Archived

This topic is now archived and is closed to further replies.

Vector Look

This topic is 5178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im trying to get my ships to point vector(thisvec), im using matrix stacks witch work fine with evertything else, so basicly im trying to rotate the ship with mroate matrix to point the ship in the thisvec direction, but the ship doesnt even show up when i add this transformation, im doing this right befor i draw the ship, (the ship rotate is an enemy ship not the player) D3DXMATRIX mroate; Vector xAxis(1,0,0); Vector myUpVector = thisvec.RotateBy(90,xAxis); D3DXVECTOR3 EyePt( 0,0,0); D3DXVECTOR3 LookatPt(thisvec.x,thisvec.y,thisvec.z); D3DXVECTOR3 UpVec(myUpVector.x,myUpVector.y,myUpVector.z ); D3DXMatrixLookAtLH( &mroate, &EyePt, &LookatPt, &UpVec ); D3DXMatrixMultiply(mStack->GetTop(), &mroate, mStack->GetTop()); r->SetTransform(D3DTS_WORLDMATRIX(0), mStack->GetTop()); [edited by - MetaKnight on October 13, 2003 3:21:19 AM]

Share this post


Link to post
Share on other sites
this is what my little group has been useing

void gr_d3d_start_instance_matrix(){
lpD3DDevice->GetVertexShader(&old_shader);
D3DXMATRIX mat, scale;

D3DXMatrixPerspectiveFovLH(&mat, (4.0/9.0)*(D3DX_PI)*View_zoom, Canv_w2/Canv_h2, 0.2f, 30000);
lpD3DDevice->SetTransform(D3DTS_PROJECTION, &mat);

D3DXMATRIX world(
Object_matrix.vec.rvec.xyz.x, Object_matrix.vec.rvec.xyz.y, Object_matrix.vec.rvec.xyz.z, 0,
Object_matrix.vec.uvec.xyz.x, Object_matrix.vec.uvec.xyz.y, Object_matrix.vec.uvec.xyz.z, 0,
Object_matrix.vec.fvec.xyz.x, Object_matrix.vec.fvec.xyz.y, Object_matrix.vec.fvec.xyz.z, 0,
Object_position.xyz.x, Object_position.xyz.y, Object_position.xyz.z, 1);
D3DXMatrixScaling(&scale, Model_Interp_scale_x, Model_Interp_scale_y, Model_Interp_scale_z);
D3DXMatrixMultiply(&mat, &scale, &world);
lpD3DDevice->SetTransform(D3DTS_WORLD, &mat);

D3DXMATRIX view(
Eye_matrix.vec.rvec.xyz.x, Eye_matrix.vec.rvec.xyz.y, Eye_matrix.vec.rvec.xyz.z, 0,
Eye_matrix.vec.uvec.xyz.x, Eye_matrix.vec.uvec.xyz.y, Eye_matrix.vec.uvec.xyz.z, 0,
Eye_matrix.vec.fvec.xyz.x, Eye_matrix.vec.fvec.xyz.y, Eye_matrix.vec.fvec.xyz.z, 0,
Eye_position.xyz.x, Eye_position.xyz.y, Eye_position.xyz.z, 1);


D3DXMatrixIdentity(&mat);
D3DXMatrixInverse(&mat, NULL, &view);
lpD3DDevice->SetTransform(D3DTS_VIEW, &mat);
material.Power = 16;

lpD3DDevice->SetVertexShader((D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2));
d3d_SetRenderState(D3DRS_LIGHTING , TRUE);
}

void gr_d3d_end_instance_matrix(){
D3DXMATRIX mat;
D3DXMatrixIdentity(&mat);
lpD3DDevice->SetTransform(D3DTS_VIEW, &mat);
lpD3DDevice->SetTransform(D3DTS_PROJECTION, &mat);
lpD3DDevice->SetTransform(D3DTS_WORLD, &mat);

lpD3DDevice->SetVertexShader(old_shader);
d3d_SetRenderState(D3DRS_LIGHTING , FALSE);
d3d_SetTexture(1, NULL);
d3d_SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
d3d_set_initial_render_state();
}

Share this post


Link to post
Share on other sites