Sign in to follow this  
HD86

Translation transform fails if vertex coordinate != 0

Recommended Posts

HD86    110

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
HD86    110

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
Nypyren    12074
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this