本文整理汇总了C#中Matrix4F.TransformVector方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4F.TransformVector方法的具体用法?C# Matrix4F.TransformVector怎么用?C# Matrix4F.TransformVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4F
的用法示例。
在下文中一共展示了Matrix4F.TransformVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDragging
public override void OnDragging(ViewControl vc, Point scrPt)
{
if (m_hitRegion == HitRegion.None || m_activeOp == null || m_activeOp.NodeList.Count == 0)
return;
// create ray in view space.
Ray3F rayV = vc.GetWorldRay(scrPt);
using (var intersectionScene = GameEngine.GetEditorSceneManager().GetIntersectionScene())
{
Vec3F intersectionPt;
if (!CalculateTerrainIntersection(vc, rayV, intersectionScene, out intersectionPt))
return;
if (m_pendingStartPt)
{
m_startPt = intersectionPt;
m_pendingStartPt = false;
}
else
{
bool clampToSurface = Control.ModifierKeys == Keys.Shift;
Vec3F translate = new Vec3F(intersectionPt.X - m_startPt.X, intersectionPt.Y - m_startPt.Y, 0.0f);
for (int i = 0; i < m_activeOp.NodeList.Count; i++)
{
ITransformable node = m_activeOp.NodeList[i];
Path<DomNode> path = new Path<DomNode>(Adapters.Cast<DomNode>(node).GetPath());
Matrix4F parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
Matrix4F parentWorldToLocal = new Matrix4F();
parentWorldToLocal.Invert(parentLocalToWorld);
Vec3F newWorldPos = m_originalTranslations[i] + translate;
float terrainHeight = 0.0f;
if (GUILayer.EditorInterfaceUtils.GetTerrainHeight(
out terrainHeight, intersectionScene, newWorldPos.X, newWorldPos.Y)) {
newWorldPos.Z = terrainHeight + (clampToSurface ? 0.0f : m_originalHeights[i]);
Vec3F localTranslation;
parentWorldToLocal.TransformVector(newWorldPos, out localTranslation);
node.Translation = localTranslation;
}
}
}
}
}
示例2: Transform
/// <summary>
/// Transforms the ray by the given matrix. The Direction member will be normalized. There are
/// no particular restrictions on M. Any transformation done to a point in world space or
/// object space can be done on this ray, including any combination of rotations, translations,
/// uniform scales, non-uniform scales, etc.</summary>
/// <param name="M">Transformation matrix</param>
public void Transform(Matrix4F M)
{
M.Transform(Origin, out Origin);
M.TransformVector(Direction, out Direction);
Direction.Normalize();
}
示例3: OnDragging
//.........这里部分代码省略.........
m_cancelDrag = true; //stop further snap-to's
}
else
{
manipMove = rayW.ProjectPoint(manipPos) - manipPos;
}
for (int i = 0; i < NodeList.Count; i++)
{
ITransformable node = NodeList[i];
Vec3F snapOffset = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
Path<DomNode> path = new Path<DomNode>(Adapters.Cast<DomNode>(node).GetPath());
Matrix4F parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
Vec3F orgPosW;
parentLocalToWorld.Transform(m_originalValues[i], out orgPosW);
Matrix4F parentWorldToLocal = new Matrix4F();
parentWorldToLocal.Invert(parentLocalToWorld);
rayW.MoveToIncludePoint(orgPosW + snapOffset + manipMove);
HitRecord[] hits = GameEngine.RayPick(view, proj, rayW, true);
bool cansnap = false;
HitRecord target = new HitRecord();
if (hits.Length > 0)
{
// find hit record.
foreach (var hit in hits)
{
if (m_snapFilter.CanSnapTo(node, GameEngine.GetAdapterFromId(hit.instanceId)))
{
target = hit;
cansnap = true;
break;
}
}
}
if (cansnap)
{
Vec3F pos;
if (target.hasNearestVert && snapSettings.SnapVertex)
{
pos = target.nearestVertex;
}
else
{
pos = target.hitPt;
}
pos -= snapOffset;
parentWorldToLocal.Transform(ref pos);
Vec3F diff = pos - node.Transform.Translation;
node.Translation += diff;
bool rotateOnSnap = snapSettings.RotateOnSnap
&& target.hasNormal
&& (node.TransformationType & TransformationTypes.Rotation) != 0;
if (rotateOnSnap)
{
Vec3F localSurfaceNormal;
parentWorldToLocal.TransformNormal(target.normal, out localSurfaceNormal);
node.Rotation = TransformUtils.RotateToVector(
m_originalRotations[i],
localSurfaceNormal,
AxisSystemType.YIsUp);
}
}
}
}
else
{
IGrid grid = DesignView.Context.Cast<IGame>().Grid;
bool snapToGrid = Control.ModifierKeys == m_snapGridKey
&& grid.Visible
&& vc.Camera.ViewType == ViewTypes.Perspective;
float gridHeight = grid.Height;
// translate.
for (int i = 0; i < NodeList.Count; i++)
{
ITransformable node = NodeList[i];
Path<DomNode> path = new Path<DomNode>(Adapters.Cast<DomNode>(node).GetPath());
Matrix4F parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
Matrix4F parentWorldToLocal = new Matrix4F();
parentWorldToLocal.Invert(parentLocalToWorld);
Vec3F localTranslation;
parentWorldToLocal.TransformVector(translate, out localTranslation);
Vec3F trans = m_originalValues[i] + localTranslation;
if(snapToGrid)
{
if(grid.Snap)
trans = grid.SnapPoint(trans);
else
trans.Y = gridHeight;
}
node.Translation = trans;
}
}
}