Sign in to follow this  

Directx translation (use only for one primitve)

This topic is 2053 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, I'm having a little problem with my app... I'm making 'Pong' game. When I try to move the ball, other primitives are moved too... I want them to stay in theirs positions...

I Draw the ball with this code:
[CODE]
D3DXMatrixTranslation(&matTranslation,Position.x, Position.y, Position.z);
Position.z -= 0.01f;
IGameStartup.GetDevice()->SetTransform( D3DTS_WORLD, &matTranslation );

IGameStartup.GetDevice()->SetTextureStageState( 0, D3DTSS_ALPHAARG1,D3DTA_TEXTURE );
IGameStartup.GetDevice()->SetTexture( 0, Texture );

IGameStartup.GetDevice()->SetStreamSource( 0, BallVB, 0, sizeof( D3DVERTEX ) );
IGameStartup.GetDevice()->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
IGameStartup.GetDevice()->SetTexture( 0, NULL );
[/CODE]

And then:
[CODE]
//set next source (NEW)
IGameStartup.GetDevice()->SetStreamSource(0,pQuadVB,0,sizeof(D3DVERTEX));
//draw quad (NEW)
IGameStartup.GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
[/CODE]

Share this post


Link to post
Share on other sites
Call SetTransform with your translated matrix before the DrawPrimitive call of the object you want to move, but specify a new different matrix (Identity) with another SetTransform call before the DrawPrimitive call to the objects you don't want to move. In short, changing the streamsource to select another object vertex buffer don't reset the world transformation matrix.

Share this post


Link to post
Share on other sites

This topic is 2053 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this