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

D3D View Matrix

Started by doctor_b Mar 19, 2000 at 3:52 PM 1 replies 800+ views
Original Post
doctor_b
doctor_b
ok, i have a view matrix and it translates and rotates etc, whats wrong is that the way i am doing it, i am translating and then roatting so it rotates around the origin, i know that i have to rotate and then translate but i dont know how to do this, here is what i have as of right now... // positions, rotates, and applies the view matrix D3DMATRIX view_matrix, RY, RX, RZ; ZeroMemory(&view_matrix, sizeof(view_matrix)); // create identity matrix view_matrix._11=view_matrix._22=view_matrix._33=view_matrix._44=1.0f; // create transform matrix view_matrix._41 = -camera_location.x; view_matrix._42 = -camera_location.y; view_matrix._43 = -camera_location.z; // create rotation matrices D3DUtil_SetRotateXMatrix(RX, -camera_rotation.x); D3DUtil_SetRotateYMatrix(RY, -camera_rotation.y); D3DUtil_SetRotateZMatrix(RZ, -camera_rotation.z); // apply rotate matrices D3DMath_MatrixMultiply(view_matrix, view_matrix, RY); D3DMath_MatrixMultiply(view_matrix, view_matrix, RX); D3DMath_MatrixMultiply(view_matrix, view_matrix, RZ); lpDevice->SetTransform(D3DTRANSFORMSTATE_VIEW,&view_matrix); ----------------------------- doctor_b@doctor.com
-----------------------------doctor_b@doctor.com
doctor_b
doctor_b
i am mad as hell, i have been searching for the solution for at least 6 hours today with no luck, i have books, tutorials, and even had people explain it to me but it just does not work, some please just take 5 seconds and figure this out because i have tried all i know and i can''t get it.

-----------------------------
doctor_b@doctor.com
-----------------------------doctor_b@doctor.com
Kylotan
Kylotan
You say you know to do the translation after you rotate, right? The program runs from top to bottom, so to do the translation last, the first thing you should try is moving the translation bit (3 lines after "//create transform matrix") to after the rotation bit (the 3 MatrixMultiplys).

Topic Locked

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

Sign in to reply to this topic.