hey all,
I'm trying to figure out how to transform an object's rotation into a vector using tformvector(), then to convert that vector back to rotation to rotate a different object. This is probably useless within blitz, but necessary to work with another program that i am using.
Unfortunately, when I try to do this, I find that the rotations do not match. I wrote this little program to test it out, and you can see if you run it that they deviate. Can you help me figure out what I'm doing wrong?
Thanks,
roland
I'm trying to figure out how to transform an object's rotation into a vector using tformvector(), then to convert that vector back to rotation to rotate a different object. This is probably useless within blitz, but necessary to work with another program that i am using.
Unfortunately, when I try to do this, I find that the rotations do not match. I wrote this little program to test it out, and you can see if you run it that they deviate. Can you help me figure out what I'm doing wrong?
Thanks,
roland
Graphics3D 640,480,16,2 SetBuffer BackBuffer() SeedRnd MilliSecs() Global lx# Global ly# Global lz# Global cam = CreateCamera() PositionEntity cam,0,10,-20 Global l=CreateLight() RotateEntity l,0,0,0 ;primary object (source of rotation) cyl = CreateCylinder() ScaleEntity cyl,.2,4,.2 PositionEntity cyl,-10,4,0 ;secondary object that we'll try to make match "cyl" cyl2 = CreateCylinder() ScaleEntity cyl2,.2,4,.2 PositionEntity cyl2,10,4,0 EntityColor cyl2,255,0,0 While Not KeyHit(1) Delay 100 TurnEntity cyl,.1,.1,.1 ;call function to transform object's rotation to vector lightangle(cyl) ;align cyl2 to cyl's vector AlignToVector cyl2,lx,ly,lz,2 UpdateWorld() RenderWorld() Text 0,0,EntityPitch(cyl)+" "+lx+" "+EntityPitch(cyl2) Text 0,12,EntityYaw(cyl)+" "+ly+" "+EntityYaw(cyl2) Text 0,24,EntityRoll(cyl)+" "+lz+" "+EntityRoll(cyl2) Flip Wend Function lightangle(light) TFormVector(0,1,0,light,0) lx = TFormedX() ly = TFormedY() lz = TFormedZ() End Function