PDA

Click to See Complete Forum and Search --> : Some how to do questions for direct x 8


Ultimasnake
Sep 4th, 2002, 03:46 PM
Here are somethings i really would like to know :

*How to oriente a object , in dx7 i used mesh.setorientation to rotate the object but also move its axis allong , with this i managed to move my car forward over it's X axis all the time, how to do this in dx8 or replace it with something else
*How to move a light , i know how to create one but how can i move it around.
*collision detection with bounding boxes, guess that could be done but the other two are more needed info

Zaei
Sep 4th, 2002, 03:56 PM
1) You need to create a rotation matrix. You can use the D3DX functions. You will want to rotate around the Y axis.

2) Simply change the position of the light in the D3DLIGHT8 structure, and Set the light again.

3) Google it =). Youll find tons of hits.

Z.

Lupin
Sep 5th, 2002, 01:15 AM
You won't find anything usefull with google. I haven't found anything about B-Box-collision detection :(

Please tell me where to find info about it?!

Ultimasnake
Sep 5th, 2002, 03:39 AM
Z. i really apriciate your help (really i do) but i am really new to Dx8 (also to direct x 7:rolleyes: ) but what you say is like well :confused: <that. I dont really know how to do this mind giving me a little example or just a code here?

and about google.. i search it and only get C++ examples while i also type "Visual basic" in it. what did you search for than?

Zaei
Sep 5th, 2002, 06:06 AM
Ill post some examples in a few hours.

I recommend that you REALLY learn to at least read C++, or you are screwed. Nearly everything that you will find on the web is going to be in C++, so you NEED to be able to convert.

Z.

Ultimasnake
Sep 5th, 2002, 06:22 AM
Thanks Z. i am at school right now so i will few them when i get back :D

Zaei
Sep 5th, 2002, 10:33 AM
Ok, what you are going to have to do is use a rotation matrix to set the orientation of your mesh. For this, you will want to use the D3DXMatrixRotationY() function. Pretty simple function, takes in a D3DMATRIX, which will hold the computed matrix, and an angle, in radians (to convert from degrees to radians, multiply by (pi / 180)). Using the D3DDevice.SetTransform() method, you could set this matrix as the D3DTS_WORLD type. This would simply rotate the car in whatever direction angle is.

This is obviously not what you want, as you want your car to move. So, you need another matrix, this time a Translation matrix. Again, D3DXMatrixTranslation() will create one for you. Simple enough, a D3DMATRIX out parameter, and 3 singles, for your x, y, and z positions. Now, as you might have noticed, you can only set one WORLD matrix. What we need to do is concatenate the translation and rotation matricies together. More D3DX =). Using the D3DXMatrixMultiply() function, you can create a matrix that will both rotate AND translate your car. The thing to remember about Matrix Multiplication is that it is NOT commutative, so it DOES matter in what order you multiply your matrices. In our case, we want our Rotation applied BEFORE the translation (otherwise, the translation would occur first, and the mesh would not appear in the right place). So, the D3DXMatrixMultiply() function takes in 3 D3DMATRIX structures. The first is the final matrix. The second and third parameters are your input matrices. Remember that the order matters, you you would have the rotation matrix as the second parameter, and the translation matrix as the third parameter. You would then SetTransform() with that final matrix, and render.

Dim f As D3DMATRIX
Dim r As D3DMATRIX
Dim t As D3DMATRIX

D3DXMatrixRotationY r, 90 * (3.14159 / 180) 'create a rotation matrix, 90 degrees
D3DXMatrixTranslation t, 10, 0, 10 'translation matrix at (10, 0, 10)
D3DXMatrixMultiply f, r, t
D3DDevice.SetTransform D3DTS_WORLD, f
'Render

Its a lot simpler then my explaination makes it seem =).

For the light. You said that you know how to create a light, just not change the position. Well, the D3DLIGHT8 structure has a position member, which contains an x, y, and z components to position the light in 3D space. Simply change these values, and use the D3DDevice.SetLight() function to change the light you want to change. If you dont want to store the D3DLIGHT8 structure, you can use the D3DDevice.GetLight() function.

If you have any questions, dont hesitate to ask =).

Z.