Ajout de la transformation au nœud
Contents
[
Hide
]
Aspose.3D for .NET propose de faire pivoter des objets dans un espace 3D. Il existe trois façons de définir la rotation de l’objet dans l’espace 3D, les angles d’Euler, Quaternion et la matrice personnalisée, toutes sont supportées par la classe
Transform.
Les TSR (Translation/Scaling/Rotation) sont les plus couramment utilisés dans le scénario 3D, nous avons fourni une classe Transform pour y accéder dans Aspose.3D. Les transformations affines comprennent:
- Traduction
- Mise à l’échelle
- Rotation
- Cartographie de cisaillement
- Cartographie à presser
L’objet de classe
Mesh est utilisé dans le code. Nous pouvons Créer un objet de classe Mesh tel que raconté là-bas.
Tourner par Quaternion
// 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");
Tourner par Euler Angles
// 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");
Matrice de transformation personnalisée
Nous pouvons également utiliser Matrix directement:
// 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");