Hi all
Could some kind soul please take a look at this piece of code to see where i'm going wrong, Basically its a menu system with each item displayed on a seperate 3d sprite, all of the sprites rotate around a center pivot to give a cylinder effect.
The problem is my CurveAngle() function, I just can't get it to handle the jump from positive to negative angles.
Thanx for your help!
Could some kind soul please take a look at this piece of code to see where i'm going wrong, Basically its a menu system with each item displayed on a seperate 3d sprite, all of the sprites rotate around a center pivot to give a cylinder effect.
The problem is my CurveAngle() function, I just can't get it to handle the jump from positive to negative angles.
; Use up and down keys to scroll the list Graphics3D 800,600,32 Const MaxLines = 40 Global SelectedTrackIndex ; create camera Global Camera = CreateCamera() ; create list wheel Dim Item(MaxLines) Dim ItemTex(MaxLines) Global Wheel = CreatePivot() PositionEntity Wheel,0,0,4 For n = 1 To MaxLines Item(n) = CreateSprite(Wheel) ScaleSprite Item(n),2,0.1 TranslateEntity Item(n),0,0,-1.5,True EntityAutoFade Item(n),3.0,3.8 EntityBlend Item(n),3 ItemTex(n) = CreateTexture(512,10) TurnEntity Wheel,(360/MaxLines),0,0 Next UpdateWheelTextures() Global BackPlate = CreateSprite() ScaleSprite BackPlate,2,0.1 PositionEntity BackPlate,0,0,3 EntityColor BackPlate,0,0,50 ; main loop While Not KeyDown(1) ; Scroll up If KeyHit(200) SelectedTrackIndex = SelectedTrackIndex - 1 If SelectedTrackIndex < 0 Then SelectedTrackIndex = MaxLines EndIf ; Scroll down If KeyHit(208) SelectedTrackIndex = SelectedTrackIndex + 1 If SelectedTrackIndex > MaxLines Then SelectedTrackIndex = 0 EndIf UpdateListWheel() UpdateWorld() RenderWorld() Flip Wend End Function UpdateListWheel() current# = EntityPitch(Wheel) destin# = (360 / MaxLines) * SelectedTrackIndex ;dist# = destin# - current# ;speed# = dist# / 5 ;TurnEntity Wheel,speed#,0,0 RotateEntity Wheel,CurveAngle(current#,destin#,10),EntityYaw(wheel),EntityRoll(wheel) End Function Function UpdateWheelTextures() x = TextureWidth(ItemTex(1))/2 y = TextureHeight(ItemTex(1))/2 For n=1 To MaxLines SetBuffer TextureBuffer(ItemTex(n)) ClsColor 0,0,0 : Cls Color 255,255,255 Text x,y,"TEST LINE "+n,1,1 EntityTexture Item(n),ItemTex(n) Next End Function Function CurveAngle#(current#,desired#,smooth#) Return current + (desired-current)/smooth End Function
Thanx for your help!