Jump to content

  • Log In with Google      Sign In   
  • Create Account


Any tips on structuring 3d models for great code?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Tengato   Members   -  Reputation: 167

Like
1Likes
Like

Posted 29 January 2013 - 04:44 PM

What is the best general structuring approach to building a robust 3d model for use in video games? (i.e. a character/vehicle controlled by the player/AI) Some of my questions in specific are:

  1. When should I use multiple models?  This seems useful for things like weapons, but what about vehicle wheels or destructible pieces - how far should you take this concept?
  2. When should I use separate meshes within a single model?
  3. Is there a 1:1 realtionship between meshes and materials that should be honored? It seems like meshes get sent to the shaders as a unit, although you could possibly break them down into primitives and send those pieces to different shaders...
  4. Is it acceptable to animate a rigid model (like a mech) using a single mesh with disconnected pieces, assigning all the vertices in each piece a 100% weight to a corresponding bone?
  5. Should you ever create animation channels for meshes (rather than a bone)?
  6. Are there standards for how many texture files should be used with a single mesh or a model?

This topic may seem more to do with modeling than coding, but the reason I'm asking is because these details inform much of the design of the model handling code, which I would like to be powerful and flexible but elegant and clean as well.

Thanks for any advice!



Sponsor:

#2 papulko   Members   -  Reputation: 857

Like
2Likes
Like

Posted 29 January 2013 - 05:39 PM

1 & 2. This is very application-specific, and it's generally a trade-off between performance and realism/complexity. A general rule of thumb would probably be to not use multiple models/meshes for any given game entity unless it's required by the game. For example, don't make a separate model for the wheels unless they can actually come off vehicle, or change appearance in some way.

 

3. Personally i prefer using texture maps for material properties, otherwise i would probably stick with one material per mesh.

 

4. Assigning all vertices a 100% weight to their corresponding bone makes the animation look less realistic on organic objects (you lose the skin-twisting effect). If that's acceptable or not is entirely up to you :)

 

5. I might be wrong but I can't see any reason to animate actual vertices when there's a working rig animation system in place.

 

6. This is also application specific, no standards. In many cases it's more efficient to load textures separately from models and just have the models reference whatever textures it's using. This way one texture can be reused by many models, but that's a different story.



#3 Krohm   Crossbones+   -  Reputation: 3049

Like
2Likes
Like

Posted 30 January 2013 - 05:20 AM

When should I use multiple models?  This seems useful for things like weapons, but what about vehicle wheels or destructible pieces - how far should you take this concept?

I would take this as far as required to reach my target.

Do your game require this feature. If not, let it out. Wrapping your head around things you might need in the future in some circumstances for some use-case is not going to take you anywhere.

Your example is ill.

Weapons come in their own model and get attached to the mesh.

Same applies to destructible pieces (although the models are likely bundled in the same resource file).

So I'd personally provide named attach points / joints / whatever you call them and allow the model to be assembled by multiple meshes.

 

When should I use separate meshes within a single model? Is there a 1:1 realtionship between meshes and materials that should be honored? It seems like meshes get sent to the shaders as a unit, although you could possibly break them down into primitives and send those pieces to different shaders...

Define what a mesh is. Everything that goes through draw calls is a mesh. Every draw call is a mesh. What is a model? For years, "models" had a single material and often got rendered in a single drawcall. Then, models started to have more drawcalls, each with a different material.

Basically, nobody in general breaks the drawcall to primitive level to issue them to "different shaders". Drawcalls are the basic unit of operation for generic usage.

 

Is it acceptable to animate a rigid model (like a mech) using a single mesh with disconnected pieces, assigning all the vertices in each piece a 100% weight to a corresponding bone?

Might work in some situations, I wouldn't be very proud of it and wouldn't consider it good practice (it's against the whole idea) but if it saves the day, I'm all for it!

 

Should you ever create animation channels for meshes (rather than a bone)?

They are sometimes still used.

 

Are there standards for how many texture files should be used with a single mesh or a model?

Some engines (especially hobby engines you read about in those forums) have a limit. In general you must support a "practically unlimited" amount of resources to be loaded. For my mesh format I have an hard limit at about 2^10 resources if memory serves.



#4 3Ddreamer   Crossbones+   -  Reputation: 3133

Like
2Likes
Like

Posted 30 January 2013 - 09:09 PM

Hi, The general rule, purely from a technical and not an artistic viewpoint, is that each of those categories in the original post should be as lean as possible to accomplish the artistic concept. I have done a whole car with one material and one texture and a ship with several each. You use the least amount to accomplish the most visual impact PERIOD Duplicate identical parts exactly the same in view, UVmap, and texture as possible - sometimes going out your way to do so. For example, you would not want to make each section of hand railing from scratch. You would make a section of hand railing complete with texture, any material, and any shader, then duplicate that section many times to cover a bridge, ship, pier, boardwalk, balcony, and so forth where the handrail will span. Another example are legs of a monster. Say your monster has twelve legs. Most or all of the legs would come from one source leg which was duplicated. Another example are faces of any object - say a boat: Instead of making each section of deck or hull from scratch each time you would make one and duplicate it, placing each duplicate into the right position. An alternative is to select already existing faces and apply the same texture/material/shader to each. Later you can always go back and take a few of them to have another layer applied for variety. It is very advantageous for any game developer to get 3D model experience so they understand optimization of a model.

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software.  The better the workflow pipeline, then the greater the potential output for a quality game.  Completing projects is the last but finest order.

 

by Clinton, 3Ddreamer





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS