Camera Transformation woes :/

Started by
3 comments, last by The Forgotten Mindset 18 years, 9 months ago
Hey guys, I'm trying to fit the matrix transformations into my engine and I'm having some problems trying to integrate a camera system. I just can't seem to get my camera to rotate the way cameras should. I've been trying to put in some values for the camera's up vector, but I can't seem to get any precise angles. I was thinking of making the cameras always points up in the positive y direction, but let the camera class have it's own special world matrix that you can rotate it with. And when it's time to update the camera, that matrix gets filled with opposite values for the camera's rotation. And with that matrix, you combine it with the world matrices for all of the other game objects. Therefore each object would rotate around the camera, instead of vice versa. This may sound slow, but I think this is what Microsoft is talking about here in the DX 8.1 sdk:
Quote:Performance Optimization Note: Microsoft® Direct3D® uses the world and view matrices that you set to configure several internal data structures. Each time you set a new world or view matrix, the system recalculates the associated internal structures. Setting these matrices frequently—for example, 20,000 times per frame—is computationally expensive. You can minimize the number of required calculations by concatenating your world and view matrices into a world-view matrix that you set as the world matrix, and then setting the view matrix to the identity. Keep cached copies of individual world and view matrices that you can modify, concatenate, and reset the world matrix as needed. For clarity, Direct3D samples rarely employ this optimization.
Please correct me if I'm wrong. Thanks in advance :)
The G'Bro GameDev Society! -The Southeastern US GameDev Gathering Group
Advertisement
Hello, uhh... Mindset?

Anyway, It's called a World-View matrix, and if you change your view matrix a lot, then it is the way to go (according to microsoft as you have read).

My camera class has a world-view matrix and before I render I set that matrix to be the transformation matrix of my root SceneNode (universe node) of my scene graph.

I have a thread here. Where I show how mine works and what I do not like about it. Maybe it will help you though.

Good Luck,
-------------------------------------------------------------------Life is short so go on and live it, cause the chicks dig it.- Kahsm
Thanks Kahsm, I'll give it a shot. :)
The G'Bro GameDev Society! -The Southeastern US GameDev Gathering Group
First of all, trying to optimize something before it even works is a big mistake. You are making things much more complicated than they need to be.

The basic camera is very simple. The basic camera has a world matrix which is used to position and rotate it -- just like everything else in the world. It also has a view matrix, which you get by computing the inverse of the world matrix.

That's all.

Once per frame, move and orient the camera as required. Then compute the inverse of the camera's world matrix and set the D3D view matrix to the result.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Thanks John, but that's actually what I just did [grin]

But my proposed optimization was not very difficult at all. Your way just fits into my engine better, that's all :)
The G'Bro GameDev Society! -The Southeastern US GameDev Gathering Group

This topic is closed to new replies.

Advertisement