Jump to content
  • Advertisement
Sign in to follow this  
HD86

Translation transform fails if vertex coordinate != 0

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

Hello,

I have two vertices for a line:

CUSTOMVERTEX LineVertices[] =
    {
        { 2560.0F, 0.0F, -2560.0F, 0xFFFFFFFF },
        { 2560.0F, 0.0F, 2560.0F, 0xFFFFFFFF }
    };

I use a translation matrix on the vertices:

D3DXMATRIXA16 TranslationMatrix;

D3DXMatrixTranslation(&TranslationMatrix, 1024.0F, 0.0F, 0.0F);
Device->SetTransform(D3DTS_WORLD, &TranslationMatrix));
Device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

The translation will not work on the X or Z coordinates, but it will work on the Y, which is set to 0 in the vertices.

Why doesn't it work?

 

 

Share this post


Link to post
Share on other sites
Advertisement
what do you mean by does not work? does the line stay in the same place?

what sort of projection matrix are you using? Edited by slicer4ever

Share this post


Link to post
Share on other sites

Yes the line does not move at all. Strangely, it does move if I put the transform command inside a loop and use the loop variable as a parameter. The following works:

for (FLOAT i = 0; i <= 1024; i += 1024)

{
        D3DXMATRIXA16 TranslationMatrix;
        D3DXMatrixTranslation(&TranslationMatrix, i, 0.0F, 0.0F);
        Device->SetTransform(D3DTS_WORLD, &TranslationMatrix);
        Device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

}

Perhaps there is something wrong in the organization of my code. I don't understand what is going on.

Share this post


Link to post
Share on other sites
Can you describe what you mean by "move" and "not working" more precisely? Perhaps showing more code would help us spot anything weird, too.

A transformation matrix calculates a new position for things relative to their original position; it doesn't change their position *over time*, and it doesn't change their original location (unless you overwrite the original vertices with the transformed values).

When you tell D3D to 'SetTransform', it *affects* what appears, but it does not *modify* the original vertices. Edited by Nypyren

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!