Link to home
Start Free TrialLog in
Avatar of egsoc
egsoc

asked on

Direct x 8 camera & matices

I just started using dx8 and noticed it's totaly different in rendering, certainly the matrices.

Now I created a 3d city and pointed the camera above it, like in GTA2. Now I would like to move the camera, but instead of just moving, he rotates around an axis.

Here's what I've wrote so far:

With Dev
    D3DXMatrixIdentity View
    D3DXMatrixIdentity Pos
    D3DXMatrixIdentity X
    D3DXMatrixLookAtLH View, MakeVector(0, 40, 0), MakeVector(0, 0, 0), MakeVector(1, 0, 0)
    .SetTransform D3DTS_VIEW, View
    D3DXMatrixTranslation Pos, 0, 40, 0
    D3DXMatrixMultiply View, Pos, X
    .SetTransform D3DTS_VIEW, View
    D3DXMatrixPerspectiveFovLH Proj, Game.Pi / 4, 1, 0.1, 500
    .SetTransform D3DTS_PROJECTION, Proj
    .Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &H0, 1, 0
    .BeginScene
...

If anyone knows the right combinations of setting and multiplying, I would realy appreciate it.

Tranks in advance,
Egsoc
Avatar of joachimc
joachimc

I am really bad at 3D math myself :) But I think that the reason you are having problems is that the camera Matrix is not behaving like you think it does. You can not add 40 to Y like you do because it give the opposite effect.

Remeber that the camera is the inverse of the world matrix. This means that moving your camera foward is the same as moving your world backward.

You have the position of your objects in row 4. so change the first x,y,z in that row and your camera should move.

D3DXMatrixInverse View
View._42 = View._42 + 40
D3DXMatrixInverse View
.SetTransform View

This code is more or less C++ you have to translate View._42 into whatever it's called in VB.

Hope it helps.
you have to move the camera and the look-at position.(eye)...( i dont know vb so i dont know if you do or not)

I think its easier to just move the entire world...

ASKER CERTIFIED SOLUTION
Avatar of RageDBL
RageDBL

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's what you do:

Establish the following variables:

Camera position (D3DXVECTOR3)
Orientation variables:
Facing Vector (D3DXVECTOR3)
Right Vector (D3DXVECTOR3)
Up Vector (D3DXVECTOR3)
Rotation Request Variables for each axis(only used to rotate, set to zero afterwards)

look at www.gamedev.net for the rest of this. I'm out of time for today. (sorry)

RageDBL