Comments (4)
You are right, the problem is that the mesh is inside another node, so 2 levels Node.Node.Geometry
with recursion is easy to pick all geometries, try this:
public static IEnumerable<Geometry> GetAllGeometryInTheScene(string path)
{
Scene scene = FbxReader.Read(path, ErrorLevel.Checked);
List<Geometry> geometries = new List<Geometry>();
//Iterate throgh all the nodes in the scene
foreach (Node item in scene.Nodes)
{
//Here you can apply filter if you know the name of the node
geometries.AddRange(GetAllGeometryInTheNode(item));
}
return geometries;
}
public static List<Geometry> GetAllGeometryInTheNode(Node node)
{
List<Geometry> list = new List<Geometry>();
//Each node can contain geometric elements so you have to look in the elements contained in the main node
foreach (Element c in node.Children)
{
//Check if the element is a geometric type
if (c is Geometry geometry)
{
list.Add(geometry);
continue;
}
else if (c is Node n)
{
list.AddRange(GetAllGeometryInTheNode(n));
}
}
return list;
}
I've tried with your document and it worked find.
from meshio.
Hi @pmorshed,
to extract the vertices you just need to access to the Scene.Nodes
and look for the Element
that you are looking for, here is an example:
Scene scene = FbxReader.Read(test, ErrorLevel.Checked);
//Iterate throgh all the nodes in the scene
foreach (Node item in scene.Nodes)
{
//Here you can apply filter if you know the name of the node
//Each node can contain geometric elements so you have to look in the elements contained in the main node
foreach (Element c in item.Children)
{
//Check if the element is a geometric type
if (!(c is Geometry geometry))
continue;
//Get the vertices of the element
List<CSMath.XYZ> vertices = geometry.Vertices;
}
}
from meshio.
Hi @pmorshed,
to extract the vertices you just need to access to the
Scene.Nodes
and look for theElement
that you are looking for, here is an example:Scene scene = FbxReader.Read(test, ErrorLevel.Checked); //Iterate throgh all the nodes in the scene foreach (Node item in scene.Nodes) { //Here you can apply filter if you know the name of the node //Each node can contain geometric elements so you have to look in the elements contained in the main node foreach (Element c in item.Children) { //Check if the element is a geometric type if (!(c is Geometry geometry)) continue; //Get the vertices of the element List<CSMath.XYZ> vertices = geometry.Vertices; } }
Hi. Thanks for the quick reply. I tried it but it didn't give any output. Have you tried it yourself?
from meshio.
Yes, works like a charm. Thanks so much
from meshio.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meshio.