simple programming question

Blitz3D Forums/Blitz3D Beginners Area/simple programming question

timmport(Posted 2006) [#1]
I am attempting to set up a set of triggers so that when I mouse over one of them it will set a mesh object to rotate to specific angle. Instead when I mouse over these triggers they cause my mesh object to contiunously rotate untill I move the cursor off the trigger. I am somewhat new to programming in BASIC hoewever I suspect I am misssing something very simple. Here is the relavent section of my code:

;the following 3 meshes are my trigger volumes
dialTrig1=LoadMesh("plane.b3d")
PositionEntity dialTrig1,0,-2,4.3
ScaleEntity dialTrig1,.04,.5,1
EntityAlpha dialTrig1,0

dialTrig2=LoadMesh("plane.b3d")
PositionEntity dialTrig2,-.31,-2,4.3
ScaleEntity dialTrig2,.04,.5,1
EntityAlpha dialTrig2,0

dialTrig3=LoadMesh("plane.b3d")
PositionEntity dialTrig3,-.62,-2,4.3
ScaleEntity dialTrig3,.04,.5,1

EntityPickMode dialTrig1, 2
EntityPickMode dialTrig2, 2
EntityPickMode dialTrig3, 2

;this is the mesh to be rotated when the triggers
;are moused over
dial=LoadMesh("control_dial.b3d")
PositionEntity dial,-.7,-2.5,4.5

dial_yaw#=0
TurnEntity dial,0,dial_yaw#,0

Repeat

entity = CameraPick (cam, MouseX (), MouseY ())
	Select entity
		Case dialTrig1
			dial_yaw#=45		
		Case dialTrig2
			dial_yaw#=22.5
		Case dialTrig3
			dial_yaw#=0
        End Select
UpdateWorld
RenderWorld
Flip
Until KeyHit (1)
End



b32(Posted 2006) [#2]
You mean, you want them to stop when you're not pointing at a trigger ? Extend the select..case part with a 'default' case, like this:
Select entity
 Case dialTrig1
 ..
 Case dialTrig2
 ..
 Default
 dial_yaw# = 0
End Select



timmport(Posted 2006) [#3]
I want the obejct to rotate to a specific position and remain at that orientation untill activated again by a different trigger. So for example when I place the cursor over a specific trigger volume the object would orient exactly 22.5 degrees from its oiginal position and stop. As the code stands now when I mouse over the trigger the objet continuously rotates in place in 22.5 or 45 degree increments untill I move the cursor away from the trigger.


GitTech(Posted 2006) [#4]
Use RotateEntity() instead of TurnEntity()?

EDIT:

Repeat

    entity = CameraPick (cam, MouseX (), MouseY ())

    Select entity
        Case dialTrig1
            dial_yaw#=45
        Case dialTrig2
            dial_yaw#=22.5
        Case dialTrig3
            dial_yaw#=0
    End Select

    RotateEntity dial,0,dial_yaw#,0

    UpdateWorld
    RenderWorld
    Flip

Until KeyHit (1)
End



timmport(Posted 2006) [#5]
that did it exactly. Thanks!