Shared data between game entity components

Started by
9 comments, last by MENTAL 19 years, 3 months ago
With regards to render states and whatnot, ideally each entity should keep track of it's model, texture, position, angle, current frame/animation, etc. However, resources like models and textures arn't loaded by the entity itself - a model manager and a texture manager load the files and pass a handle back to the entity. That way, multiple entities can use the same model/texture.

So, each entity should have it's own RenderObject, but they should all reference common data. That way you can change an entity's model or texture without causing all other entities of the same type to change as well.

As for sorting, I'm currently sorting by texture, and then sorting by distance (closest to farthest). That way I ensure that each texture is only loaded once but I still keep overdraw down.

I also render the map first and the models second as the map has far less polygons than the models, resulting in faster rendering times.

As a side note, if you're going to render transparent objects then you need to render them after everything else has been drawn, and they MUST be sorted back-to-front (so the far ones are drawn first), otherwise they won't blend properly if a transparent object is in front of another transparent object.

I've ranted enough.

If any of it is of any use then don't forget to rate me (yes I know I shouldn't ask but I'm trying to get off 1019!).

This topic is closed to new replies.

Advertisement