Transformation zum Knoten hinzufügen
Contents
[
Hide
]
Aspose.3D for .NET bietet an, Objekte in 3D Raum zu drehen. Es gibt drei Möglichkeiten, die Rotation des Objekts im 3D-Raum, Euler winkeln, Quaternion und Custom Matrix zu definieren. Alle werden von der
Transform
-Klasse unterstützt.
TSR (Translation/Skalierung/Rotation) werden am häufigsten im 3D-Szenario verwendet. Wir haben eine Klasse Transform
bereit gestellt, um auf diese in Aspose.3D zuzugreifen. Affine Transformationen umfassen:
- Übersetzung
- Skalierung
- Rotation
- Scher kartierung
- Squeeze-Mapping
Das
Mesh
-Klassen objekt wird im Code verwendet. Wir können Erstellen Sie ein Mesh-Klassen objekt, wie es dort erzählt wird.
Drehen Sie durch Quaternion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET | |
// Initialize scene object | |
Scene scene = new Scene(); | |
// Initialize Node class object | |
Node cubeNode = new Node("cube"); | |
// Call Common class create mesh using polygon builder method to set mesh instance | |
Mesh mesh = Common.CreateMeshUsingPolygonBuilder(); | |
// Point node to the Mesh geometry | |
cubeNode.Entity = mesh; | |
// Set rotation | |
cubeNode.Transform.Rotation = Quaternion.FromRotation(new Vector3(0, 1, 0), new Vector3(0.3, 0.5, 0.1)); | |
// Set translation | |
cubeNode.Transform.Translation = new Vector3(0, 0, 20); | |
// Add cube to the scene | |
scene.RootNode.ChildNodes.Add(cubeNode); | |
// Save 3D scene in the supported file formats | |
scene.Save("TransformationToNode.fbx"); |
Drehen Sie durch Euler Winkel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET | |
// Initialize scene object | |
Scene scene = new Scene(); | |
// Initialize Node class object | |
Node cubeNode = new Node("cube"); | |
// Call Common class create mesh using polygon builder method to set mesh instance | |
Mesh mesh = Common.CreateMeshUsingPolygonBuilder(); | |
// Point node to the Mesh geometry | |
cubeNode.Entity = mesh; | |
// Euler angles | |
cubeNode.Transform.EulerAngles = new Vector3(0.3, 0.1, -0.5); | |
// Set translation | |
cubeNode.Transform.Translation = new Vector3(0, 0, 20); | |
// Add cube to the scene | |
scene.RootNode.ChildNodes.Add(cubeNode); | |
// Save 3D scene in the supported file formats | |
scene.Save("TransformationToNode.fbx"); |
Individuelle Transformation matrix
Wir können Matrix auch direkt verwenden:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET | |
// Initialize scene object | |
Scene scene = new Scene(); | |
// Initialize Node class object | |
Node cubeNode = new Node("cube"); | |
// Call Common class create mesh using polygon builder method to set mesh instance | |
Mesh mesh = Common.CreateMeshUsingPolygonBuilder(); | |
// Point node to the Mesh geometry | |
cubeNode.Entity = mesh; | |
// Set custom translation matrix | |
cubeNode.Transform.TransformMatrix = new Matrix4( | |
1, -0.3, 0, 0, | |
0.4, 1, 0.3, 0, | |
0, 0, 1, 0, | |
0, 20, 0, 1 | |
); | |
// Add cube to the scene | |
scene.RootNode.ChildNodes.Add(cubeNode); | |
// Save 3D scene in the supported file formats | |
scene.Save("TransformationToNode.fbx"); |