Skip to main content
GameDev.net gamedev.net
🔒 Locked

Transforming

Started by Snash Apr 18, 2003 at 7:49 AM 4 replies 650+ views
Original Post
Snash
Snash
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.
Snash
Snash
No one knows?
Peon
Peon
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..
Peon
Snash
Snash
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?
aker_jus
aker_jus
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.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.