Hello?

Can someone tell me how can i get the viewing

vector from the World Matrix?

You can get the view vector by doing the following:

First you invert the View-Matrix and than you multipy the invers-View-Matrix with the vector (0,0,1)

is it necessary to invert it, i just use

forward_direction_vector = VECTOR( use_cam_rotMATRIX.m[2], use_cam_rotMATRIX.m[5], use_cam_rotMATRIX.m[8] );

which has worked flawlessly until now.

could this run into problems?

This is how I do it in my camera class and it works great.

```
Matrix4 camRot, cx, cy;
camRot.ToIdentity();
cx.ToIdentity();
cy.ToIdentity();
cx.RotateX( m_fPitchAngle * DEGTORAD );
cy.RotateY( m_fYawAngle * DEGTORAD );
camRot = cy * cx;
vector_t dir = camRot * m_vVelocity;
if( dt > 0 )
VectorMulFloat( &dir, dir, dt );
```

-SirKnight

Originally posted by zed:

[b]is it necessary to invert it, i just use

forward_direction_vector = VECTOR( use_cam_rotMATRIX.m[2], use_cam_rotMATRIX.m[5], use_cam_rotMATRIX.m[8] );

which has worked flawlessly until now.

could this run into problems?[/b]

unless you have scaling or sheering in your matrix (which shouldnt be the case) the inverted rotation part is the transposed. multiplying the "z"vector with that should result in the z axis of the matrix. ie. it should be pretty much what youre doing.

None of this is the viewing vector if the model has been orientated in world space using the modelview matrix. You’re extracting a vector that is the concatonation of the models transform and the viewing (camera) transform.

In d3d the 2 transforms are kept seperate, but in GL they’re fused into 1 transform.

Originally posted by knackered:

None of this is the viewing vector if the model has been orientated in world space using the modelview matrix.

hm, i guess we simply expected he is aware that he has to do it BEFORE any additional transformations are applied. but i admit i like the seperate matrices of d3d better.