How is NodeFixedYawAxis() working?
Posted: Wed Oct 02, 2013 5:15 pm
Hello friends,
I tried many variants with the code below, all variants of vectors. But it´s not working at all.
This is a code of a user from the german PB-Forum:

I tried many variants with the code below, all variants of vectors. But it´s not working at all.
Code: Select all
NodeFixedYawAxis(Node, #True, 0, 0, 0)Please try it and help meEnableExplicit
If InitEngine3D()
InitSprite()
InitMouse()
InitKeyboard()
Else
MessageRequester("Error", "Can Not init 3D engine !")
End
EndIf
Define.i TexFloor, MatFloor, MshFloor, EntFloor, MshCube, EntCube, Camera, Node, MouseX, MouseY, nodemode, quit, DebugFont, DebugSprite
If OpenWindow(0, 0, 0, 1024, 768, "3D Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If Not OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0))
MessageRequester("Error", "Can not open windowed screen !")
End
EndIf
Else
MessageRequester("Error", "Can not open window !")
End
EndIf
TexFloor = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(TexFloor))
Box( 0, 0, 128, 128, RGB(225,225,225))
Box(63, 0, 64, 64, RGB( 0, 0,128))
Box( 0,63, 64, 64, RGB( 0, 0,128))
StopDrawing()
MatFloor = CreateMaterial(#PB_Any, TextureID(TexFloor))
SetMaterialColor(MatFloor, #PB_Material_AmbientColor, RGB(175, 238, 238))
MshFloor = CreatePlane(#PB_Any, 1000, 1000, 1, 1, 10, 10)
MshCube = CreateCube(#PB_Any, 100)
EntFloor = CreateEntity(#PB_Any, MeshID(MshFloor), MaterialID(MatFloor), 0, 0, 0)
EntCube = CreateEntity(#PB_Any, MeshID(MshCube), MaterialID(MatFloor), 0, 100, -750)
RotateEntity(EntCube, 45, 45, 0)
Node = CreateNode(#PB_Any, 0, 64, 0)
;NodeFixedYawAxis(Node, #True, 0, 0, 0)
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(Camera, 0, 64, 0)
AmbientColor(RGB(0,0,128))
DebugSprite = CreateSprite(#PB_Any, 500, 100)
DebugFont = LoadFont(#PB_Any, "Courier New", 11)
Repeat
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_F1)
If nodemode
nodemode = #False
DetachNodeObject(Node, CameraID(Camera))
Else
nodemode = #True
AttachNodeObject(Node, CameraID(Camera))
EndIf
ElseIf KeyboardReleased(#PB_Key_Escape)
quit = 1
EndIf
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX() / 10
MouseY = -MouseDeltaY() / 10
EndIf
If nodemode
RotateNode(Node, MouseY, MouseX, 0, #PB_Relative)
Else
RotateCamera(Camera, MouseY, MouseX, 0, #PB_Relative)
EndIf
RenderWorld()
StartDrawing(SpriteOutput(DebugSprite))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(DebugFont))
FrontColor(RGB(255,255,0))
Box(0, 0, SpriteWidth(DebugSprite), SpriteHeight(DebugSprite), 0)
DrawText( 5, 5, "Direction/Node : x=" + StrF(NodePitch(Node),1) + ", y=" + StrF(NodeYaw(Node),1) + ", z=" + StrF(NodeRoll(Node),1))
DrawText( 5,25, "Direction/Camera: x=" + StrF(CameraPitch(Camera),1) + ", y=" + StrF(CameraYaw(Camera),1) + ", z=" + StrF(CameraRoll(Camera),1))
If nodemode
DrawText(5,45, "Node Mode - hit F1 to switch")
Else
DrawText(5,45, "Camera Mode - hit F1 to switch")
EndIf
StopDrawing()
DisplayTransparentSprite(DebugSprite, 0, 0)
FlipBuffers()
Until quit = 1
End