Help with AlignToVector

Blitz3D Forums/Blitz3D Programming/Help with AlignToVector

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

o.k., I think that this works, in principle. I found that I had to add 90 to the "Pitch" variable in order to get the rotations to match visually. But they don't seem to match by the numbers. Does this look like the correct implementation to you guys? I realize that I'll have to make these negative for the light vector, but other than that, is this right?


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

cyl = CreateCone()
ScaleEntity cyl,.2,4,.2
PositionEntity cyl,-1,4,0

cyl2 = CreateCone()
ScaleEntity cyl2,.2,4,.2
PositionEntity cyl2,1,4,0
EntityColor cyl2,255,0,0


While Not KeyHit(1)

;Delay 1000

TurnEntity cyl,.5,.5,.5

lightangle(cyl)


Yaw# = VectorYaw( lx ,ly, lz )
Pitch# = VectorPitch(lx,ly,lz )

RotateEntity cyl2,Pitch+90,Yaw,0

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



thanks again for all your help with this. Nothing beat's blitz's community!

best,
roland