Mesh
Không gian tên: Aspose.ThreeD.Entities (Aspose.3D 26.1.0)
Mesh lưu trữ hình học đa giác dưới dạng danh sách các điểm điều khiển (vị trí đỉnh) và danh sách các mặt đa giác. Mỗi mặt đa giác là một danh sách các chỉ mục bắt đầu từ 0 vào mảng các điểm điều khiển. Dữ liệu bổ sung cho mỗi đỉnh – các vector pháp tuyến, tọa độ UV, màu sắc đỉnh – được gắn kèm như VertexElement lớp.
public class Mesh : GeometryPhương pháp
A3DObject → SceneObject → Entity → Geometry → Mesh
Phương pháp
Xây dựng một lưới tam giác đơn từ đầu:
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
// Create the mesh and add three vertex positions
var mesh = new Mesh();
mesh.ControlPoints.Add(new Vector4(0.0, 0.0, 0.0, 1.0)); // vertex 0
mesh.ControlPoints.Add(new Vector4(1.0, 0.0, 0.0, 1.0)); // vertex 1
mesh.ControlPoints.Add(new Vector4(0.5, 1.0, 0.0, 1.0)); // vertex 2
// Define one triangle face using vertex indices
mesh.CreatePolygon(0, 1, 2);
// Attach to a scene and save
var scene = new Scene();
scene.RootNode.CreateChildNode("triangle", mesh);
scene.Save("triangle.stl");Xây dựng từ một primitive và kiểm tra:
var sphere = new Sphere(1);
var mesh = sphere.ToMesh();
Console.WriteLine("Vertices: " + mesh.ControlPoints.Count);
Console.WriteLine("Polygons: " + mesh.PolygonCount);Phương pháp
| Name | Type | Access | Description |
|---|---|---|---|
Edges | IArrayList<int> | Read | Gets the edges. |
PolygonCount | int | Read | Gets the polygon count. |
Polygons | IList<int[]> | Read | Gets the polygons. |
Visible | bool | Read/Write | Gets or sets the visible. |
Deformers | IList<Deformer> | Read | Gets the deformers. |
ControlPoints | IArrayList<Vector4> | Read | Gets the control points. |
CastShadows | bool | Read/Write | Gets or sets the cast shadows. |
ReceiveShadows | bool | Read/Write | Gets or sets the receive shadows. |
VertexElements | IList<VertexElement> | Read | Gets the vertex elements. |
Excluded | bool | Read/Write | Gets or sets the excluded. |
ParentNodes | List<Node> | Read | Gets the parent nodes. |
ParentNode | Node | Read/Write | Gets or sets the parent node. |
Scene | Scene | Read | Gets the scene. |
Name | string | Read/Write | Gets or sets the name. |
Properties | PropertyCollection | Read | Gets the properties. |
Phương pháp
| Signature | Description |
|---|---|
Mesh() | Creates a Mesh with the specified name |
Mesh(name: string) | |
GetPolygonSize(index: int) | Gets the vertex count of the specified polygon. |
GetEnumerator() | Gets the enumerator for each inner polygons. |
CreatePolygon(indices: int[]) | Create a polygon with specified indices |
CreatePolygon(v1: int, v2: int, v3: int, v4: int) | Create a polygon with specified indices |
CreatePolygon(v1: int, v2: int, v3: int) | Create a polygon with specified indices |
ToMesh() | Gets the Mesh instance from current entity. |
IsManifold() | Check if current mesh is a manifold mesh. This function will not cache the manifold calculation result. |
Optimize(vertexElements: bool) | Optimize the mesh’s memory usage by eliminating duplicated control points |
Optimize(vertexElements: bool, toleranceControlPoint: float, toleranceNormal: float, toleranceUV: float) | Optimize the mesh’s memory usage by eliminating duplicated control points |
Triangulate() | Return triangulated mesh |
Geometry(name: string) | |
GetDeformers() | Gets all deformers |
GetElement(type: VertexElementType) | Gets a vertex element with specified type |
GetVertexElementOfUV(textureMapping: TextureMapping) | Gets a VertexElementUV instance with given texture mapping type |
CreateElement(type: VertexElementType) | Creates a vertex element with specified type and add it to geometry. |
AddElement(element: VertexElement) | Adds an existing vertex element to current geometry |
CreateElementUV(uvMapping: TextureMapping) | Creates a VertexElementUV with given texture mapping type. |
Entity(name: string) | |
GetBoundingBox() | Gets the bounding box of current entity in its object space coordinate system. |
GetEntityRendererKey() | Gets the key of the entity renderer registered in the renderer |
SceneObject(name: string) | |
A3DObject() | |
RemoveProperty(property: Property) | Removes a dynamic property. |
GetProperty(property: string) | Get the value of specified property |
SetProperty(property: string, value: object?) | Sets the value of specified property |
FindProperty(propertyName: string) | Finds the property. It can be a dynamic property (Created by CreateDynamicProperty/SetProperty) or native property(Identified by its name) |