PHASE 1( 3d engine creation )
Phase Details :
Phase 1 involves the creation of a 3d engine capable of displaying large worlds at an optimum frame rate . Implementation of this phase will be done in Visual C++ using OpenGL and/or DirectX . Platform specific functions will be separated and put in platform specific code libraries.
coding language : C/C++
coding platform : Windows
Author : Prashanth Ellina
Phase head : Prashanth Ellina
Document creation date and time : Sunday, 14 October, 2001 ( Time : 14:20:51 )
Document Description : This document contains a basic introduction to 3d math using matrices and trigonometry.
Date : Sunday, 14 October, 2001
Time : 16:53:17
Topic : Projection of 3d objects onto 2d plane (screen)
formulae:
screen.x = screen_center.x+dist * (vertex.x/vertex.z)
screen.y = screen_center.y+dist * (vertex.y/vertex.z)
The above formulae helps in converting 3d coordinated of the objects into 2d coordinates of the screen which is the projection plane in this case. x and y coordinates are judged with reference to the z value which is the depth . The more the depth the lesser effect the x and y values have . This results in the perpective view we seen in real life ( as shown in picture below )
screen.x - final x coordinate projection of 3d point (vertex.x,vertex.y,vertex.z)
screen.y - final y coordinate projection of 3d point (vertex.x,vertex.y,vertex.z)
screen_center.x - x coord of screen center . (eg 320 for a 640 X 480 screen )
screen_center.y - y coord of screen center . (eg 240 for a 640 X 480 screen )
dist - field of view ( usual vals 256 , 512 , 1024 )
vertex.x , vertex.y , vertex.z - x,y,z coords of 3d point
Date : Sunday, 14 October, 2001
Time : 16:55:27
Topic : Translation of a point P(x,y,z) by a,b,c units
Translation means moving. Therefore translation of a point means , shifting the point from the current location to the new location. This can be done easily without complicated mathematical calculations.
when P(x,y,z) is translated by a,b,c units then
the new point Q has coords (x+a,y+b,z+c)
Another way of doing point transformation is the matrix method.
Date : Thursday, 18 October, 2001
Time : 12:59:27
Matrix method :
Consider the 3d point ( x,y,z) and assume that it has to be traslated by (a,b,c) units along the x-axis
Transformation matrix or translation matrix
In the above matrix tx , ty and tz are the required translations along x , y and z co-ordinated respectively
Now consider the second matrix , which unlike the first one is not a square matrix.
Point matrix
The point matrix is a 1x4 matrix that contains the original co-ordinates of the point.W is an extra parameter which is always equal to 1 . w is considered because it will be useful in calculating motion of a body.
Now to transform the point by (a,b,c) units along the co-ordinate axes taken in order, we'll have to do the following.
x1 = dot product ( 1st row of transformation matrix and point matrix )
y1 = dot product ( 2nd row of transformation matrix and point matrix )
z1 = dot product ( 3rd row of transformation matrix and point matrix )
where x1,y1,z1 are the co-ordinates of the transformed point.
The above can be represented as
x1 = x*1 + y*0 + z*0 + w*tx
y1 = x*0 + y*1 + z*0 + w*ty
z1 = x*0 + y*0 + z*1 + w*tz
where w=1
Date : Thursday, 18 October, 2001
Time : 13:49:20
Topic : Scaling a point P(x,y,z)
Multiplication of a co-ordinate(s) of a point by a constant value is called scaling. Scaling of a 3d object results in an object of different dimensions.The process of scaling can easily be done by multiplying the co-ordinate(s) of the point by the required scaling factor.The other method is the matrix method.
Consider the matrix
Scaling matrix
Here sx,sy and sz are the scaling factors along the x,y and z axes respectively.
Point matrix
x1 = dot product ( 1st row of scaling matrix and point matrix )
y1 = dot product ( 2nd row of scaling matrix and point matrix )
z1 = dot product ( 3rd row of scaling matrix and point matrix )
Where x1,y1,z1 are the co-ordinates of the scaled point.
The above can be represented as
x1 = x*sx + y*0 + z*0 + w*0
y1 = x*0 + y*sy + z*0 + w*0
z1 = x*0 + y*0 + z*sz + w*0
where w=1
Date : Thursday, 18 October, 2001
Time : 14:27:52
Topic : Rotation of a point P(x,y,z)
Consider the rotation of the point P(x,y,z) about the co-ordinate axes . We can do the same using any one of the techniques listed below
Technique 1 : Matrix method
INPUTS :
Point P(x,y,z) , angles of rotation about x,y,z axes as ax,ay,az respectively
OUTPUTS :
rx , ry , rz --> Final co-ordinates.
PROCESS :