Coder Social home page Coder Social logo

Comments (5)

vpenades avatar vpenades commented on May 20, 2024

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.

from sharpgltf.

cesarecaoduro avatar cesarecaoduro commented on May 20, 2024

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.

from sharpgltf.

vpenades avatar vpenades commented on May 20, 2024

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.

from sharpgltf.

cesarecaoduro avatar cesarecaoduro commented on May 20, 2024

Awesome...the code is working well and it is really fast as well.

from sharpgltf.

Maxxxel avatar Maxxxel commented on May 20, 2024

https://gist.github.com/Maxxxel/2908309eee583131d88d152ba8416d0f

How i solved it.

from sharpgltf.

Related Issues (20)

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.