Translation transform fails if vertex coordinate != 0

Started by
2 comments, last by Nypyren 6 years, 10 months ago

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?

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?
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

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.

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.

This topic is closed to new replies.

Advertisement