Skip to main content
GameDev.net gamedev.net
🔒 Locked

Matrices and Objects

Started by Laroche Jul 31, 2002 at 11:02 AM 2 replies 300+ views
Original Post
Laroche
Laroche
I don''t understand how you are supposed to move a bunch of different objects around in different directions and such using only matrices. I currently have 1 textured-quad which moves around using the arrow keys. The arrow keys affect the world matrix. It works fine. Now, let''s say I wanted TWO objects, each controlled in a different way, that move independently. How would I do this? Would I have to lock and unlock the vertices every frame? Also, how would each object be rendered seperately? If I try and have a vb hold 8 vertices, and then call DrawPrimitive(...), How would it render each quad with it''s OWN strip? I''m not quite sure how else to word the question, so there it is. Any help would be very appreciated. I''ve done 2D before, but this change is a little bit more difficult then I thought it would be..
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Eli Gottlieb
Eli Gottlieb
You need to create a second world matrix and start your DrawPrimitive call from vertex 5.


Application::Render()
{
iD3DDevice->BeginScene();
//Set rendering properties.
iD3DDevice->SetStreamSource(0,&iQuadVertices,sizeof(QUADVERTEX));
iD3DDevice->SetVertexShader(QuadFVF);
//Set 1st World Matrix and render the 1st Quad.
iD3DDevice->SetTransform(&Quad1Matrix);
iD3DDevice->SetTexture(&Quad1Texture);
iD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,0,2);
//Set 2nd World Matrix and render the 2nd Quad.
iD3DDevice->SetTransform(&Quad2Matrix);
iD3DDevice->SetTexture(&Quad1Texture);
iD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,5,2);
//End and present the scene.
iD3DDevice->EndScene();
iD3DDevice->Present(NULL,NULL,NULL,NULL);
};


void Signature(void* Pointer)
{
PObject(Pointer)->ShowMessage("Why do we need so many pointers?");
};

Two guys walk into a bar. One''s an Isreali ambassador, one''s a Palestinian ambassador. They both get drunk. Then they start peace talks.
void Signature(void* Pointer){PObject(Pointer)->ShowMessage("Why do we need so many pointers?");};
Pipo DeClown
Pipo DeClown
I dont either, but using VerteXBuffeRs && SetStreamSource() it makes a little bit sense? Although Im not sure what Im talking about :S Anyway, just accept it!
Laroche
Laroche
Correct me if I''m wrong, but shouldn''t DrawPrimitive be called using the most vertices possible? Doing 4 at a time is rathr inefficent, no?
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content

Topic Locked

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

Sign in to reply to this topic.