Jump to content
  • Advertisement

Archived

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

Snash

Transforming

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

I''ve created a simple class, where I can store a texture for a sprite. Every time the class calls Draw, eg if I want to draw a 2DObject, the data of the vertices will be stored into a single vertex buffer and only one call to drawprimative is needed. Ex: for (int i=0; i < 10; i++) { TheSpriteClass.Draw } TheSpriteClass.Display the code will first draw to a single vertex buffer, 10 instance of the object, then display them. But what about transistions matrices? like rotation and movement? How should I implent that? I want to use the D3DXMATRIX if I can. Thanks for your time.

Share this post


Link to post
Share on other sites
Advertisement
I don''t know if I understand correctly, but if I am, you are saying that you want to use 3D transforms for a 2D game (that is in 3D)... is this correct?

Making the assumption that I''m right.. This is similar to what I am doing. For my game, I just have the sprites as quads (well, a single triangle, in my case ) and have one of the axes have the same number for the vertices. For example, if x and y was horizontally across the screen and into it, while z was up, I might have all of my vertices use 0.0 as their Z coordinate. Then I just spin it about its axis with the appropriate rotation matrix function.

If you mean, "how do I ue these transforms if everything is in one buffer", then I think you will want to use an index buffer? (not sure on this, I''m learning Dx9 as I go along.

Hope something in this post is actually worthwhile..

Share this post


Link to post
Share on other sites
I have a single vertex buffer. This buffer can hold 100*4 vertices. 4 vertices is used to create a quad, a sprite. So my vertex buffer can hold 100 sprites.

If I used a vertex buffer that only holds 4 vertices eg one sprite, and call DrawPrimitive 100 times to draw my 100 sprites, this would be inefficient.
But my question is, I have 4 vertices, which would be drawn to pos x y z, has a rotation and a scale, but how do I do that?

Share this post


Link to post
Share on other sites
Why not use the ID3DXSprite interface? Again, if you want to learn by doing it yourself, you can get away without using matrices. Make your VB a dynamic one, and change the vertices on the fly.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!