CodePudding user response:
As long as you are the coordinates of the stack can be, but need to pay attention to the element is in two different spaceCodePudding user response:
In Model3DGroup can Model3DGroup. Children. The Add (model); Methods add other Model3DGroup classCodePudding user response:
Is only, for example, a 3 d model, for example, in the Grid, make two Grid, each new inside a Preview_Model, set a Grid position is overlap,Refer to http://bbs.cskin.net/thread-16048-1-1.html
Public class Preview_Model
{
Public AxisAngleRotation3D AxisAngleRotation3D;
Public PerspectiveCamera PerspectiveCamera;
Public Point3DCollection positions []=new Point3DCollection [6].
Public PointCollection [] texturepoints=new PointCollection [6].
Public Image [] Image=new Image [6].
Public System. Drawing. Bitmap [] face_image=new System. Drawing. The Bitmap [] {the Resource. The f4, Resource. F3, Resource. The f0, the Resource. The f2, Resource. The f5, the Resource. The f1};
Public Viewport3D Viewport3D;
Public MeshGeometry3D [] MeshGeometry3D=new MeshGeometry3D [6].
Public GeometryModel3D [] GeometryModel3D=new GeometryModel3D [6].
Public ModelVisual3D ModelVisual3D;
Public Model3DGroup Model3DGroup;
Public DoubleAnimation animation;
Public Storyboard RotCube;
Public void init_draw (Grid obj, double x, double y, double z, double the size)
{
Set_Scaling (x, y, z);
Texturepoints=new PointCollection [6]
{
New PointCollection {new Point (1, 0), new Point (0, 0), new Point (0, 1), new Point (0, 1), new Point (1, 1), new Point (1, 0)},
New PointCollection {new Point (0, 0), new Point (0, 1), new Point (1, 1), new Point (1, 1), new Point (1, 0), new Point (0, 0)},
New PointCollection {new Point (0, 1), new Point (1, 1), new Point (1, 0), new Point (1, 0), new Point (0, 0), new Point (0, 1)},
New PointCollection {new Point (1, 1), new Point (1, 0), new Point (0, 0), new Point (0, 0), new Point (0, 1), new Point (1, 1)},
New PointCollection {new Point (0, 1), new Point (1, 1), new Point (1, 0), new Point (1, 0), new Point (0, 0), new Point (0, 1)},
New PointCollection {new Point (1, 1), new Point (1, 0), new Point (0, 0), new Point (0, 0), new Point (0, 1), new Point (1, 1)}
};
Viewport3D=new viewport3D ();
PerspectiveCamera=new perspectiveCamera ()
{
The Position=new Point3D (0, 0, 3),
LookDirection=new Vector3D (0, 0, 3),
FieldOfView=size,
UpDirection=new Vector3D (0, 1, 0),
FarPlaneDistance=20,
NearPlaneDistance=0,
};
Viewport3D. Camera=perspectiveCamera;
ModelVisual3D=new modelVisual3D ();
Model3DGroup=new model3DGroup ();
for (int i=0; I & lt; 6; I++)
{
GeometryModel3D [I]=new geometryModel3D ();
DiffuseMaterial diffuse=new DiffuseMaterial ();
VisualBrush VisualBrush=new VisualBrush ();
Image [I]=new image ();
Image [I] Source=Function. BitmapToImageSource (face_image [I]);
VisualBrush. Visual=image [I];
Diffuse. Brush=visualBrush;
GeometryModel3D [I]. Material=diffuse;
MeshGeometry3D [I]=new meshGeometry3D ()
{
Positions=Positions [I],
TextureCoordinates=texturepoints [I],
};
GeometryModel3D [I]. Geometry=meshGeometry3D [I];
Model3DGroup. Children. The Add (geometryModel3D [I]);
}
AmbientLight AmbientLight=new AmbientLight ();
Model3DGroup. Children. The Add (ambientLight);
ModelVisual3D. The Content=model3DGroup;
Viewport3D. Children. The Add (modelVisual3D);
Obj. Children. The Add (viewport3D);
AxisAngleRotation3D=new axisAngleRotation3D (new Vector3D (0, 1, 0), 0).
RotateTransform3D rotate=new RotateTransform3D (axisAngleRotation3D);
ModelVisual3D. Transform=rotate;
Animation=new DoubleAnimation ();
Animation. The From=0;
Animation. To=360;
Animation. Duration=new Duration (TimeSpan. FromSeconds (10.0));
Animation. RepeatBehavior=RepeatBehavior. Forever;
NameScope. SetNameScope (obj, new NameScope ());
Obj. RegisterName (" cubeaxis axisAngleRotation3D);
Storyboard. SetTargetName (animation, "cubeaxis");
Storyboard. SetTargetProperty (animation, new PropertyPath (AxisAngleRotation3D. AngleProperty));
RotCube=new Storyboard ();
RotCube. Children. The Add (animation);
RotCube. The Begin (obj, true);
}
Public void Set_Scaling (double x, double y, double z)
{
Positions [0]=new Point3DCollection (new Point3D [] {
New Point3D (x, y, z), new Point3D (x, y, z), new Point3D (x, y, z),
New Point3D (x, y, z), new Point3D (x, y, z), new Point3D (x, y, z)
});
Positions [1]=new Point3DCollection (new Point3D [] {
New Point3D (x, y, z), new Point3D (- x, y, z), new Point3D (- x, y, z),
New Point3D (- x, y, z), new Point3D (x, y, z), new Point3D (x, y, z)
});
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull