GithubHelp home page GithubHelp logo

Comments (4)

DomCR avatar DomCR commented on August 27, 2024 1

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.

DomCR avatar DomCR commented on August 27, 2024

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.

pmorshed avatar pmorshed commented on August 27, 2024

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;
      }
}

Hi. Thanks for the quick reply. I tried it but it didn't give any output. Have you tried it yourself?

from meshio.

pmorshed avatar pmorshed commented on August 27, 2024

Yes, works like a charm. Thanks so much

from meshio.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.