Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Jan 2013
Offline Last Active Feb 02 2013 09:09 AM

Topics I've Started

Help needed setting up camera transform

05 January 2013 - 03:13 PM

First time poster here.  I tried searching the forum for prior posts related to this, but didn't find exactly what I needed. 


I am trying to make a simple 3d rendering engine just to demonstrate to myself that I understand the math.  I have not taken linear algebra, but have spent some time trying to self-teach with online and textbook tutorials and have a working understanding (I think).  I am writing this simple engine with lazarus free pascal.  


I have found several tutorials that I have tried reading through.  Most recently from www.scratchapixel.com.


First I have objects that are positioned in the world with a world transform/matrix.


Next I am trying to set up my camera transform.  But I am apparently doing something wrong.  I am hoping that if I write out my understanding here, someone can pick up where I am off.


First, I am planning on using a right-handed matrix and math.  I think this means that when I consider the axis at (0,0,0), +X will go to the "right", +Y will go "up", and +Z will come "out towards me".


Next, I think that to create the camera transform, one has to create cardinal vectors for the new coordinate space: In, Up, and Left.


In = LookingAtPosition - Camera Position

Left = In X (0,1,0)  (in vector cross a global up vector)

Up = in X Left 


Next, I think that the parts of a matrix are as follows.  But I am uncertain about this.


[Left.x,   Left.z,  Left.z,  A   ]

[  Up.x,    Up.y,   Up.z,   B  ]

[   In.x,      In.x,    In.z,   C   ]

[       0,          0,        0,     1 ]


A,B,C as a column vector is the position of the camera. (e.g. A=T.x, B=T.y, C=T.z)


I have some output from the engine, but this web page interface won't let me paste the text in. (I assume this is a defense against spammers).


Before I go any further, can anyone comment on my understanding so far?


Any help appreciated.


Kevin T