Jump to content
  • Advertisement
Sign in to follow this  
mokaschitta

Various Model Export/Import questions with blender

This topic is 3267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am about to start my first simple model exporter in blender but I have various questions since I have never done this before and I would like to make things correctly from the beginning so I can extend my exporter/format easily in the future without having to rewrite everything. So basically for now I want to start to only export static models with TBN Matrix for things like bump mapping. I want to make the format openGL friendly and also export it as indexed data. questions: 1. if I want to export indexed arrays from blender, I though I would simply write each position/normal/texcoord to an array, and only add it if its not allready in there. So basically only if normal/texcoord and position are identical with one exiting in the array, i will refer to it with its index, otherwise I need to add it as a new vertex with another index. Would that work? 2. what if I want to have for example a tree where I can animate its branches with a simple wind vertex shader but the stomp should not move. Would I create the stomp and the branches as different objects and also respect it in my format? What is the common way of doing this? 3. Generally how can I link specific parts of my model with certain shaders? I would be really thankful if someone could clearify these things for me and point me into the right direction! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
1. if I want to export indexed arrays from blender, I though I would simply write each position/normal/texcoord to an array, and only add it if its not allready in there. So basically only if normal/texcoord and position are identical with one exiting in the array, i will refer to it with its index, otherwise I need to add it as a new vertex with another index. Would that work?
That would work, but it is actually simpler than that. Every Blender mesh has a 'verts' attribute which is a list of all its vertexes 'alredy indexed', i.e., their position in the list is their index. Meshes also have a 'faces' attribute, a list of all the model faces, which has a 'verts' attribute, from which you can get the index to the vertexes that form that face. UV coordinates are a bit different though, your solution might be the best option in your case. Anyway, you might want to read this and this to see what better fits your texture needs.

Share this post


Link to post
Share on other sites
Don't know how experienced you are with OGL, so you can ignore me if you already know this; but make sure that you understand that when you start using your models with VBO the texture, normal and vertex indices (for indexed array access) must always share the same index.

If you model a piece of paper with 100 vertices, you cannot just store the 100 vertices in an array, and store one normal because the normals are the same across the square.

If you want to draw vertex #57, you have to make sure that the normal vector is #57 in the normals array, and the texture coordinate is #57 in the texcoords array.

I didn't know this when I made my model converter and I had to redo a chunk of it.

Good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!