vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
457 stars 72 forks source link

Add Children Property and Some Basic Questions #125

Closed kitkat730 closed 1 year ago

kitkat730 commented 2 years ago

Hello Thanks for this library.

In the past I have created GLTF file using this link in C++. Now want to create GLTF from scratch using C#. To create GLTF in C#, I followed this link. Do you have any Documentation Or any Link where I can find what is the Purpose of all the method and all ?

I have few questions.

I followed link to create GLTF.

  1. I am able to add vertices point using Add Triangle but how can I add Normal and Texture Information into GLTF.
  2. How can I Add Children Property in nodes. For Example :- "nodes": [ { "children": [ 1 ], "name": "Group_Index" }, ]

I am beginner into this. Thank You, Have a good Day : )

kitkat730 commented 2 years ago

@vpenades Please look at here . I need the solution for this. Thank you.

vpenades commented 2 years ago

@kitkat730 I help when I have time, which is very limited, not by command.

  1. use:
    var mesh new MeshBuilder<VertexPositionNormal>();
  2. scene.AddRigidMesh(mesh, Matrix4x4.Identity);

Already creates a node at the matrix location, you can change the matrix to any location. If you want a configurable node, replace Matrix4x4.Identity by a `NodeBuilder object. There's plenty of examples in the tests using NodeBuilder

Please, review the whole SceneBuilder API to see all the options available.

kitkat730 commented 2 years ago

Hey, Thanks for your quick reply.

There's plenty of examples in the tests using`NodeBuilder```

Can you please share link where I can find examples. I tried but not able to find It.

One More Question...How to add indices to mesh.. I Saw it added indices internally but I want to add manually.

Thank you.

vpenades commented 2 years ago

Can you please share link where I can find examples. I tried but not able to find It.

Indices are just references to vertices. If you have 3 indices pointing to 3 vertices, you just grab the 3 vertices and add them to the MeshBuilder, and indices will be automatically rebuilt internally. This way of adding geometry prevents lots of invalid use cases.