hi!
i think you heard of my software render lib. my problem now is that i'm using euler rotation and i dont know how to use the real rotation - i mean quaternion rotation...
this example shows pretty good what i mean
this is my matrix lib so far. it is fully working, but the euler rotation is just bothering me ;D
thank you for any help :)
i think you heard of my software render lib. my problem now is that i'm using euler rotation and i dont know how to use the real rotation - i mean quaternion rotation...
this example shows pretty good what i mean
Graphics3D 800, 600, 32, 2 SetBuffer BackBuffer() ;Camera Cam = CreateCamera() RotateEntity CreateLight(), 70, 20, 0 ;Cubes Cube1 = CreateCube() PositionEntity Cube1, -2, 0, 5 Cube2 = CreateCube() PositionEntity Cube2, 2, 0, 5 SetFont LoadFont("Arial", 30, True) While Not KeyHit(1) ;Cube 1 rotation (Euler; WRONG!) rot = rot + 2 RotateEntity Cube1, rot, rot, rot ;Cube 2 rotation (Quaternion; RIGHT!) TurnEntity Cube2, 2, 2, 2 RenderWorld Text 40, 100, "Euler rotation:" Text 40, 140, "(Like in my software renderer)" Text 500, 100, "Quaternion rotation:" Text 500, 140, "(I need that)" Rect 400, 0, 1, 600 Flip Wend End
this is my matrix lib so far. it is fully working, but the euler rotation is just bothering me ;D
;My matrix library Global vglMat_aa#, vglMat_ab#, vglMat_ac# Global vglMat_ba#, vglMat_bb#, vglMat_bc# Global vglMat_ca#, vglMat_cb#, vglMat_cc# Global vglMat_da#, vglMat_db#, vglMat_dc# Function vglMatrixIdentity() vglMat_aa# = 1: vglMat_ab# = 0: vglMat_ac# = 0 vglMat_ba# = 0: vglMat_bb# = 1: vglMat_bc# = 0 vglMat_ca# = 0: vglMat_cb# = 0: vglMat_cc# = 1 vglMat_da# = 0: vglMat_db# = 0: vglMat_dc# = 0 End Function Function vglMatrixTranslate(x#, y#, z#) vglMat_da# = vglMat_da# + x# vglMat_db# = vglMat_db# + y# vglMat_dc# = vglMat_dc# + z# End Function This Function is what is euler-rotation And Not quaternion-rotation ===> You must know, in the function below is matrix rotation And matrix multiply all in one! Function vglMatrixRotate(x#, y#, z#) If x# <> 0 Then vglMat2_ab# = vglMat_ab# vglMat2_bb# = vglMat_bb# vglMat2_cb# = vglMat_cb# vglMat2_db# = vglMat_db# vglMat_ab# = vglMat_ab# * Cos(x#) + vglMat_ac# * -Sin(x#) vglMat_ac# = vglMat2_ab# * Sin(x#) + vglMat_ac# * Cos(x#) vglMat_bb# = vglMat_bb# * Cos(x#) + vglMat_bc# * -Sin(x#) vglMat_bc# = vglMat2_bb# * Sin(x#) + vglMat_bc# * Cos(x#) vglMat_cb# = vglMat_cb# * Cos(x#) + vglMat_cc# * -Sin(x#) vglMat_cc# = vglMat2_cb# * Sin(x#) + vglMat_cc# * Cos(x#) vglMat_db# = vglMat_db# * Cos(x#) + vglMat_dc# * -Sin(x#) vglMat_dc# = vglMat2_db# * Sin(x#) + vglMat_dc# * Cos(x#) EndIf If y# <> 0 Then vglMat2_aa# = vglMat_aa# vglMat2_ba# = vglMat_ba# vglMat2_ca# = vglMat_ca# vglMat2_da# = vglMat_da# vglMat_aa# = vglMat_aa# * Cos(y#) + vglMat_ac# * Sin(y#) vglMat_ac# = vglMat2_aa# * -Sin(y#) + vglMat_ac# * Cos(y#) vglMat_ba# = vglMat_ba# * Cos(y#) + vglMat_bc# * Sin(y#) vglMat_bc# = vglMat2_ba# * -Sin(y#) + vglMat_bc# * Cos(y#) vglMat_ca# = vglMat_ca# * Cos(y#) + vglMat_cc# * Sin(y#) vglMat_cc# = vglMat2_ca# * -Sin(y#) + vglMat_cc# * Cos(y#) vglMat_da# = vglMat_da# * Cos(y#) + vglMat_dc# * Sin(y#) vglMat_dc# = vglMat2_da# * -Sin(y#) + vglMat_dc# * Cos(y#) EndIf If z# <> 0 Then vglMat2_aa# = vglMat_aa# vglMat2_ba# = vglMat_ba# vglMat2_ca# = vglMat_ca# vglMat2_da# = vglMat_da# vglMat_aa# = vglMat_aa# * Cos(z#) + vglMat_ab# * -Sin(z#) vglMat_ab# = vglMat2_aa# * Sin(z#) + vglMat_ab# * Cos(z#) vglMat_ba# = vglMat_ba# * Cos(z#) + vglMat_bb# * -Sin(z#) vglMat_bb# = vglMat2_ba# * Sin(z#) + vglMat_bb# * Cos(z#) vglMat_ca# = vglMat_ca# * Cos(z#) + vglMat_cb# * -Sin(z#) vglMat_cb# = vglMat2_ca# * Sin(z#) + vglMat_cb# * Cos(z#) vglMat_da# = vglMat_da# * Cos(z#) + vglMat_db# * -Sin(z#) vglMat_db# = vglMat2_da# * Sin(z#) + vglMat_db# * Cos(z#) EndIf End Function Function vglMatrixScale(x#, y#, z#) vglMat_aa# = vglMat_aa# * x# vglMat_ab# = vglMat_ab# * y# vglMat_ac# = vglMat_ac# * z# vglMat_ba# = vglMat_ba# * x# vglMat_bb# = vglMat_bb# * y# vglMat_bc# = vglMat_bc# * z# vglMat_ca# = vglMat_ca# * x# vglMat_cb# = vglMat_cb# * y# vglMat_cc# = vglMat_cc# * z# vglMat_da# = vglMat_da# * x# vglMat_db# = vglMat_db# * y# vglMat_dc# = vglMat_dc# * z# End Function
thank you for any help :)