Skip to main content
gamedev.net
🔒 Locked

Model class design issue

Started by zerorepent Mar 19, 2011 at 4:45 PM 0 replies 750+ views
Original Post
zerorepent
zerorepent
Hi!
This problem has been giving me headache for quite som time, I've had several ideas which I've been coding for a few hours but suddenly realising this isn't gonna work and throwing it away, so I thought I should ask and see how other people have solved it. A model or mesh can consist of several submeshes/geometricdata (i.e. a vertexbuffer, indexbuffer and a material each). In Order to sort the rendering per Material each submesh need to be wrapped in a class which contains worldmatrix, the geometricdata and if animated skeleton data or other renderingrelated data and. Is this how its usually done, or do submeshes usually share the same materials and/or other renderparameters making it irrelevant (in the general case) to sort the submeshes into the renderqueue?
Hodgman
Hodgman
Sub-meshes often have different materials. Often the reason that there's multiple sub-meshes (instead of them all being merged into a single sub-mesh) is precisely because they do have different materials.

You could organise it like:
Instance data: world matrix, bone/anim data, etc
Material data: texture/shader bindings, etc
Drawable: Has links to a sub-mesh, an instance data and a material data.
Model: collection of drawables.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.