本文整理汇总了C#中System.Windows.Media.Media3D.RotateTransform3D类的典型用法代码示例。如果您正苦于以下问题:C# RotateTransform3D类的具体用法?C# RotateTransform3D怎么用?C# RotateTransform3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RotateTransform3D类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了RotateTransform3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CellNet
public CellNet(INetwork network, ModelVisual3D mophology, Dictionary<Guid, ICell> cells, Dictionary<Guid, ICellNet> childcellnet)
{
this.network = network;
this.mophology = mophology;
this.cells = cells;
this.childcellnet = childcellnet;
IsPushing = true;
var transforms = new Transform3DGroup();
Rotate = new RotateTransform3D(new QuaternionRotation3D());
Translate = new TranslateTransform3D(network.Position.X, network.Position.Y, network.Position.Z);
Scale = new ScaleTransform3D();
transforms.Children.Add(Rotate);
transforms.Children.Add(Translate);
transforms.Children.Add(Scale);
Mophology.Transform = transforms;
var binding = new Binding()
{
Source = network,
Path = new PropertyPath("Position"),
Mode = BindingMode.OneWay
};
BindingOperations.SetBinding(this, CellNet.PositionProperty, binding);
}
示例2: GetRotateTransform3D
public static RotateTransform3D GetRotateTransform3D(this XbimMatrix3D m)
{
RotateTransform3D r = new RotateTransform3D();
XbimQuaternion xq = m.GetRotationQuaternion();
r.Rotation = new QuaternionRotation3D(new Quaternion(xq.X, xq.Y, xq.Z, xq.W * (180.0 / Math.PI)));
return r;
}
示例3: Cell
public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager)
{
this.neuron = neuron;
this.mophology = mophology;
this.imager = imager;
neuron.Updated += OnUpdated;
neuron.Hillock.Spike += OnSpike;
IsPushing = true;
var transforms = new Transform3DGroup();
Rotate = new RotateTransform3D(new QuaternionRotation3D());
Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z);
Scale = new ScaleTransform3D();
transforms.Children.Add(Rotate);
transforms.Children.Add(Translate);
transforms.Children.Add(Scale);
Mophology.Transform = transforms;
var binding = new Binding()
{
Source = neuron,
Path = new PropertyPath("Position"),
Mode = BindingMode.OneWay
};
BindingOperations.SetBinding(this, Cell.PositionProperty, binding);
}
示例4: 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;
}
示例5: Sphere
// Public constructor to initialize those fields, etc
public Sphere()
{
rotate = new AxisAngleRotation3D();
xform = new RotateTransform3D(rotate);
PropertyChanged(this, new DependencyPropertyChangedEventArgs());
}
示例6: Cylinder
// Public constructor to initialize those fields, etc
public Cylinder()
{
rotate = new AxisAngleRotation3D();
xform = new RotateTransform3D(rotate);
PropertyChanged(new DependencyPropertyChangedEventArgs());
}
示例7: ThrustLine
public ThrustLine(Viewport3D viewport, SharedVisuals sharedVisuals, Vector3D forceDirection, Vector3D localOffset)
{
this.Viewport = viewport;
_forceDirection = forceDirection;
_forceStrength = forceDirection.Length; // this way they don't have to set this if they don't want
this.BodyOffset = new TranslateTransform3D(localOffset); // just setting it to something so it's not null
#region Create Visual
// I'll create the visual, but won't add it until they fire the thruster
// Material
MaterialGroup materials = new MaterialGroup();
materials.Children.Add(new DiffuseMaterial(Brushes.Coral));
materials.Children.Add(new SpecularMaterial(Brushes.Gold, 100d));
// Geometry Model
// Create a skinny 3D rectangle along the x axis
GeometryModel3D geometry = new GeometryModel3D();
geometry.Material = materials;
geometry.BackMaterial = materials;
geometry.Geometry = sharedVisuals.ThrustLineMesh;
// Figure out how much to rotate the cube to be along the opposite of the force line. I do the opposite, because
// thruster flames shoot in the opposite direction that they're pushing
Vector3D flameLine = forceDirection;
flameLine.Negate();
Vector3D axis;
double radians;
Math3D.GetRotation(out axis, out radians, new Vector3D(1, 0, 0), flameLine);
if (radians == 0d)
{
_initialRotate = null;
}
else
{
_initialRotate = new RotateTransform3D(new AxisAngleRotation3D(axis, Math1D.RadiansToDegrees(radians)));
}
//// Transform
//Transform3DGroup transform = new Transform3DGroup(); // rotate needs to be added before translate
//transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(axis, Math3D.RadiansToDegrees(radians))));
//transform.Children.Add(new TranslateTransform3D(from));
// Model Visual
_model = new ModelVisual3D();
_model.Content = geometry;
_model.Transform = new TranslateTransform3D(); // I won't do anything with this right now
#endregion
}
示例8: makeAxisTransform
//Create a rotation transformation about the specified axis by the specified number of degrees anti-clockwise:
public static RotateTransform3D makeAxisTransform(Vector3D axis, double angle)
{
RotateTransform3D myRotateTransform3D = new RotateTransform3D();
AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
myAxisAngleRotation3d.Axis = axis;
myAxisAngleRotation3d.Angle = angle; //rotate anticlockwise by the specified angle
myRotateTransform3D.Rotation = myAxisAngleRotation3d;
return myRotateTransform3D;
}
示例9: Render
public ModelVisual3D Render()
{
_blocks = new GeometryModel3D[_dimension, _dimension, _dimension];
Model3DGroup group = new Model3DGroup();
double space = 0.03;
double w = (1 - space * (_dimension - 1)) / _dimension;
double slot = w + space;
ScaleTransform3D scaling = new ScaleTransform3D(w, w, w);
for (int i = 0; i < _dimension * _dimension * _dimension; i++)
{
int x = i % _dimension;
int y = (int)(i / _dimension) % _dimension;
int z = (int)(i / (_dimension * _dimension));
GeometryModel3D c = CreateMiniCube();
_blocks[x, y, z] = c;
TranslateTransform3D pos = new TranslateTransform3D((slot * x), (slot * y), -(slot * z));
Transform3DGroup tgroup = new Transform3DGroup();
tgroup.Children.Add(scaling);
tgroup.Children.Add(pos);
c.Transform = tgroup;
group.Children.Add(c);
}
Transform3DGroup cubeTransGroup = new Transform3DGroup();
TranslateTransform3D cubePos = new TranslateTransform3D(-0.5, -0.5, 0.5);
cubeTransGroup.Children.Add(cubePos);
// Animation
_spinTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0));
//Vector3DAnimation myVectorAnimation = new Vector3DAnimation(new Vector3D(0, 0, -1), new Duration(TimeSpan.FromMilliseconds(5000)));
//myVectorAnimation.RepeatBehavior = RepeatBehavior.Forever;
//myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation);
//myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, doubleAnim);
cubeTransGroup.Children.Add(_spinTransform);
// Animation end
group.Transform = cubeTransGroup;
ModelVisual3D model = new ModelVisual3D();
model.Content = group;
return model;
}
示例10: Trackball
public Trackball(double rotationFactor = 4.0, double zoomFacfor = 1.0) {
_rotationFactor = rotationFactor;
_zoomFactor = zoomFacfor;
_transform = new Transform3DGroup();
_transform.Children.Add(_scale);
_rotateTransform = new RotateTransform3D(_rotation);
_transform.Children.Add(_rotateTransform);
_transform.Children.Add(_translate);
}
示例11: Move
public void Move(double offsetX, double offsetY, double offsetZ, double angle)
{
Transform3DGroup transform = new Transform3DGroup();
RotateTransform3D rotateTrans = new RotateTransform3D();
rotateTrans.Rotation = new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle);
TranslateTransform3D translateTrans = new TranslateTransform3D(offsetX, offsetY, offsetZ);
transform.Children.Add(rotateTrans);
transform.Children.Add(translateTrans);
this.Transform = transform;
}
示例12: Cube
public Cube(Viewport3D myViewport3D, float obesity)
{
this.up = ((PerspectiveCamera)myViewport3D.Camera).UpDirection;
this.trans = new Transform3DGroup();
this.scale = new ScaleTransform3D();
this.translation = new TranslateTransform3D();
this.rotation = new RotateTransform3D();
this.axis = new AxisAngleRotation3D();
this.obesity = obesity;
this.cube = new Model3DGroup();
Point3D p0 = new Point3D(-1, -1, -1);
Point3D p1 = new Point3D(1, -1, -1);
Point3D p2 = new Point3D(1, -1, 1);
Point3D p3 = new Point3D(-1, -1, 1);
Point3D p4 = new Point3D(-1, 0, -1);
Point3D p5 = new Point3D(1, 0, -1);
Point3D p6 = new Point3D(1, 0, 1);
Point3D p7 = new Point3D(-1, 0, 1);
//front side triangles
cube.Children.Add(CreateTriangleModel(p3, p2, p6));
cube.Children.Add(CreateTriangleModel(p3, p6, p7));
//right side triangles
cube.Children.Add(CreateTriangleModel(p2, p1, p5));
cube.Children.Add(CreateTriangleModel(p2, p5, p6));
//back side triangles
cube.Children.Add(CreateTriangleModel(p1, p0, p4));
cube.Children.Add(CreateTriangleModel(p1, p4, p5));
//left side triangles
cube.Children.Add(CreateTriangleModel(p0, p3, p7));
cube.Children.Add(CreateTriangleModel(p0, p7, p4));
//top side triangles
cube.Children.Add(CreateTriangleModel(p7, p6, p5));
cube.Children.Add(CreateTriangleModel(p7, p5, p4));
//bottom side triangles
cube.Children.Add(CreateTriangleModel(p2, p3, p0));
cube.Children.Add(CreateTriangleModel(p2, p0, p1));
this.model = new ModelVisual3D();
this.model.Content = cube;
this.myDirectionalLight = new DirectionalLight();
this.myDirectionalLight.Color = Colors.Green;
this.myDirectionalLight.Direction = new Vector3D(-2, -3, 1);
this.cube.Children.Add(myDirectionalLight);
myViewport3D.Children.Add(model);
trans.Children.Add(scale);
trans.Children.Add(rotation);
trans.Children.Add(translation);
this.cube.Transform = trans;
}
示例13: UserControl1
public UserControl1()
{
InitializeComponent();
ax3d = new AxisAngleRotation3D(new Vector3D(0, 2, 0), 1);
RotateTransform3D myRotateTransform = new RotateTransform3D(ax3d);
var ModelVisual3D = this.GetModel();
MatrixTransform3D mTransform = new MatrixTransform3D();
ModelVisual3D.Transform = myRotateTransform;
//model
////
}
示例14: AddBone
private static void AddBone(MeshGeometry3D mesh, Point3D startPoint, Point3D endPoint)
{
AxisAngleRotation3D rotate = new AxisAngleRotation3D();
RotateTransform3D xform = new RotateTransform3D(rotate);
Vector3D boneVec = endPoint - startPoint;
// radius always points towards -Z (when possible)
Vector3D radius;
if (boneVec.X == 0 && boneVec.Y == 0)
{
// Special case.
radius = new Vector3D(0, -1, 0);
}
else
{
// Find vector axis 90 degrees from bone where Z == 0
rotate.Axis = Vector3D.CrossProduct(boneVec, new Vector3D(0, 0, 1));
rotate.Angle = -90;
// Rotate 90 degrees to find radius vector
radius = boneVec * xform.Value;
radius.Normalize();
}
// Rotate the radius around the bone vector
rotate.Axis = boneVec;
var positions = mesh.Positions;
const int slices = 10;
for (int slice = 0; slice < slices; ++slice)
{
// Rotate radius vector
rotate.Angle = slice * 360.0 / slices;
Vector3D vectRadius = radius * xform.Value;
rotate.Angle = (slice + 1) * 360.0 / slices;
Vector3D vectRadius1 = radius * xform.Value;
// Bit of a hack to avoid having to set the normals or worry about consistent winding.
positions.Add(startPoint);
positions.Add(endPoint + delta * vectRadius);
positions.Add(endPoint + delta * vectRadius1);
positions.Add(startPoint);
positions.Add(endPoint + delta * vectRadius1);
positions.Add(endPoint + delta * vectRadius);
}
}
示例15: VerticalTransform
private void VerticalTransform(bool upDown, double angleDeltaFactor)
{
Vector3D postion = new Vector3D(myPerspectiveCamera.Position.X, myPerspectiveCamera.Position.Y, myPerspectiveCamera.Position.Z);
Vector3D rotateAxis = Vector3D.CrossProduct(postion, myPerspectiveCamera.UpDirection);
RotateTransform3D rt3d = new RotateTransform3D();
AxisAngleRotation3D rotate = new AxisAngleRotation3D(rotateAxis, angleDeltaFactor * (upDown ? -1 : 1));
rt3d.Rotation = rotate;
Matrix3D matrix = rt3d.Value;
Point3D newPostition = matrix.Transform(myPerspectiveCamera.Position);
myPerspectiveCamera.Position = newPostition;
myPerspectiveCamera.LookDirection = new Vector3D(-newPostition.X, -newPostition.Y, -newPostition.Z);
Vector3D newUpDirection = Vector3D.CrossProduct(myPerspectiveCamera.LookDirection, rotateAxis);
newUpDirection.Normalize();
myPerspectiveCamera.UpDirection = newUpDirection;
}