Jump to content
  • Advertisement
Sign in to follow this  
TransformedBG

Drawing subset of an array of pointers

This topic is 2517 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Short version lets say i want to make 10 objects:
Atom, Bullet, Tree, etc, etc. using ID3DXMesh's.

My idea was it would be something like:



//setup objects in world
ID3DXMesh** Objects[10] = {0,0,0,0,0,0,0,0,0};
ID3DXMesh *Atom[4] = {0,0,0,0};



//set up 4 meshes for atom
void renderAtom()
{
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[0], 0);
D3DXCreateSphere(Device, 0.5f, 20, 20, &Atom[1], 0);
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[2], 0);
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[3], 0);
}



//set atom to the first pointer
Objects[0] = Atom;


do the rest of the objects


//render the world
void render(float timeDelta)
{
// Render
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();
for(int i = 0; i < 10; i++)
{
Device->SetMaterial(&Mtrls);
Device->SetTransform(D3DTS_WORLD, &Worlds);
Objects->DrawSubset(0);
}

Device->EndScene();
}



problem is DrawSubset needs to point to a class/struct/union or generic type. Would there be an easy way to do this?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!