reseting rotation when using show/hide entity
Blitz3D Forums/Blitz3D Beginners Area/reseting rotation when using show/hide entity
| ||
Hello all: I posted this to the programming forum, but might be more appropriate here. I am sure this is a very simple question, but I have not been able to solve it, I am not a great coder. I am using show/hide entity, so only one entity is present in window at a time. I want to use the same keys to rotate whatever entity is visible, but the way I have it set up, each newly shown entity inherits the rotation values of the previous one. I cannot get the rotation values to reset when I switch from hide to showentity. Seems like a simple thing, but none of my attempts worked. I have pasted sample code below. Any help would be deeply appreciated. BTW, you can see some of my futile attempts, commented out. (The "jordan" and "karen" in the commented code are globals from previous code attempts, could be replaced with redcube, yellowcube, bluecube.) Dena ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Graphics3D 1024,768,24,2 ;HidePointer SetBuffer BackBuffer() Global camera=CreateCamera() CameraZoom camera,4 light=CreateLight() Global redcube=CreateCube() EntityColor redcube, 255,0,0 PositionEntity redcube,0,0,20 HideEntity redcube Global bluecube=CreateCube() EntityColor bluecube,0,0,255 PositionEntity bluecube,0,0,20 HideEntity bluecube Global yellowcube=CreateCube() EntityColor yellowcube,255,255,0 PositionEntity yellowcube,0,0,20 HideEntity yellowcube While Not KeyHit(1) UserControls() If KeyDown( 208 )=True Then pitch#=pitch#-1 If KeyDown( 200 )=True Then pitch#=pitch#+1 If KeyDown( 203 )=True Then yaw#=yaw#-1 If KeyDown( 205 )=True Then yaw#=yaw#+1 If KeyDown( 45 )=True Then roll#=roll#-1 If KeyDown( 44 )=True Then roll#=roll#+1 RotateEntity redcube,pitch#,yaw#,roll# RotateEntity bluecube,pitch#,yaw#,roll# RotateEntity yellowcube,pitch#,yaw#,roll# If KeyDown (19) HideEntity bluecube HideEntity yellowcube ShowEntity redcube EndIf If KeyDown (48) HideEntity redcube HideEntity yellowcube ShowEntity bluecube EndIf If KeyDown (21) HideEntity bluecube HideEntity redcube ShowEntity yellowcube EndIf ;If ShowEntity bluecube=True ; Then RotateEntity bluecube,pitch#,yaw#,roll# ; Else RotateEntity bluecube,0,0,0 ;While ShowEntity redcube = True ; RotateEntity redcube,pitch#,yaw#,roll# ; Else RotateEntity redcube,0 0 0 ;Wend UpdateWorld RenderWorld Color 128,128,128 Text 27,60, "" + CurrentTime$() Text 27,75, "" + CurrentDate$() Text 27,120,"RMB to zoom out" Text 27,135,"LMB to zoom in" Text 27,150,"r to load redcube, b to load bluecube, y to load Yellowcube" Text 27,180,"want rotations to reset back to 0,0,0 when I load different color cubes" Flip Wend End ;Function update_headsWMouse() ; ; move_y# = (center_x - MouseX()) / smoothness ; move_x# = (center_y - MouseY()) / smoothnessYaw ; ; RotateEntity jordan , EntityPitch(jordan)+move_x , EntityYaw(jordan)+move_y , EntityRoll(jordan) ; RotateEntity karen , EntityPitch(karen)+move_x , EntityYaw(karen)+move_y , EntityRoll(karen) ; ; MoveMouse center_x,center_y ; ;End Function ; ;;Function update_headsWKeys() ; If KeyDown( 208 )=True Then pitch#=pitch#-1 ; If KeyDown( 200 )=True Then pitch#=pitch#+1 ; If KeyDown( 203 )=True Then yaw#=yaw#-1 ; If KeyDown( 205 )=True Then yaw#=yaw#+1 ; If KeyDown( 45 )=True Then roll#=roll#-1 ; If KeyDown( 44 )=True Then roll#=roll#+1 ; ;; Rotate cone using rotation values ;RotateEntity karen,pitch#,yaw#,roll# ;RotateEntity jordan,pitch#,yaw#,roll# ; ;End Function Function UserControls() If MouseDown(1) MoveEntity camera,0,0,.3 End If If MouseDown(2) MoveEntity camera,0,0,-.3 End If ;If MouseDown(3) ; MoveEntity camera,0,3,0 ;End If End Function ;Function turnKaren() ;If KeyDown( 208 )=True Then pitch#=pitch#-1 ; If KeyDown( 200 )=True Then pitch#=pitch#+1 ; If KeyDown( 203 )=True Then yaw#=yaw#-1 ; If KeyDown( 205 )=True Then yaw#=yaw#+1 ; If KeyDown( 45 )=True Then roll#=roll#-1 ; If KeyDown( 44 )=True Then roll#=roll#+1 ; ; ;RotateEntity karen,pitch#,yaw#,roll# ; ;RotateEntity jordan,pitch#,yaw#,roll# ;End Function ;Function hideHead() ; If KeyDown (57) ; CopyEntity jordan ; And update_jordan() ;EndIf ;End Function ;Function update_head() ; ; move_y# = (center_x - MouseX()) / smoothness ; move_x# = (center_y - MouseY()) / smoothnessYaw ; ; If HideEntity jordan ; RotateEntity karen , EntityPitch(karen)+move_x , EntityYaw(karen)+move_y , EntityRoll(karen) ; End If ; ; If HideEntity karen ; RotateEntity jordan , EntityPitch(jordan)+move_x , EntityYaw(jordan)+move_y , EntityRoll(jordan) ; End If ; ; MoveMouse center_x,center_y ; ;End Function ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| ||
dena I answered in the other thread (Blitz Programming). Please don't "crosspost" (post the same topic in several Forum sections) if possible, thanks. |
| ||
okay, thanks, and sorry. |
| ||
np |