vpenades / SharpGLTF

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

Demo application? #133

Closed bjorn-ali-goransson closed 2 years ago

bjorn-ali-goransson commented 2 years ago

Hello there,

I'm curious how you visualize the results of the SharpGLTF logic yourself, do you happen to have a OpenGL example application that shows the loaded GLTF?

Maybe this is wishing too much.

Context, I'm currently trying to make OpenRA into a Lego Game (TellTale) engine, and it's time to load assets and I discovered GLTF. It's right over here: https://github.com/bjorn-ali-goransson/TellMeAStoryEngine

vpenades commented 2 years ago

Not sure if I understand your question.

If you want a program that displays glTF files, windows itself comes with an in built 3D model viewer that is able to open and display glTF models.

If what you want is a demo on how to render a glTF to screen, I've done some basic stuff using MonoGame engine, but it's far from a good example due to the limitations of MonoGame, which makes the code extremely ugly.

In the end, SharpGLTF is just a loader/authoring library, and rendering is out of scope because it would require writing code for every single rendering API.

But, regardless of the rendering API, there's some boilerplate code that should be common to all rendering APIs, like evaluating the nodes, calculating matrices, etc.... you can find that code in the runtime namespace. It's not documented though, so you'll have to navigate around it yourself.

bjorn-ali-goransson commented 2 years ago

Understood, thank you! Yes I began to traverse the nodes / indices 👍🏼 .

I just saw that the glTF format includes strides and a "buffer" so I thought maybe there is some easy way to transfer this onto a buffer object, but no worries.

vpenades commented 2 years ago

buffer strides is just one detail among one hundredth. It took me a month of work to write the renderer for MonoGame, so it's not a simple task.

glTF rendering can be divided in two main sections:

The gpu resources need to be converted from glTF to your engine of choice using your own code, and there's little the library can do about it.

For the scene description stuff, there's the Runtime namespace that has several utilities that simplify the work: I would begin looking at SceneTemplate and SceneInstance classes.

bjorn-ali-goransson commented 2 years ago

Much appreciated sir. Thanks!