Rendering ideas.
Hi,
How would I go about rendering all objects in my game?
I have a object that renders but how do I pass all the information on what needs to be rendered into it?
do I let a object decide if it should be rendered?
do I have a object manager that loops though the objects and and renders them?
how would the object manager know what was to be render or even if a object exsited?
I know this is a bit of a mess of questions but I think I need to get this straight.
I am planning at the moment and this has me stumped.
Cheers
I use something like this this:
Then you could make an array of CObjects and when you want to render them you could use
a loop like this:
CMesh{ HRESULT gRender(); ... //More methodsprivate: // ... Renderstates etc... VERTEXBUFFER pVB;}CObject{ HRESULT gRender(){ ... // Apply world matrix, etc. return pMesh->gRender; } ... // Methodsprivate: float pPosX, pPosY, pPosZ; // Object's position float pAngX, pAngY, pAngZ; // Object's angle CMesh *pMesh;}
Then you could make an array of CObjects and when you want to render them you could use
a loop like this:
DWORD i;for( i=0; i<objects_Num; i++ ){ if( pObjects </i> )<br> pObjects<i> </i> ->gRender();<br>}<br> </pre> <br><br>Hope that helps <img src="smile.gif" width=15 height=15 align=middle> <br><br><hr><i>KaM1KaZ3 </i> <br><br><SPAN CLASS=editedby>[edited by - Kamikaze15 on February 27, 2003 2:21:41 PM]</SPAN>
In the project i'm currently working on I inherit everything in the game from a base class called CEntity. Then in the main game loop I do something like this
As far as knowing if it should be rendered or not, you could have a bool called Alive or something like that.. if it's alive then draw it.. so maybe something like
I hope this helps..
[edited by - randal on February 27, 2003 2:20:49 PM]
for (i = 0; i < numentities; i++) { entity[i]->Tick(Delta);}if (Graphics->BeginScene()){ for (i = 0; i < numentities; i++) { entity[i]->Render(); } Graphics->EndScene();}
As far as knowing if it should be rendered or not, you could have a bool called Alive or something like that.. if it's alive then draw it.. so maybe something like
for (i = 0; i < numentities; i++) { if (entity[i]->Alive) entity[i]->Render();}
I hope this helps..
[edited by - randal on February 27, 2003 2:20:49 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement