Directx D3DXMatrixLookAtLH prob? [Archive] - C Board

PDA

View Full Version : Directx D3DXMatrixLookAtLH prob?


Frog22
12-10-2002, 11:41 AM
hello!!!

where to start....

well I am writing a simple program to load X files, In the program i have setup several functions for camera movement...

now based on the users input, i have setup these functions to adjust the camera source/target accordingly through the D3DXMatrixLookAtLH function, then pass the D3DXMATRIX through the g_pD3D->SetTransform(D3DTS_VIEW, &matView);

now my prob is when i pass the D3DXVERTEX3 variable as the source in the D3DXMatrixLookAtLH function, being the second parameter, it tells me that it is expecting a constant expression instead of a literal expresion.

also with the error it says that no user defined operator is given to make the conversion, or operator cannot be called.

sorry for the sparactic thought, i haven't sleep in what feels like days!

anyway here is the code snipplet:
enjoy....

void vSetupView()
{
D3DXMATRIX m;
D3DXMATRIX matView;
D3DXMATRIX matRotate;
D3DXMATRIX matProj;
D3DXVECTOR3 matSource;
D3DXVECTOR3 matTarget;

D3DXMatrixRotationX(&m, xRotation);
matRotate = matRotate * m;
D3DXMatrixRotationY(&m, yRotation);
matRotate = matRotate * m;
D3DXMatrixRotationZ(&m, xRotation);
matRotate = matRotate * m;

//set zoom and height strafe
matSource.x = xAdjust;
matSource.y = yAdjust;
matSource.z = -30.0f;

matTarget.x = xAdjust;
matTarget.y = yAdjust;
matTarget.z = 0.0f;

matSource.x = matSource.x + (Zoom * (matTarget.x - matSource.x));
matSource.y = matSource.y + (Zoom * (matTarget.y - matSource.y));
matSource.z = matSource.z + (Zoom * (matTarget.z - matSource.z));

matTarget.x = matTarget.x + (Zoom * (matTarget.x - matSource.x));
matTarget.y = matTarget.y + (Zoom * (matTarget.y - matSource.y));
matTarget.z = matTarget.z + (Zoom * (matTarget.z - matSource.z));



D3DXMatrixLookAtLH( &matView, matSource,
matTarget,
D3DXVECTOR3(0.0f, 1.0f, 0.0f);

matView = matView * matRotate;

D3DXMatrixPerspectiveFovLH (&matProj, D3DX_PI/4, 1.0f, 1.0f, 500.0f);

g_pD3DDevice->SetTransform
(D3DTS_VIEW, &matView);
g_pD3DDevice->SetTransform
(D3DTS_PROJECTION, &matProj);
}

that is it...

well any help is appreciated, i know it is something simple and i am not thinking right now, :) thanks frog22


We'd enjoy it more if it had code tags (http://www.cprogramming.com/cboard/showthread.php?s=&threadid=25765). Hammer

MrWizard
12-10-2002, 01:27 PM
You forgot a paranthesis on the call to D3DXMatrixLookAtLH.

Frog22
12-10-2002, 01:49 PM
sorry that wasn't it, althought thank you for the reply anyway!!

MrWizard
12-10-2002, 02:00 PM
For the same call , you need to pass the address of the variables...for example..


D3DXMatrixLookAtLH( &mat1, &mat2, &mat3, &D3DXVector3( 1.0f, 2.0f, 3.0f ) );

Frog22
12-10-2002, 02:20 PM
well that was it.... lol i have spent the last 2 hours going over the prob and that was it.

thanks mr wizard...