Jump to content
  • Advertisement
Sign in to follow this  

Directx translation (use only for one primitve)

This topic is 2360 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:

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 );

And then:

//set next source (NEW)
//draw quad (NEW)

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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!