Lägga till omvandling i noden
Contents
[
Hide
]
Aspose.3D for Python via .NET erbjuder att rotera objekt i 3D mellanslag. Det finns tre sätt att definiera objekts rotation i 3D utrymme, Euler vinklar, Quaternion och Custom Matrix, Alla stöds av klassen
Transform.
TSR (översättning/skalning/rotation) används oftast i 3D scenario, vi tillhandahöll en klass Transform för att komma åt dessa i Aspose. 3D. Affina transformationer omfattar:
- Översättning
- Skalning
- Rotationer
- Skjut avbildning
- Tryck på kartläggning
The
Mesh class object is being used in the code. We can create a Mesh class object as narrated there.
Rotera med kvittering
from aspose.threed import FileFormat, Node, Scene
from aspose.threed.utilities import Quaternion, Vector3
# For complete examples and data files, please go to https:# github.com/aspose-3d/Aspose.3D-for-.NET
# Initialize scene object
scene = Scene()
# Initialize Node class object
cubeNode = Node("cube")
# Call Common class create mesh using polygon builder method to set mesh instance
mesh = Common.CreateMeshUsingPolygonBuilder()
# Point node to the Mesh geometry
cubeNode.entity = mesh
# Set rotation
cubeNode.transform.rotation = Quaternion.from_rotation(Vector3(0, 1, 0), Vector3(0.3, 0.5, 0.1))
# Set translation
cubeNode.transform.translation = Vector3(0, 0, 20)
# Add cube to the scene
scene.root_node.child_nodes.append(cubeNode)
# The path to the documents directory.
output = "out" + "TransformationToNode.fbx"
# Save 3D scene in the supported file formats
scene.save(output, FileFormat.FBX7500ASCII)Rotera med Euler vinklar
from aspose.threed import FileFormat, Node, Scene
from aspose.threed.utilities import Vector3
# For complete examples and data files, please go to https:# github.com/aspose-3d/Aspose.3D-for-.NET
# Initialize scene object
scene = Scene()
# Initialize Node class object
cubeNode = Node("cube")
# Call Common class create mesh using polygon builder method to set mesh instance
mesh = Common.CreateMeshUsingPolygonBuilder()
# Point node to the Mesh geometry
cubeNode.entity = mesh
# Euler angles
cubeNode.transform.euler_angles = Vector3(0.3, 0.1, -0.5)
# Set translation
cubeNode.transform.translation = Vector3(0, 0, 20)
# Add cube to the scene
scene.root_node.child_nodes.append(cubeNode)
# The path to the documents directory.
output = "out" + "TransformationToNode.fbx"
# Save 3D scene in the supported file formats
scene.save(output, FileFormat.FBX7500ASCII)Egen omvandlingsmatris
Vi kan också använda Matrix direkt:
from aspose.threed import FileFormat, Node, Scene
from aspose.threed.utilities import Matrix4
# For complete examples and data files, please go to https:# github.com/aspose-3d/Aspose.3D-for-.NET
# Initialize scene object
scene = Scene()
# Initialize Node class object
cubeNode = Node("cube")
# Call Common class create mesh using polygon builder method to set mesh instance
mesh = Common.CreateMeshUsingPolygonBuilder()
# Point node to the Mesh geometry
cubeNode.entity = mesh
# Set custom translation matrix
cubeNode.transform.transform_matrix = 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.root_node.child_nodes.append(cubeNode)
# The path to the documents directory.
output = "out" + "TransformationToNode.fbx"
# Save 3D scene in the supported file formats
scene.save(output, FileFormat.FBX7500ASCII)