Closed cesarecaoduro closed 4 years ago
Hi, you have two ways of doing it... if you notice in yout code there's this line:
scene.AddRigidMesh(mesh, Matrix4x4.Identity);
When you add a mesh to the scene, you can specify a transform matrix that will set the origin of the mesh within the scene, so you can do things like this:
scene.AddRigidMesh(mesh, Matrix4x4.CreateTranslation(100,43,50) );
You can see an example here
Additionally, if you want to store a hierarchy graph you can also create an armature like this:
var armature1 = new NodeBuilder("Skeleton1");
var child0 = armature1
.CreateNode("Joint 0")
.WithLocalTranslation(new Vector3(0, 1, 0));
var child1 = armature1
.CreateNode("Joint 1")
.WithLocalTranslation(new Vector3(10,5, 0));
var scene = new SceneBuilder();
scene.AddRigidMesh(cube, child0 );
scene.AddRigidMesh(sphere, child1 );
Notice that both the Matrix4x4 and NodeBuilder objects support setting translation, rotation and scaling.
Additional notes about your code:
In the Material builder you're using .WithDoubleSide(true)
, this only tells that the triangles should be rendered from both sides, and it is not really neccesary if you're creating solid meshes.
Thanks I have managed to export it in the right location using the CreateWorld method.
I need to test the graph structure but I understand now how to use it. Is it possible to nest the tree?
Something like: var child11 = child1.CreateNode('Joint 1-1')
I will also remove the .withDoubleSide(true)
thanks for the suggestions.
yes, in order to build a tree, you use the NodeBuilder class.
You create the root node with new NodeBuilder("root name");
and then, you can use the .CreateNode("child name")
recursively to create the nodes of the tree.
Once you hace created the tree, you can pass any node to the AddRigidMesh(mesh, node);
instead of a matrix.
Awesome...the code is working well and it is really fast as well.
https://gist.github.com/Maxxxel/2908309eee583131d88d152ba8416d0f
How i solved it.
I am trying to write a very simple exporter for Revit and this is the code. I can't attach a screenshot but basically the objects are exported properly in terms of shape but they are all in wrong locations. I would like to export each object as a separate object and the coordinate system should be the World Coordinate System with Origin in 0,0,0 and with Z Axis point to the top.
Any help will be much appreciated.