0

Alright so I did this thing today in class, programming a rotating square. So it all works good, but when I change the view matrix to move side to side, it scews from the side? Like, its on a grid, and so the grid hits the right side of the display, and continues on the otherside, but scewed?

I know this is a pretty vague question, but im unsure how it works, very new to graphics programming.

//Create View
    View = XRotation4x4(XRotation);
    View = YRotation4x4(YRotation)*View;
    View = ZRotation4x4(ZRotation)*View;
    View = TranslationMatrix4x4(CamPos.x, CamPos.y, CamPos.z)*View;
    //Inverse view
    View = View.Inverse();
    //Projecting my feelings
    Projection = ProjectionMatrix4x4(90, Width, Height, 0.1, 10);

    //Draw calls
    VertexShader = ApplyWVP;
    PixelShader = NULL;

    WorldMatrix = Identity4x4;
    DrawGrid(GridH, GridV, 22, 22, GridColor);

    WorldMatrix = TranslationMatrix4x4(0, 0.25, 0);
    WorldMatrix = WorldMatrix*YRotation4x4(Timer->TotalTime() * 20);
    DrawCubeWireframe(Cube, CubeColor,true);

Before:

img

After moving to the left:

img

Spektre
  • 49,595
  • 11
  • 110
  • 380
7ark
  • 1
  • 2
  • It's better to add some code samples, people will help you to solve your problem. – Blackcoat77 Jan 13 '17 at 02:14
  • without knowing what you do with the matrices (in rendering) or their content is hard to say. See [Understanding 4x4 homogenous transform matrices](http://stackoverflow.com/a/28084380/2521214) and the sublinks there too (especially last two). My bet is that you are mixing column and row major matrix representations or matrix multiplication order. – Spektre Jan 13 '17 at 08:30

0 Answers0