you can make more than one static geo just add another line CreateStaticGeometry(??,...)
here the example staticGeometry.pb from the examples\3D
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
CreateStaticGeometry(1, 1000, 1000, 1000, #True)
regarding picking a building by a mouse, thats i think not possible.
but in general picking and selecting object is possible , there is an example somewhere in the 3d examples.
regarding the physics with static geo there are some issues look this thread
http://www.purebasic.fr/english/viewtop ... 36&t=56002
there is physics possible with static geo if we haven't freed the entities
and as PMV said "StaticGeometry() is from OGRE3D .. for the render-process .. The complete physic stuff is not OGRE, as it is called bullet"
you can use a model made by modeling software and scale it in xyz if you want good collision physics : look my example about stonehenge
here is the official StaticGeometry.pb with 2 worlds of static Geometry.
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Static Geometry
;
; (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 10, Yaw.f, Pitch.f
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
WorldShadows(#PB_Shadow_Additive)
AmbientColor(0)
; node for Light and Billboard (Sun)
CreateNode(0, 0, 3000, 0)
;Create light
CreateLight(0, RGB(90, 105, 132), 0, 3000, 0)
AttachNodeObject(0, LightID(0))
; Create flare
GetScriptMaterial(0, "Scene/burst")
CreateBillboardGroup(0, MaterialID(0), 2048, 2048)
AddBillboard(0, 0, 0, 3000, 0)
AttachNodeObject(0, BillboardGroupID(0))
; Static geometry
;
; Create Entity
CreateCube(0, 1)
CreateEntity(0, MeshID(0), #PB_Material_None)
; Create Static geometry
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
For z = -10 To 10
For x = -10 To 10
AddStaticGeometryEntity(0, EntityID(0), x * 1000, 0, z * 1000, 1000, 10, 1000, 0, 0, 0)
Height.f = 200 + Random(800)
AddStaticGeometryEntity(0, EntityID(0), x * 1000, Height/2, z * 1000, 200, Height, 200, 0, Random(360), 0)
Next
Next
; Build the static geometry
BuildStaticGeometry(0)
CreateStaticGeometry(1, 1000, 1000, 1000, #True)
For z = 10 To 30
For x = 10 To 30
AddStaticGeometryEntity(1, EntityID(0), x * 1000, 10, z * 1000, 1000, 10, 1000, 0, 0, 0)
Height.f = 200 + Random(800)
AddStaticGeometryEntity(1, EntityID(0), x * 1000, Height/2, z * 1000, 200, Height, 200, 0, Random(360), 0)
Next
Next
; Build the static geometry
BuildStaticGeometry(1)
FreeEntity(0)
; Camera
;
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 2000, 2000, 2000, #PB_Absolute)
;CameraLookAt(0, 0, 0, 0)
RotateCamera(0,0,-110,0,#PB_Relative)
CameraRange (0, 2, 5000)
CameraFOV (0, 90)
CameraBackColor(0, RGB(90, 105, 132))
Repeat
Screen3DEvents()
If ExamineMouse()
Yaw = -MouseDeltaX() * 0.05
Pitch = -MouseDeltaY() * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
MoveCamera(0, 0, 0, -2 * Boost)
ElseIf KeyboardPushed(#PB_Key_Down)
MoveCamera(0, 0, 0, 2 * Boost)
EndIf
If KeyboardPushed(#PB_Key_Left)
MoveCamera(0, -2 * Boost, 0, 0)
ElseIf KeyboardPushed(#PB_Key_Right)
MoveCamera(0, 2 * Boost, 0, 0)
EndIf
EndIf
; Sun
nx = 10000 * Cos(ElapsedMilliseconds() / 2500)
nz = 10000 * Sin(ElapsedMilliseconds() / 2500)
MoveNode(0, nx, 3000, nz, #PB_Absolute)
RotateCamera(0, Pitch, Yaw, 0, #PB_Relative)
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