本文整理汇总了C#中System.Matrix.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Translate方法的具体用法?C# Matrix.Translate怎么用?C# Matrix.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.Translate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
private void Render()
{
if (device == null)
return;
Matrix QuadMatrix = new Matrix();
QuadMatrix = Matrix.Identity;
QuadMatrix.Translate(-1f, 1f, 0f);
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
device.BeginScene();
device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.SetTransform(TransformType.World, QuadMatrix);
device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
QuadMatrix.Translate(-0.64f, 0.64f, 0f);
device.SetTransform(TransformType.World, QuadMatrix);
device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
device.EndScene();
device.Present();
}
示例2: Run
/// <summary>
/// Executes the command.
/// Moves the selected Item's Joints around a given point and with a given angle.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
Dictionary<Joint, Joint> joints = new Dictionary<Joint, Joint>();
ItemList<Joint> jList = services.Model.JointList;
ItemList<LineElement> lList = services.Model.LineList;
List<Item> selection = services.GetSelection();
if (selection.Count == 0)
return;
foreach (Item item in selection)
{
if (item is Joint)
joints.Add((Joint)item, null);
else if (item is LineElement)
{
LineElement l = (LineElement)item;
if (!joints.ContainsKey(l.I))
joints.Add(l.I, null);
if (!joints.ContainsKey(l.J))
joints.Add(l.J, null);
}
}
Microsoft.DirectX.Vector3 v, v2;
float angle = float.Parse(services.GetString(Culture.Get("getRotationAngle")));
angle *= (float)Math.PI / 180.0F;
Controller.Snap.Magnet m = services.GetPoint(Culture.Get("getRotationCenter"));
if (m == null) return;
v = m.SnapPosition;
services.TrackingService = LineTrackingService.Instance;
services.TrackingService.SetPoint(m.SnapPositionInt);
m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
if (m == null) return;
v2 = m.SnapPosition;
if (v2.Equals(v))
{
Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
Vector3 v1Tmp = new Vector3(0, 0, 0);
Vector3 v2Tmp = new Vector3(0, 0, 1);
view.Unproject(ref v1Tmp);
view.Unproject(ref v2Tmp);
v2 = v2 + v1Tmp - v2Tmp;
}
services.TrackingService = null;
Matrix trans1 = new Matrix();
trans1.Translate(-v);
Matrix rot = new Matrix();
rot.RotateAxis(v2 - v, angle);
Matrix trans2 = new Matrix();
trans2.Translate(v);
rot = trans1 * rot * trans2;
foreach (Joint j in joints.Keys)
{
Vector3 pos = new Vector3(j.X, j.Y, j.Z);
pos.TransformCoordinate(rot);
j.X = pos.X;
j.Y = pos.Y;
j.Z = pos.Z;
}
}
示例3: render
public void render(Vector3 desplazamiento)
{
if (!enabled)
return;
Device d3dDevice = GuiController.Instance.D3dDevice;
TgcTexture.Manager texturesManager = GuiController.Instance.TexturesManager;
//Textura
effect.SetValue("texDiffuseMap", terrainTexture);
texturesManager.clear(1);
Matrix traslacion = new Matrix();
traslacion.Translate(desplazamiento.X, desplazamiento.Y, desplazamiento.Z);
//GuiController.Instance.Shaders.setShaderMatrix(this.effect, Matrix.Identity);
GuiController.Instance.Shaders.setShaderMatrix(this.effect, traslacion);
d3dDevice.VertexDeclaration = GuiController.Instance.Shaders.VdecPositionTextured;
effect.Technique = this.technique;
d3dDevice.SetStreamSource(0, vbTerrain, 0);
//Render con shader
effect.Begin(0);
effect.BeginPass(0);
d3dDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, totalVertices / 3);
effect.EndPass();
effect.End();
}
示例4: transform
/// <summary>
/// Aplicar transformacion
/// </summary>
private void transform(Device d3dDevice)
{
//Crear matrices
Matrix matTranslate = new Matrix();
Matrix matRotate = new Matrix();
Matrix matScale = new Matrix();
Matrix matFinal = new Matrix();
matTranslate = Matrix.Identity;
matRotate = Matrix.Identity;
matScale = Matrix.Identity;
matFinal = Matrix.Identity;
//Generar las matrices para cada movimiento
matTranslate.Translate((float)GuiController.Instance.Modifiers["translateX"], 0, 0);
matRotate.RotateZ((float)GuiController.Instance.Modifiers["rotationZ"]);
float scale = (float)GuiController.Instance.Modifiers["ScaleXYZ"];
matScale.Scale(scale,scale,scale);
//Multiplicar todas las matrices en una sola final
matFinal = matScale * matRotate* matTranslate;
//Configurar la matriz de transformación actual de DirectX para todo lo que se va a dibujar a continuacion
d3dDevice.Transform.World = matFinal;
}
示例5: MakeArc
private void MakeArc(Canguro.Model.Model model, Vector3 C, Vector3 N, Joint from, Joint until, Joint passing, int segments)
{
Vector3 p0 = from.Position;
Vector3 p1 = until.Position;
Vector3 p2 = passing.Position;
Vector3 a = Vector3.Normalize(C - p0);
Vector3 b = Vector3.Normalize(C - p1);
Vector3 c = Vector3.Normalize(C - p2);
N.Normalize();
float ang = (float)Math.Acos(Vector3.Dot(a, b));
float p2Ang = (float)Math.Acos(Vector3.Dot(a, c));
ang = (Vector3.Dot(Vector3.Cross(a, N), b) > 0) ? 2f * (float)Math.PI-ang : ang;
p2Ang = (Vector3.Dot(Vector3.Cross(a, N), c) > 0) ? 2f * (float)Math.PI - p2Ang : p2Ang;
List<Joint> joints = new List<Joint>();
joints.Add(from);
float angle = 0;
ang /= segments;
for (int i = 0; i < segments - 1; i++)
{
angle += ang;
Matrix trans1 = new Matrix();
trans1.Translate(-C);
Matrix rot = new Matrix();
rot.RotateAxis(N, angle);
Matrix trans2 = new Matrix();
trans2.Translate(C);
rot = trans1 * rot * trans2;
Vector3 pos = from.Position;
pos.TransformCoordinate(rot);
if (Math.Abs(angle) > Math.Abs(p2Ang) && Math.Abs(angle) < Math.Abs(p2Ang + ang))
joints.Add(passing);
Joint joint = new Joint(pos.X, pos.Y, pos.Z);
joints.Add(joint);
model.JointList.Add(joint);
}
joints.Add(until);
StraightFrameProps props = new StraightFrameProps();
for (int i = 1; i < joints.Count; i++)
{
model.LineList.Add(new LineElement(props, joints[i - 1], joints[i]));
}
}
示例6: Run
//.........这里部分代码省略.........
jSelection.Add(l.J, null);
joints.Add(l.J, null);
}
}
else if (item is AreaElement)
{
AreaElement a = (AreaElement)item;
aSelection.Add(a);
areas.Add(a);
if (!jSelection.ContainsKey(a.J1))
{
jSelection.Add(a.J1, null);
joints.Add(a.J1, null);
}
if (!jSelection.ContainsKey(a.J2))
{
jSelection.Add(a.J2, null);
joints.Add(a.J2, null);
}
if (!jSelection.ContainsKey(a.J3))
{
jSelection.Add(a.J3, null);
joints.Add(a.J3, null);
}
if (a.J4 != null && !jSelection.ContainsKey(a.J4))
{
jSelection.Add(a.J4, null);
joints.Add(a.J4, null);
}
}
}
Microsoft.DirectX.Vector3 v, v2;
uint n = (uint)services.GetSingle(Culture.Get("getArrayRepetition"));
float dAngle = float.Parse(services.GetString(Culture.Get("getPolarArrayAngle")));
dAngle *= (float)Math.PI / 180.0F;
float angle = 0.0F;
Controller.Snap.Magnet m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
if (m == null) return;
v = m.SnapPosition;
services.TrackingService = LineTrackingService.Instance;
services.TrackingService.SetPoint(m.SnapPositionInt);
m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
if (m == null) return;
v2 = m.SnapPosition;
if (v2.Equals(v))
{
Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
Vector3 v1Tmp = new Vector3(0, 0, 0);
Vector3 v2Tmp = new Vector3(0, 0, 1);
view.Unproject(ref v1Tmp);
view.Unproject(ref v2Tmp);
v2 = v2 + v1Tmp - v2Tmp;
}
services.TrackingService = null;
List<Joint> newJoints = new List<Joint>();
List<LineElement> newLines = new List<LineElement>();
List<AreaElement> newAreas = new List<AreaElement>();
for (int i = 1; i <= n; i++)
{
angle += dAngle;
Matrix trans1 = new Matrix();
trans1.Translate(-v);
Matrix rot = new Matrix();
rot.RotateAxis(v2 - v, angle);
Matrix trans2 = new Matrix();
trans2.Translate(v);
rot = trans1 * rot * trans2;
foreach (Joint j in joints.Keys)
{
Vector3 pos = new Vector3(j.X, j.Y, j.Z);
pos.TransformCoordinate(rot);
jList.Add(nJoint = new Joint(pos.X, pos.Y, pos.Z));
nJoint.Masses = j.Masses;
nJoint.DoF = j.DoF;
jSelection[j] = nJoint;
newJoints.Add(nJoint);
}
foreach (LineElement l in lines)
{
lList.Add(nLine = new LineElement(l, jSelection[l.I], jSelection[l.J]));
newLines.Add(nLine);
}
foreach (AreaElement a in areas)
{
aList.Add(nArea = new AreaElement(a, jSelection[a.J1], jSelection[a.J2], jSelection[a.J3], (a.J4 != null) ? jSelection[a.J4] : null));
newAreas.Add(nArea);
}
}
JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
}