Jump to content
  • Advertisement
Sign in to follow this  
swtsvn

different world matrix for diferent objects

This topic is 3175 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

Hi everyone, I am developing a game, and new to DirectX. I need to apply different transformations to different objects on the screen. I am using effects file to implement HLSL. for every object i get transformation matrix from physx api. i need to multiply this world matrix with view and projection matrix and send to effects file. but the cube gets displayed on the center of the world, as if the world matrix has no effect at all. in physx I am translating the object by(-10,0,-15) during actor creation. getting the transformation matrix using float mat[16]; plankActor->getGlobalPose().getColumnMajor44(mat); passing this matrix to directX code //begin scene code here mWorld = g_mCenterWorld * *g_Camera.GetWorldMatrix(); mProj = *g_Camera.GetProjMatrix(); mView = *g_Camera.GetViewMatrix(); mWorldViewProjection = mWorld * mView * mProj; V( g_pEffect->SetMatrix( "g_mWorldViewProjection", &mWorldViewProjection ) ); V( g_pEffect->SetMatrix( "g_mWorld", &mWorld ) ); ...other parameters to pass to effect file V( g_pEffect->SetTechnique( "RenderSceneOnlyTexture" ) ); V( g_pEffect->Begin( &cPasses, 0 ) ); for( iPass = 0; iPass < cPasses; iPass++ ) { V( g_pEffect->BeginPass( iPass ) ); render_tower(); //render tower V( g_pEffect->EndPass() ); } V( g_pEffect->End() ); //end scene code here void render_tower(){ vector<mat4X4> Wmatrices=tower.getAllPlankMatrices(); //init iterator vector<mat4X4>::iterator matItr=Wmatrices.begin(); //get dimensions vector<vec3> dimensions=tower.getBoxDimensions(); //get iterator vector<vec3>::iterator i=dimensions.begin(); //render each plank //do check if(Wmatrices.size()!=dimensions.size()){ MessageBox( hWindow, L"ERROR: matrices and dimensions input from tower: size varies." , L"ERROR",MB_ICONERROR); //typecasting to lpcwstr is required. return false; } for(;i!=dimensions.end();i++,matItr++){ LPD3DXMESH plankMesh=NULL; D3DXCreateBox(d3ddev,(*i).x,(*i).y,(*i).z,&plankMesh,NULL); D3DXComputeNormals(plankMesh, NULL ) ; //draw D3DXMATRIXA16 Wm((*matItr).mat[0],(*matItr).mat[1],(*matItr).mat[2],(*matItr).mat[3],(*matItr).mat[4],(*matItr).mat[5],(*matItr).mat[6],(*matItr).mat[7],(*matItr).mat[8],(*matItr).mat[9],(*matItr).mat[10],(*matItr).mat[11],(*matItr).mat[12],(*matItr).mat[13],(*matItr).mat[14],(*matItr).mat[15]); D3DXMATRIXA16 mWVP=Wm * mView * mProj; g_pEffect->SetMatrix("mWorldViewProjection", &mWVP); g_pEffect->SetMatrix( "g_mWorld", &Wm ); g_pEffect->CommitChanges(); plankMesh->DrawSubset( 0 ); } return TRUE; } i googled, searched in documentations, but couldnt find out why the new matrix is not getting effective. can anyone please help me.

Share this post


Link to post
Share on other sites
Advertisement
next time use [ source] [ /source] tags please

as far as I know you shouldn't use

g_pEffect->SetMatrix("mWorldViewProjection", &mWVP);
g_pEffect->SetMatrix( "g_mWorld", &Wm );

between

g_pEffect->begin and g_pEffect->end

is this the problem?

Share this post


Link to post
Share on other sites
Quote:
Original post by Namethatnobodyelsetook
Quote:
Original post by shultays
is this the problem?
No, he's doing a CommitChanges, so any variables changed will be sent to the card.


Oh I didn't know about that =D thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!