Hello,
I want to make a new RS add-in that can import a PLY file format.
I have an external dll that can import this file format, but I don’t know how to represents this ( vertices, faces, normals, material, ecc) with SDK internal geometry.
There are some internal tutorial that show this?
Hi, here is some sample code that creates a Part with a mesh consisting of a single flat Surface:
Part BuildPart() { // Create a face var meshFace = new MeshFace(); meshFace.Material = new Material(System.Drawing.Color.Azure); // Add vertices and normals meshFace.Vertices.Add(new Vector3(0, 0, 0)); meshFace.Vertices.Add(new Vector3(1, 0, 0)); meshFace.Vertices.Add(new Vector3(0, 1, 0)); meshFace.Vertices.Add(new Vector3(1, 1, 0)); meshFace.Normals.Add(new Vector3(0, 0, 1)); meshFace.Normals.Add(new Vector3(0, 0, 1)); meshFace.Normals.Add(new Vector3(0, 0, 1)); meshFace.Normals.Add(new Vector3(0, 0, 1)); // Add triangles meshFace.TriangleIndices.AddRange(new int { 0, 1, 2, 2, 1, 3 }); // Add wireframe meshFace.WireIndices.AddRange(new int { 1, 0, 2, -1, 0, 3, 2, 1 });
// Add the face to a body var meshBody = new MeshBody(); meshBody.Faces.Add(meshFace); // Add the body to a part var meshPart = new MeshPart(); meshPart.Bodies.Add(meshBody);
// Assign the part Part part = new Part(false); part.Mesh[DetailLevels.Medium] = meshPart;
// Call Rebuild() to commit the data to the graphics system part.Mesh.Rebuild(); return part; }
Thank you very match.
Just another questions..
Where I can enable or disable material culling?
If you mean backface culling, it is enabled by default and you can disable it by setting a flag on each MeshFace:
meshFace.Flags = MeshFlags.DisableBackFaceCull