PDA

View Full Version : Keep all Objects in Engine in one Array



uwi2k2
06-07-2014, 03:50 AM
hi there,


i just play around with thoughts about render engine structure.
i know there are many out there but i wanne just learn by practice.


i have a complete setup of renderengine, shader manager, texture manager... and so on
and all worx fine with my basic object calss obj_3d.
so i can pass any obj3d instance to the renderer->draw() func and it handels all : shader select, postprozess....


in my game class there is a vector of my obj_3d objects. based on some sorting i just loop through it and draw them.


worx all fine so far !


now, of course there are diffrent objects in my world, that have additional diffrent information / behaviors.


eg. in my space game planets have diffrent resources you can drain from them, while space shipds have diffrent flight behavior.
these propertys dont belong in the obj_3d class .
instead i should inherit the planet class from obj_3d.
like: class planet : obj_3d


but if i set it up like this, i cant have only one vector holding all my objects in the game class as they will all be of diffrent types. planet, ship, astroid, spacestation, ...


so how so i solv this ?
i just wanne have 1 vector/array of objects to loop through and pass to render func ?


is there a way ?


thanx
uwi