Generare dati normali per tutte le maglie in un file 3D
Contents
[
Hide
]
Utilizzando Aspose.3D for .NET, gli sviluppatori possono generare dati normali per tutte le mesh in qualsiasi modello 3D (senza i dati normali).
Generare dati normali per tutte le maglie in un file 3DS
Il metodo GenerateNormal
esposto dalla classe PolygonModifier
può essere utilizzato per generare dati normali per tutte le mesh in un file 3DS. Se l’elemento VertexElementSmoothingGroup
è stato definito nella mesh, i dati normali generati verranno smussati da VertexElementSmoothingGroup
.
Campione di programmazione
Questo esempio di codice carica un file 3DS, visita tutti i nodi e crea dati normali per tutte le mesh.
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 | |
// Load a 3ds file, 3ds file doesn't have normal data, but it has smoothing group | |
Scene s = new Scene(RunExamples.GetDataFilePath("camera.3ds")); | |
// Visit all nodes and create normal data for all meshes | |
s.RootNode.Accept(delegate(Node n) | |
{ | |
Mesh mesh = n.GetEntity<Mesh>(); | |
if (mesh != null) | |
{ | |
VertexElementNormal normals = PolygonModifier.GenerateNormal(mesh); | |
mesh.VertexElements.Add(normals); | |
} | |
return true; | |
}); |