Angles des entity
Publié : mer. 24/oct./2012 18:44
Hello!
Ca fait un petit moment que j'ai pas posté ici... même si je le suis régulièrement.
J'ai un petit soucis avec les entités et leur angles, on peut recupérer le pitch/yaw/roll mais ils ne servent pas à grand chose si on ne peut pas les ré-utiliser. Je m'explique :
Si je fais un RotateEntity(id, 32, 54, 86)
Puis je recupère EntityPitch(id), EntityYaw(id), EntityRoll(id)
Et enfin ré-applique ces angles, je n'ai pas du tout la même orientation.
Je pense que les angle donné a RotateEntity et les angles retournés par EntityPitch()... sont différent?
Comment récupérer les angles passé à un rotate entity ducoup? (pour par exemple les sauvegarder et les re-utiliser plustard) sachant que je n'ai pas forcement la main mise dessus (avec la physique je ne peux pas savoir ces angles)
Un petit code de démo : Bouger les 3 premiers trackBar qui font un RotateEntity du premier cube, le deuxieme cube est Rotate avec les angles retourné des Pitch/Yaw/Roll du premier
Merci pour votre aide 
Ca fait un petit moment que j'ai pas posté ici... même si je le suis régulièrement.
J'ai un petit soucis avec les entités et leur angles, on peut recupérer le pitch/yaw/roll mais ils ne servent pas à grand chose si on ne peut pas les ré-utiliser. Je m'explique :
Si je fais un RotateEntity(id, 32, 54, 86)
Puis je recupère EntityPitch(id), EntityYaw(id), EntityRoll(id)
Et enfin ré-applique ces angles, je n'ai pas du tout la même orientation.
Je pense que les angle donné a RotateEntity et les angles retournés par EntityPitch()... sont différent?
Comment récupérer les angles passé à un rotate entity ducoup? (pour par exemple les sauvegarder et les re-utiliser plustard) sachant que je n'ai pas forcement la main mise dessus (avec la physique je ne peux pas savoir ces angles)
Un petit code de démo : Bouger les 3 premiers trackBar qui font un RotateEntity du premier cube, le deuxieme cube est Rotate avec les angles retourné des Pitch/Yaw/Roll du premier
Code : Tout sélectionner
InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 1280, 1000, "toast", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 1280, 720, 0, 0, 0)
TrackBarGadget(0, 10, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(1, 15, 835, 30, 20, "0")
TrackBarGadget(2, 50, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(3, 55, 835, 30, 20, "0")
TrackBarGadget(4, 90, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(5, 95, 835, 30, 20, "0")
TrackBarGadget(10, 210, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(11, 215, 835, 30, 20, "0")
TrackBarGadget(12, 250, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(13, 255, 835, 30, 20, "0")
TrackBarGadget(14, 290, 730, 30, 100, 0, 360, #PB_TrackBar_Vertical)
TextGadget(15, 295, 835, 30, 20, "0")
WorldDebug(#PB_World_DebugEntity)
AmbientColor(RGB(128, 128, 128))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 50, 50, 100)
CameraLookAt(0, 0, 0, 0)
CreateLight(0, #White, 10, 20, 0)
CreateTexture(0, 1, 1)
StartDrawing(TextureOutput(0)) : Plot(0, 0, #Yellow) : StopDrawing()
CreateMaterial(0, TextureID(0))
CreateTexture(1, 1, 1)
StartDrawing(TextureOutput(1)) : Plot(0, 0, #Red) : StopDrawing()
CreateMaterial(1, TextureID(1))
CreateTexture(2, 1, 1)
StartDrawing(TextureOutput(2)) : Plot(0, 0, #Green) : StopDrawing()
CreateMaterial(2, TextureID(2))
CreateTexture(3, 1, 1)
StartDrawing(TextureOutput(3)) : Plot(0, 0, #Blue) : StopDrawing()
CreateMaterial(3, TextureID(3))
CreateCube(1, 1)
CreateEntity(1, MeshID(1), MaterialID(0))
ScaleEntity(1, 10, 10, 10)
CreateEntity(2, MeshID(1), MaterialID(0), 20, 0, 0)
ScaleEntity(2, 10, 10, 10)
CreateLine3D(5, -500, 0, 0, #Red, 500, 0, 0, #Red)
CreateLine3D(6, 0, -500, 0, #Green, 0, 500, 0, #Green)
CreateLine3D(7, 0, 0, -500, #Blue, 0, 0, 500, #Blue)
currentTime = ElapsedMilliseconds()
Repeat
lastTime = currentTime
currentTime = ElapsedMilliseconds()
deltaTime = currentTime - lastTime
Select WindowEvent()
Case #PB_Event_CloseWindow
quit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case 0
SetGadgetText(1, Str(GetGadgetState(0)))
RotateEntity(1, GetGadgetState(0), GetGadgetState(2), GetGadgetState(4), #PB_Absolute)
RotateEntity(2, EntityPitch(1), EntityYaw(1), EntityRoll(1))
SetGadgetState(10, EntityPitch(1) + 180)
SetGadgetText(11, Str(GetGadgetState(10) - 180))
SetGadgetState(12, EntityYaw(1) + 180)
SetGadgetText(13, Str(GetGadgetState(12) - 180))
SetGadgetState(14, EntityRoll(1) + 180)
SetGadgetText(15, Str(GetGadgetState(14) - 180))
Case 2
SetGadgetText(3, Str(GetGadgetState(2)))
RotateEntity(1, GetGadgetState(0), GetGadgetState(2), GetGadgetState(4), #PB_Absolute)
RotateEntity(2, EntityPitch(1), EntityYaw(1), EntityRoll(1))
SetGadgetState(10, EntityPitch(1) + 180)
SetGadgetText(11, Str(GetGadgetState(10) - 180))
SetGadgetState(12, EntityYaw(1) + 180)
SetGadgetText(13, Str(GetGadgetState(12) - 180))
SetGadgetState(14, EntityRoll(1) + 180)
SetGadgetText(15, Str(GetGadgetState(14) - 180))
Case 4
SetGadgetText(5, Str(GetGadgetState(4)))
RotateEntity(1, GetGadgetState(0), GetGadgetState(2), GetGadgetState(4), #PB_Absolute)
RotateEntity(2, EntityPitch(1), EntityYaw(1), EntityRoll(1))
SetGadgetState(10, EntityPitch(1) + 180)
SetGadgetText(11, Str(GetGadgetState(10) - 180))
SetGadgetState(12, EntityYaw(1) + 180)
SetGadgetText(13, Str(GetGadgetState(12) - 180))
SetGadgetState(14, EntityRoll(1) + 180)
SetGadgetText(15, Str(GetGadgetState(14) - 180))
EndSelect
EndSelect
ClearScreen(0)
RenderWorld(deltaTime)
FlipBuffers()
Until quit = #True
