Original Post
Hi!
Currently, i'm writing a little raytracing library, everything worked very well - but now, i'm implementing matrices for the transformation.. so i would like to make some things right, because i think they could be wrong:
- LoadMatrix: Simply resets all Push and Pop stages and loads the given values into CurrentMatrix.
- PushMatrix: Creates a new matrix, copyies the current stage and pushes the current matrix on stack
- MultMatrix: Multiplies CurrentMatrix * ObjectMatrix
- PopMatrix: Restores the last pushed stage
- Normal Matrix: Upper 3x3 of CurrentMatrix, Inversed, Transposed (Compute it every time Load or MultMatrix is called)
- Set a Vertex: Vector(x, y, z) is multiplied by CurrentMatrix
- Set a Normal: Normal(nx, ny, nz) is Multiplied by CurrentMatrix -- or, when computed by intersection algorythm, this normal is used (and not transformed by NormalMatrix?)
- The Lights: Position and Direction is recomputed each "LoadMatrix" is called, not multiplied by CurrentMatrix
- Rays of Projection: Computed once per "SetViewport" - because our world is transformed, it isn't necessary to transform them
Would be nice if someone knows, if my thoughts are right or not..
Happy coding,
Lunatix
Currently, i'm writing a little raytracing library, everything worked very well - but now, i'm implementing matrices for the transformation.. so i would like to make some things right, because i think they could be wrong:
- LoadMatrix: Simply resets all Push and Pop stages and loads the given values into CurrentMatrix.
- PushMatrix: Creates a new matrix, copyies the current stage and pushes the current matrix on stack
- MultMatrix: Multiplies CurrentMatrix * ObjectMatrix
- PopMatrix: Restores the last pushed stage
- Normal Matrix: Upper 3x3 of CurrentMatrix, Inversed, Transposed (Compute it every time Load or MultMatrix is called)
- Set a Vertex: Vector(x, y, z) is multiplied by CurrentMatrix
- Set a Normal: Normal(nx, ny, nz) is Multiplied by CurrentMatrix -- or, when computed by intersection algorythm, this normal is used (and not transformed by NormalMatrix?)
- The Lights: Position and Direction is recomputed each "LoadMatrix" is called, not multiplied by CurrentMatrix
- Rays of Projection: Computed once per "SetViewport" - because our world is transformed, it isn't necessary to transform them
Would be nice if someone knows, if my thoughts are right or not..
Happy coding,
Lunatix