Jump to content
  • Advertisement


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


D3D8 Transform Woes

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

Well, here we are, some newbies (to D3D, at least) asking a (probably) obvious question. But here goes anyway! We have 2 textured polygons (henceforth called polys so we can sound coool) that we are drawing on the screen. pic1 (a CPic, which is a class we made that contains a CPrimitive, another class we made) is 64x64 with one texture, and pic2 is another poly, which is 32x32 and has a different texture. Our problem is that the transforms to position the polys are being applied to the wrong polygons. For example, we set pic1 to draw at (-100, -100) -- it''s one of those 2D/3D engines, so the Z coordinate is constant. We set pic2 to display at (100, 500), and is to be rotated 32 degrees. Also, in the Update() code, pic1 is moved a few pixels every frame. When the program runs, every transform that was meant to apply to pic1 is applied to pic2, and vice versa. Pic1 is rotated and at (100, 500), and pic2 starts at (-100, -100) and moves. Yikes. Heres the code for DrawScene():
void DrawScene()
That doesn''t help much, does it? CPic::Draw() is a wrapper for the CPrimitive::Draw() function (every CPic has a CPrimitive which holds all the position and texture information). So here''s the CPrimitive::Draw():
void CPRIMITIVE::Draw()
	float zoomoffset = 0.0f;
	if (!zoomable)
		zoomoffset = CAMERADIST - dist;
		zoomoffset = dist;
	// Transformation
	D3DXMATRIX translation;
	D3DXMATRIX rotation;
	D3DXMATRIX final;
As you can see from the code above, we follow a pretty standard system for transforms (i.e. transform the world matrix, draw it, that''s standard, right?), but obviously we''re doing something wrong... We would appreciate any help that could be given. Thank you. Pat & Jake

Share this post

Link to post
Share on other sites

Your problem is the ProcessVertices call. You don''t need it and shouldn''t use it. ProcessVertices is doing the transformation and then your world matrix is being ignored by the DrawPrim call.

ProcessVertices creates Transformed Vertices. Transformed vertices are not affected by the current world matrix, they have screen coordinates.

ProcessVertices DOES use the current world matrix, which because of the way things are organized will be the world matrix for the other object.

What you should do is associate a Vertex Buffer with each object, then just set the world matrix and do a DrawPrim call.

Let me know if that doesn''t make sense. There are a number of tutorials on my site (www.drunkenhyena, just click my sig) that you might find helpful.

Stay Casual,

Drunken Hyena

Share this post

Link to post
Share on other sites
Thank you so much for your help. Your advice helped greatly. My friend didn''t want to rewrite all of what he had done so far so that processed vertices weren''t used, but we solved the situation by moving the ProcessVertices() call to a point after the world matrix is set.

Thanks again (now we''re having more adventures trying to convert the thing to a .dll, but it''s actually going pretty well...er, kind of)

I''m sure we''ll be on posting about that at some other time.

Jake (him) & Pat (me)

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.

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!