File Examples/3D/Entity.pb
Insert
Code: Select all
RotateEntity(0, 0, 0.1, 0, #PB_Relative)
MoveEntity(0, 0, 0, -0.1, #PB_Relative)
Code: Select all
RotateEntity(0, 0, 0.1, 0, #PB_Relative)
MoveEntity(0, 0, 0, -0.1, #PB_Relative)
About what ?Thade wrote:Is that as it should be?
// HACK To display bones
// This won't work if the entity is not centered at the origin
// TODO work out a way To allow bones To be rendered when Entity Not centered
Code: Select all
#CameraSpeed = 1
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY, RollZ
Declare DisplayBone()
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts" , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Models" , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Packs/skybox.zip", #PB_3DArchive_Zip)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
LoadMesh(0, "robot.mesh")
CreateCube(1, 0.5)
CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
MaterialShadingMode(0, #PB_Material_Wireframe)
GetScriptMaterial(1, "Color/Red")
MaterialSelfIlluminationColor(1, RGB(255, 255, 55))
CreateEntity(0, MeshID(0), MaterialID(0))
StartEntityAnimation(0, "Walk")
For i = 1 To 18
CreateEntity(i, MeshID(1), MaterialID(1))
Next i
SkyBox("stevecube.jpg")
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 0, 40, 150)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateEntity(0, 0, 1, 0, #PB_Relative)
MoveEntity(0, 0.5, 0, 0.0, #PB_Local)
DisplayBone()
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
Procedure DisplayBone()
For i=1 To 18
Bone$ = "Joint"+Str(i)
EntityLocate(i, EntityBoneX(0, Bone$), EntityBoneY(0, Bone$), EntityBoneZ(0, Bone$))
Next
EndProcedure