Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

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

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

Tranks in advance,
  • 2
1 Solution
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...

I use C++ as well, but I'm a former QB guy.
I got the movement of the camera and everything, but what you really should do is move the entire world if you want to skip changing the matrices for now.
There are some good tutorials on this at www.gamedev.net . One of them helped me through it, but I'm not sure I completely understand it yet. You must access the view matrix directly and change it to do this.

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)



Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now