Saturday, June 10, 2006

World Cup first Match & 3D graphic Fundamentals

Germany 4 - 2 Costa Rica

Ermm, I think most of the people knew this result already, just act as a record lo. I have a bet with Kent for this match, he bet Germany and I took Costa Rica with eating 1 1/2 ball. So bad I lost the bet with the last world class ball score by Frings, Germany. I lost one cup of...Teh O Ice Limao anyway...

This is a good match, a really good start for this year world cup. Time fly and world change, world cup is getting more and more amazing compare to every previous cup. Economic, cash flow, football fever and global effect are very big and ... awesome I can say? Who don't know the exist of World Cup? Not possibe :P. Soccer become more than a sport now I think, people actually get rich and famous of it, economy rise and drop affected by it. World change I think. hehe.

Direct X (3D Graphic Fundamentals)

Well, i am not lazy for these few days, i did read something which John reminded me to read. Everything will grow very high and fast if it had a very stable fundamentals while thing collapse just in one second if the basic is shaking ( sound like pro, got example :P). Okay, okay. I stop reading about coding and function of D3Dx for these days while I got some cool resources from John which got a full detail of 3D fundamentals theory which implemented perfectly with Directx since the resources is about teaching Direct x. So I enjoying reading those stuff for 3 days ( well, my efficiency at Setapak is abit low, since at the same time i have to finish Naruto comic from 21-36 in one day) but that chapter is 100 pages of texts in A4 PDF.

Ermmm, source is confidential, sorry I cant share that out for some reason. But I think it is ok i share what i learnt from it.

3D graphic is all about Mathematic. Two most basic and useful topic of math in 3D graphic is Vector and Matrix. Then is Trigo, Algebra, etc I not yet find out. Vector used in 3D to define the position of vertex, direction of normal for polygon. Matrix mainly use for transforming the vertex in vector form from translation, rotation, scale to pipeline transforming. Using of matrix seem is the most effective way and easier way to implement the transforming of vertex.

Involved D3DX function :
  • D3DXMATRIX
  • D3DXVECTOR3
  • D3DXVec3Cross ( D3DXVECTOR3* pOut, CONST D3DXVECTOR3* pV1, CONST D3DXVECTOR3* pV2 );
  • D3DXVec3Dot ( CONST D3DXVECTOR3* pV1, CONST D3DXVECTOR3* pV2 );
  • D3DXVec3Length( CONST D3DXVECTOR3* pV );
  • D3DXVec3Normalize ( D3DXVECTOR3* pOut, CONST D3DXVECTOR3* pV );

There are 3 main type of transformation of vertex. Thats translation (moving position of one vertex), rotation and scaling of vertex. vertex position is recorded in 3D vector (or 4D for transforming purpose) then this vector mutiply with Transformation matrix will result a transformed vector. E.G. VectorA x RotationMatrix = VectorRotatedA. The good thing about using matrix is we actually can combine all the transformation matrix as one transform by Multiplying them together. E.G. RotationMatrix X TranslationMatrix = RotateAndTranslateMatrix. This save some operation and calculation effort but need to aware of the arrangement of matrix in multiplying, different placement will result differnt matrix. E.G. A X B != B X A.

There are something need to aware and we may interested in. 4D vector and 4D matrix are actually used in direct x. Why 4D? This is mainly because for translation matrix purpose. Due to the impossible to perform translation with 3D matrix, an extra slot is needed to perform an addition as the translation. the 4th row in matrix is use for translation.

Involved D3DX function :
  • D3DXMatrixMultiply(D3DXMATRIX *pOut, D3DXMATRIX *pA ,D3DXMATRIX *pB)
  • D3DXMatrixRotationX(D3DXMATRIX *pOut, float Angle) Y and Z same.
  • D3DXMatrixTranslation(D3DXMATRIX *pOut, float X, float Y, float Z)
  • D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pOut, float Yaw, float Pitch, float Roll) : yaw - x rotation, Pitch - Y rotation, Roll - Z Rotation
  • D3DXVec3TransformCoord( D3DXVECTOR3* pOut, CONST D3DXVECTOR3* pV, CONST D3DXMATRIX* pM );
  • D3DXVec3TransformNormal(D3DXVECTOR3* pOut, CONST D3DXVECTOR3* pV,
    CONST D3DXMATRIX* pM );
  • D3DXVec3Transform ( D3DXVECTOR4* pOut, CONST D3DXVECTOR3* pV,
    CONST D3DXMATRIX* pM);
It seem unreasonable to just put the function there and not explaining...sorry about that, too much to type then :P with the function, It not hard to understand th basic concept but the whole concept may need you to read it from direct x documentation.

I'll share the PipeLine 2 in next blog, so....stay tuned! lol...Just kidding.

Today Feeling : Ermmm, world cup started and life go on.