本文整理汇总了C#中System.Windows.Media.Media3D.Transform3D类的典型用法代码示例。如果您正苦于以下问题:C# Transform3D类的具体用法?C# Transform3D怎么用?C# Transform3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform3D类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了Transform3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PushModelTransform
internal void PushModelTransform(Transform3D transform)
{
if (transform != null && transform != Transform3D.Identity)
{
_modelTransformStack.Push(transform.Value);
}
}
示例2: Expand
private void Expand(GeometryModel3D model, Transform3D transformation)
{
Transform3D ot;
if (originalTransforms.ContainsKey(model))
ot = originalTransforms[model];
else
{
ot = model.Transform;
originalTransforms.Add(model, ot);
}
Transform3D totalTransform = Transform3DHelper.CombineTransform(transformation, ot);
var mesh = model.Geometry as MeshGeometry3D;
if (mesh == null)
return;
var bounds = new Rect3D();
foreach (int i in mesh.TriangleIndices)
bounds.Union(totalTransform.Transform(mesh.Positions[i]));
Point3D p = bounds.Location;
Vector3D d = p - actualExpandOrigin;
d *= Expansion;
Point3D p2 = actualExpandOrigin + d;
var t = new TranslateTransform3D(p2 - p);
model.Transform = Transform3DHelper.CombineTransform(ot, t);
}
示例3: Transform3DVector
public static Vector3D Transform3DVector(Transform3D transform, Vector3D vector)
{
Point3D input = new Point3D(vector.X, vector.Y, vector.Z);
Point3D output;
return transform != null && transform.TryTransform(input, out output) ? new Vector3D(output.X, output.Y, output.Z) : vector;
}
示例4: Rotate3D
public static MatrixTransform3D Rotate3D(Transform3D transform, double x, double y, double z, Point3D center, Vector3D up, Vector3D look, RotationType type)
{
if (type != RotationType.LockAxisY)
{
up = transform.Transform(up);
}
if (type != RotationType.LockAxisZ)
{
look = transform.Transform(look);
}
center = transform.Transform(center);
Vector3D axisX = Vector3D.CrossProduct(up, look);
Matrix3D matrix = new Matrix3D();
matrix.RotateAt(new Quaternion(axisX, x), center);
matrix.RotateAt(new Quaternion(up, y), center);
matrix.RotateAt(new Quaternion(look, z), center);
MatrixTransform3D mOriginTransform = transform as MatrixTransform3D;
//mOriginTransform.Matrix.RotateAt(
try
{
return new MatrixTransform3D(Matrix3D.Multiply(mOriginTransform.Matrix, matrix));
}
catch (Exception err)
{
Exceptions.LogOnly(err);
return null;
}
}
示例5: applyTransform
//Given a 3d object, it will apply the transform to it and return the new object. Note that it will not
//overwrite the objects current transformation:
public static Model3DGroup applyTransform(Model3DGroup obj, Transform3D transform)
{
Model3DGroup newObj = new Model3DGroup();
newObj.Children.Add(obj);
newObj.Transform = transform;
return newObj;
}
示例6: CalcRotationMatrix
public static Matrix3D CalcRotationMatrix(double x, double y, double z, Point3D center, Vector3D up, Vector3D look, Transform3D transform, RotationType type)
{
//Transform3DGroup trm = new Transform3DGroup();
//trm.Children.Add(transform);
Vector3D realup = transform.Transform(up);
if (type != RotationType.LockAxisY)
{
up = realup;
}
if (type != RotationType.LockAxisZ)
{
look = transform.Transform(look);
}
center = transform.Transform(center);
Vector3D axisX = Vector3D.CrossProduct(up, look);
Matrix3D matrix = new Matrix3D();
//Quaternion q = new Quaternion();
//q.
double ang = AngleBetween(realup, YAxis) + x;
if (ang >= 90)
{
x = 90 - ang;
}
matrix.RotateAt(new Quaternion(axisX, x), center);
matrix.RotateAt(new Quaternion(up, y), center);
matrix.RotateAt(new Quaternion(look, z), center);
return matrix;
}
示例7: PrependInverseTransform
internal static void PrependInverseTransform(Transform3D transform, ref Matrix3D viewMatrix)
{
if (transform != null && transform != Transform3D.Identity)
{
PrependInverseTransform(transform.Value, ref viewMatrix);
}
}
示例8: CombineTransform
/// <summary>
/// Combines two transforms.
/// </summary>
/// <param name="t1">
/// The first transform.
/// </param>
/// <param name="t2">
/// The second transform.
/// </param>
/// <returns>
/// The combined transform group.
/// </returns>
public static Transform3D CombineTransform(Transform3D t1, Transform3D t2)
{
var g = new Transform3DGroup();
g.Children.Add(t1);
g.Children.Add(t2);
return g;
}
示例9: ExportLight
/// <summary>
/// Exports the light.
/// </summary>
/// <param name="light">
/// The light.
/// </param>
/// <param name="inheritedTransform">
/// The inherited transform.
/// </param>
protected override void ExportLight(Light light, Transform3D inheritedTransform)
{
base.ExportLight(light, inheritedTransform);
// todo...
// http://www.povray.org/documentation/view/3.6.1/34/
}
示例10: Plant
public Plant()
{
var x = new Vector3D(1, 0, 0);
var r1 = new RotateTransform3D(new AxisAngleRotation3D(x, 80));
var r2 = new RotateTransform3D(new AxisAngleRotation3D(x, -70));
var r3 = new RotateTransform3D(new AxisAngleRotation3D(x, -10));
var t1 = new TranslateTransform3D(0, 0, 0.5);
var t2 = new TranslateTransform3D(0, 0, 0.7);
var t3 = new TranslateTransform3D(0, 0, 1.0);
var s1 = new ScaleTransform3D(0.5, 0.5, 0.5);
var s2 = new ScaleTransform3D(0.3, 0.3, 0.3);
var s3 = new ScaleTransform3D(0.8, 0.8, 0.8);
var m1 = new Transform3DGroup();
m1.Children.Add(r1);
m1.Children.Add(s1);
m1.Children.Add(t1);
var m2 = new Transform3DGroup();
m2.Children.Add(r2);
m2.Children.Add(s2);
m2.Children.Add(t2);
var m3 = new Transform3DGroup();
m3.Children.Add(r3);
m3.Children.Add(s3);
m3.Children.Add(t3);
T1 = m1;
T2 = m2;
T3 = m3;
}
示例11: CreateViewMatrix
// Transfrom that moves the world to a camera coordinate system
// where the camera is at the origin looking down the negative z
// axis and y is up.
//
// NOTE: We consider camera.Transform to be part of the view matrix.
//
internal static Matrix3D CreateViewMatrix(Transform3D transform, ref Point3D position, ref Vector3D lookDirection, ref Vector3D upDirection)
{
Vector3D zaxis = -lookDirection;
zaxis.Normalize();
Vector3D xaxis = Vector3D.CrossProduct(upDirection, zaxis);
xaxis.Normalize();
Vector3D yaxis = Vector3D.CrossProduct(zaxis, xaxis);
Vector3D positionVec = (Vector3D) position;
double cx = -Vector3D.DotProduct(xaxis, positionVec);
double cy = -Vector3D.DotProduct(yaxis, positionVec);
double cz = -Vector3D.DotProduct(zaxis, positionVec);
Matrix3D viewMatrix = new Matrix3D(
xaxis.X, yaxis.X, zaxis.X, 0,
xaxis.Y, yaxis.Y, zaxis.Y, 0,
xaxis.Z, yaxis.Z, zaxis.Z, 0,
cx, cy, cz, 1);
PrependInverseTransform(transform, ref viewMatrix);
return viewMatrix;
}
示例12: AlphaSort
// http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-04-01-86-12/SceneSortingHelper_2E00_cs
/// <summary>
/// Sort Modelgroups in Farthest to Closest order, to enable transparency
/// Should be applied whenever the scene is significantly re-oriented
/// </summary>
public static void AlphaSort(Point3D cameraPosition, Model3DCollection models, Transform3D worldTransform)
{
var sortedList = models.OrderBy(model => Point3D.Subtract(cameraPosition, worldTransform.Transform(model.Bounds.Location)).Length);
models.Clear();
foreach (var model in sortedList)
{
models.Add(model);
}
}
示例13: ExportModel
/// <summary>
/// Exports the model.
/// </summary>
/// <param name="model">
/// The model.
/// </param>
/// <param name="inheritedTransform">
/// The inherited transform.
/// </param>
protected override void ExportModel(GeometryModel3D model, Transform3D inheritedTransform)
{
var mesh = model.Geometry as MeshGeometry3D;
if (mesh == null)
{
return;
}
// todo
}
示例14: ExportModel
protected override void ExportModel(GeometryModel3D model, Transform3D transform)
{
writer.WriteLine(String.Format("o object{0}", objectNo++));
writer.WriteLine(String.Format("g group{0}", groupNo++));
string matName = String.Format("mat{0}", matNo++);
writer.WriteLine(String.Format("usemtl {0}", matName));
ExportMaterial(matName, model.Material, model.BackMaterial);
var mesh = model.Geometry as MeshGeometry3D;
ExportMesh(mesh, Transform3DHelper.CombineTransform(transform, model.Transform));
}
示例15: PushVisualTransform
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
internal void PushVisualTransform(Transform3D transform)
{
Debug.Assert(!HasModelTransformMatrix,
"ModelTransform stack should be empty when pusing a visual transform");
if (transform != null && transform != Transform3D.Identity)
{
_visualTransformStack.Push(transform.Value);
}
}