#### Archived

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

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

## Recommended Posts

Right my understanding of matrices is you do this: -> Cocanate || translate Local ( object is orgin ) -> World ( all objects collect ) -> Camera ( Orgin is where camera is ) -> Projection ( 2D ) Now I just read in SDK that local matrix is not used in DX, but its data is set in the vertcies of the object so if you want you can use local matrix to change verticies right. My next understanding is that you have translate the object into a world matrix using translation. Now how would you move the object into the world matrix when its just a bunch of verticies. Cause if you have more than 1 object in your space and you have to translate them into diffrent positions how do you translate each object into a diffrent position in the world matrix please please help me, I really need to understand this thanx thanx in advance Iain PS I know how the matrices rotate,translate,scale cause i got my own matrix class which works, I just don''t get how you translate diffrent objects into diffrent places in the world matrix.

##### Share on other sites
I would recommend that you take a look at a good tutorial, or math book, on matrices and how they are used in 3D graphics. I don''t think you have yet fully grasped the concept of matrices and how they relate to 3D object transformations. I won''t try and explain it all here as there are loads of good tutorials out there already (try a search through these very forums, too).

Typically you will have your object with it''s geometry specified in local space (relative to the object''s local origin). You then need to apply a transformation to the object to take it into world space. This is where the world matrix is used. The world matrix can contain a translation, a rotation, and a scale and will place your object into position within world space. Each object that you have defined is likely to have it''s own world matrix that uniquely takes the object and places it into the world at the correct place, orientation and size.

To view the objects you have just transformed into world space you need to define your view matrix. This transformation places you into the world and is how your viewpoint realises the world - this is view space (or camera space). There are utility functions that can create this matrix for you.

Finally, you need to create the projection matrix. Again, there are functions that can create this matrix for you. This transformation will take your 3D world, viewed from your specified viewpoint, and transform it to 2D screen space.

And that is it in a nutshell.
Good luck!

Sharky

##### Share on other sites
"Each object that you have defined is likely to have it''s own world matrix that uniquely takes the object and places it into the world at the correct place, orientation and size"

thats it thank-you so much , thats the bit I didn''t understand every object has its own world matrix, I thought they all shared it , I really really apprciate you telling me that.

I do know about Matrix transformatios and how they realate with vectors I just didn''t get how matrix associated with the model but now I understand by that simple explanations. Thanx alot man.

So Im guessing its gd to try have massive vertex buffer instead of having loads of little ones so matrix math & draw primitive are called less, ya

##### Share on other sites
I just started with this stuff. I am surprised I have the same confusion as you did. After reading tutorial 5 of Andy Pike. He did a good job in reducing my confusion.

What I understood is that when you apply the transformation, that implementation of the world matrix transformation is specific to the object.

It is like saying:
1-I want a version of the world matrix to apply to object1. This version could be rotation for example, then render(important).
2-Same, for next object I want a version of the world matrix to apply to object2. This version could be scaling, then render again,
and so forth for the other objects.

You could argue that this is not a world matrix transformation, it is indeed local to the object, and I will not be able to disagree.

If love is illusion and hate is real, I would rather be crazy

##### Share on other sites
If it helps, I imagine this as a black box that throws transformed vertex to the screen.

You have a group of vertexes defining and object. So you tell your video card:

- use this texture
- use this lights
- other stuff
- now: move this vertexes to here (word transformation)
this is like ''use this place''
- view from here
- use this focus of vision

The last two will be the same for each frame or we would get strange results, so for each object that you draw, you set textures, lights, etc.. and position.

And then you draw the primitive. Your video card/directx texturizes and iluminates, moves and projects that triangles and fills the zbuffer with appropiate values. Now you can continue drawing of other objects no matter what textures, lights or matrices you set because the triangles before have already been drawed.

It seems that you could have a vertex list with ''world-transformated'' coordinates... yes, but usually if you have a tree and put it in many places, you would prefer drawing it several times with different world matrixes.

By the way, I ask: are lights affected by matrixes? If I put two trees in different places... would the lights iluminate them equaly or the lights are well-set with world-coordinates-system?

##### Share on other sites
quote:
Original post by jjmontes
By the way, I ask: are lights affected by matrixes? If I put two trees in different places... would the lights iluminate them equaly or the lights are well-set with world-coordinates-system?

You can change the positions of lights (and directions of certain types of light) using matrices as this is, like moving a model vertex, a simple transformation.

If you place two trees into your world at different positions and apply lighting to the scene you will see that they are illuminated differently. Direct3D uses per vertex lighting (don''t be confused by per-pixel lighting/shaders) and, because each tree''s vertex set has a different position, your trees will exhibit different levels of illumination - provided the normals and correct render states have been set beforehand!

Sharky

##### Share on other sites
Ok thanx alot , your advice helped me alot I can actully get stuff moving around in my program thank-you so much !

do all this stuff has led me onto anatha question, I was moving onto my view matrix and I made a function to translate & roate the matrix using angle & translation point like so:

Pseudo code ax=angle x, tx=translations x
D3DMATRIX SetViewMatrix(ax,ay,az,tx,ty,tz)
{
D3DMATRIX mat;
SetIdentitMatrix(&mat);
mat=Multiply(mat,TranslateMatrix(mat,tx,ty,tz));
mat=Multiply(mat,RotateX(ax));
mat=Multiply(mat,RotateY(ay));
mat=Multiply(mat,RotateZ(az));
return mat;
}

ok it didn''t work, so i commented out the rotation functions and the translation works fine. The rotation works because I used it in world matrix and it worked fine, so just burgering up in the settingupviewmatrix. I pass the viewmatrix 0,0,0 for rotation & translate to -10 on zaxis and 0,0 on x&y axis. So the rotation keeps on belling it up , please help.

PS don''t point me out to the D3DUtil function, I know about but I want to create 1 without using vectors but actual points thanx in advance WizHarD

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632960
• Total Posts
3009477
• ### Who's Online (See full list)

There are no registered users currently online

×