Archived

This topic is now archived and is closed to further replies.

F_r_e_s_h

Ok so i'm dumb, i can't help it please help me

Recommended Posts

Ok so ive started getting into dirextX8 for VB, ive read a tone of tutorials and stuff and i get it all except one thing. When you rotate the world matrix everything in the world rotates right, ok i understand that but how do i rotate on object by itslef. I know it''s called model space and stuf but how do i actually tell VB that i just want to rotate that particular object? In all the tutorials ive seen they just rotate the world matrix they don''t show you how to rotate single objects. Ive looked at the dlphin example that comes with the SDK but i just cant get my head around how they do it because they break every little thing into functions and it just goea from one spot to another and i can''t seem to follow it. Sorry for asking such a stupid question but well like it sayd in the title i''m dumb and i can''t help it.

Share this post


Link to post
Share on other sites
Well, one way is to have the object you refer to in a separate vertexbuffer and when you render that object your first make a rotationmatrix then multiply that matrix by a translationmatrix which moves the object to it''s position in worldspace.
It''s important that your multiply in the correct order, rotation * translation, that is.
Then you set this matrix as the worldmatrix and render your object.

If you didn''t understand, just ask again and I will try to clarify.

Good luck

Share this post


Link to post
Share on other sites
yeah ok so i already have my objects in a vertex buffer and everything and i realise that i need to make a translation and rotation matrix. But the problem is that i try to do a rotation or something and it does it to the whole world matrix not just the particular object that i want to rotate how do i specify or whatever u need to do so it knows i only want to move that specific item.

oh and really thanks for your help in advance.

Edited by - F_r_e_s_h on June 25, 2001 7:46:35 AM

Share this post


Link to post
Share on other sites
In OpenGL you just (after making sure the model view matrix is selected, I''m not sure if they call it that in DirectX) push the current matrix, rotate, draw the object, the pop the matrix so that it doesn''t affect the following objects. I''m sure DirectX has something similar to this, I just don''t know if off hand.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Well if you have all your object in one vertexbuffer then you should probably create an indexbuffer containing just the indicies for the object you wan''t to draw.
Then you create the matrix, sets that as worldmatrix, and draw the world.

Some pseudo code for the renderloop:

-Render loop---------
Set IdentityMatrix as WorldMatrix
RenderWorld

For every object
    Set ObjectMatrix (Rotation*Translation)
    Set ObjectIndexBuffer
    RenderObject
Loop
---------------------

So for each object you should av a structure like this:

class Object {
   float fYaw, fPicth, fRoll;
   float fX, fY, fZ;
   (An indexbuffer containing the indicies for the object);
//Or if your objects verticies is in order in the VB
   (Starting index and number of verticies in the VB);
};

This of course requires that your objects are in objectspace in your vertexbuffer, that means that a shere should have it''s vertices located around 0,0,0.
That is the point the rotation of your objectmatrix will rotate around, then translates it to it''s position.

Hope that helped some.

Share this post


Link to post
Share on other sites