StaticGeometry + physics
Posted: Thu Aug 15, 2013 6:51 pm
After a quick test I can confirm absence of physics support in static geometry; collision is removed once entities are added to the stat. geom. pool. This is a major show stopper and unless there is a way to do it static geometry in it's current state is quite useless. Please test the code to confirm it's not an issue with my code.
Code: Select all
; Conclusion StaticGeom does not support physics
#CamSpeed =5.5
#MouseSpeed =0.2
#ResX =800
#ResY =600
#Title ="PB3D (Hold space to add random physics entities)"
If InitEngine3D(#PB_Engine3D_DebugOutput)
InitMouse()
InitKeyboard()
InitSprite()
If OpenWindow(0,0,0,#ResX,#ResY,#Title,#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0))
Add3DArchive(".",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\Textures\",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\GUI",#PB_3DArchive_FileSystem)
Parse3DScripts()
WorldShadows(#PB_Shadow_Additive)
CreateCamera(0,0,0,WindowWidth(0),WindowHeight(0))
CameraBackColor(0,RGB(0, 123, 191))
MoveCamera(0,10,30,160)
CreateLight(0,RGB(255, 255, 95),-50,50,100)
OpenWindow3D(0,10,10,220,100,"Engine Stats")
TextGadget3D(0,10,10,200,30,"")
TextGadget3D(1,10,40,200,30,"")
ShowGUI(255,0)
CreateMaterial(0,TextureID(LoadTexture(#PB_Any,"ground_diffuse.png")))
CreateCube(0,1)
CreateSphere(1,1)
CreateEntity(0,MeshID(0),MaterialID(0))
CreateEntity(1,MeshID(0),MaterialID(0))
ScaleEntity(0,100,10,100)
ScaleEntity(1,10,10,100)
RotateEntity(0,0,0,-20)
MoveEntity(1,50,-5,0)
EntityPhysicBody(0,#PB_Entity_StaticBody,1,0,5.0)
EntityPhysicBody(1,#PB_Entity_StaticBody,1,5,0.5)
If MessageRequester("PB3D","Enable Static Geometry?",#PB_MessageRequester_YesNo)=#PB_MessageRequester_Yes
CreateStaticGeometry(0,200,200,200,#True)
AddStaticGeometryEntity(0,EntityID(0),0,0,0,100,10,100,0,0,20)
AddStaticGeometryEntity(0,EntityID(1),50,-5,0,10,10,100)
BuildStaticGeometry(0)
FreeEntity(0)
FreeEntity(1)
SetWindowTitle(0,#Title+" STATIC GEOMETRY IS ON!")
EndIf
Define.f CamMX,CamMY,MouseLX,MouseLY
Repeat
ExamineKeyboard()
ExamineMouse()
MouseLX=-(MouseDeltaX()*#MouseSpeed)
MouseLY=-(MouseDeltaY()*#MouseSpeed)
If KeyboardPushed(#PB_Key_Left)
CamMX=-#CamSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
CamMX=#CamSpeed
Else
CamMX=0
EndIf
If KeyboardPushed(#PB_Key_Up)
CamMY=-#CamSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
CamMY=#CamSpeed
Else
CamMY=0
EndIf
If KeyboardPushed(#PB_Key_Space)
phys=Random(1)
ent=CreateEntity(#PB_Any,MeshID(phys),MaterialID(0),Random(100)-50,100,Random(100)-50)
ScaleEntity(ent,5,5,5)
If phys=0
EntityPhysicBody(ent,#PB_Entity_BoxBody)
Else
EntityPhysicBody(ent,#PB_Entity_SphereBody)
EndIf
EndIf
RotateCamera(0,MouseLY,MouseLX,0,#PB_Relative)
MoveCamera(0,CamMX,0,CamMY)
RenderWorld()
FlipBuffers()
SetGadgetText3D(0,"FPS: "+StrF(Engine3DFrameRate(#PB_Engine3D_Current)))
SetGadgetText3D(1,"Tris: "+StrF(CountRenderedTriangles()))
Until WindowEvent()=#PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
EndIf
EndIf
EndIf
