there are a Guide sphere for the camera to follow using CameraFollow function. press space to toggle rotation, when you stop rotation press arrows and move mouse to go inside the objects collection cloud, and when we press space again the camera position are for what written in CameraFollow line.
Q1: how to stay inside the cloud and to rotate and stop from any position while the camera follow the Guide sphere ?
Q2: i have noticed some small kicks when the objects collection rotate, and ironically those kicks disappear when we choose more objects number such as 10000 Line 46, or is this an optical illusion !!.
use real models such as fish and instead of cubes or balls, in a test i have used a fish to plot the points near the ground.

some of the code are borrowed from Olby example somewhere
Code: Select all
#CamSpeed =6
#MouseSpeed =0.2
#sphere = 3
Global stop = 1
If InitEngine3D(#PB_Engine3D_DebugOutput)
InitMouse()
InitKeyboard()
InitSprite()
ExamineDesktops()
If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "press space to toggle rotation, after stop use arrow keys and mouse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
If OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 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()
CreateCamera(0,0,0,100,100)
CameraBackColor(0,RGB(0, 0, 0))
MoveCamera(0,10,100,160)
CreateLight(0,RGB(255, 255, 95),-50,50,100)
;;============================================
OpenWindow3D(0,0,0,100,60,"Engine Stats")
TextGadget3D(0,2,0,70,30,"")
TextGadget3D(1,2,0,40,60,"")
ShowGUI(255,0)
;;=============================================
CreateMaterial(0,TextureID(LoadTexture(#PB_Any,"ground_diffuse.png")))
CreateMaterial(1,TextureID(LoadTexture(#PB_Any,"Geebee2.bmp")))
CreateMaterial(2,TextureID(LoadTexture(#PB_Any,"nskingr.jpg")))
CreateCube(0,0.3)
CreateSphere(1,0.3)
CreateSphere(2,0.6)
CreateEntity(0,MeshID(0),MaterialID(0))
CreateEntity(1,MeshID(1),MaterialID(1))
CreateEntity(2,MeshID(2),MaterialID(2))
CreateStaticGeometry(23,10000,10000,10000,#False)
For i=1 To 4000
id = Random(1)
;id = 0
If id = 0
AddStaticGeometryEntity(23,EntityID(0),Random(100)-50,Random(100)-50,Random(100)-50,4,4,4)
Else
y = Random(100)-50
If y < -30: id = 2
Else
id = 1
EndIf
AddStaticGeometryEntity(23,EntityID(id),Random(100)-50,y,Random(100)-50,2,2,2)
EndIf
Next
BuildStaticGeometry(23)
FreeEntity(0)
FreeEntity(1)
FreeEntity(2)
CreateSphere(#sphere, 5) ;the guide of the CameraFollow
CreateEntity(#sphere, MeshID(#sphere), MaterialID(1))
MoveEntity(#sphere,-34,-30,0)
CreateLight(0,RGB(255,255,255),-50,40,30)
AmbientColor(RGB(100,100,100))
Define.f CamMX,CamMY,MouseLX,MouseLY
Repeat
ExamineKeyboard()
ExamineMouse()
If KeyboardReleased(#PB_Key_Space)
stop !1
EndIf
If stop = 0
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
Else
;CameraFollow(#Camera, ObjectID, Angle, Height, Distance, RotationPercent, PositionPercent [, Mode])
CameraFollow(0, EntityID(#sphere) , 90, 100,170, 1, 1 )
EndIf
RotateCamera(0,MouseLY,MouseLX,0,#PB_Relative)
MoveCamera(0,CamMX,0,CamMY)
MoveEntity(#sphere, 0, 0, -0.7, #PB_Local)
RotateEntity(#sphere, 0, -1, 0, #PB_Relative)
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
EndIfhttp://www.ogre3d.org/forums/viewtopic. ... 69#p423669
it is part from a tutorial:
http://sourceforge.net/projects/so3dtools/ with a name B_1_Cubes.
in fact it display too slow on my machine, so i have tested to display 300000 cubes using PureBasic static Geometry and it is acceptable, it takes about 15 seconds to display it.
so i have used only cubes to draw 300000 cube, the FPS is about 16, please post your results and how much time it takes to diplay it in the following code
also any other variations . thanks
Code: Select all
#CamSpeed =6
#MouseSpeed =0.2
#sphere = 3
Global stop = 1
If InitEngine3D(#PB_Engine3D_DebugOutput)
InitMouse()
InitKeyboard()
InitSprite()
ExamineDesktops()
If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "press space to toggle rotation, after stop use arrow keys and mouse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
If OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 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()
CreateCamera(0,0,0,100,100)
CameraBackColor(0,RGB(0, 0, 0))
MoveCamera(0,10,100,160)
CreateLight(0,RGB(255, 255, 95),-50,50,100)
;;============================================
OpenWindow3D(0,0,0,100,60,"Engine Stats")
TextGadget3D(0,2,0,70,30,"")
TextGadget3D(1,2,0,40,60,"")
ShowGUI(255,0)
;;=============================================
CreateMaterial(0,TextureID(LoadTexture(#PB_Any,"ground_diffuse.png")))
CreateMaterial(1,TextureID(LoadTexture(#PB_Any,"Geebee2.bmp")))
CreateMaterial(2,TextureID(LoadTexture(#PB_Any,"nskingr.jpg")))
CreateCube(0,0.3)
;CreateSphere(1,0.3)
;CreateSphere(2,0.6)
CreateEntity(0,MeshID(0),MaterialID(0))
CreateStaticGeometry(23,10000,10000,10000,#False)
For i=1 To 300000
AddStaticGeometryEntity(23,EntityID(0),Random(100)-50,Random(100)-50,Random(100)-50,4,4,4)
Next
BuildStaticGeometry(23)
FreeEntity(0)
CreateSphere(#sphere, 5) ;the guide of the CameraFollow
CreateEntity(#sphere, MeshID(#sphere), MaterialID(1))
MoveEntity(#sphere,-34,-30,0)
CreateLight(0,RGB(255,255,255),-50,40,30)
AmbientColor(RGB(100,100,100))
Define.f CamMX,CamMY,MouseLX,MouseLY
Repeat
ExamineKeyboard()
ExamineMouse()
If KeyboardReleased(#PB_Key_Space)
stop !1
EndIf
If stop = 0
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
Else
;CameraFollow(#Camera, ObjectID, Angle, Height, Distance, RotationPercent, PositionPercent [, Mode])
CameraFollow(0, EntityID(#sphere) , 90, 100,170, 1, 1 )
EndIf
RotateCamera(0,MouseLY,MouseLX,0,#PB_Relative)
MoveCamera(0,CamMX,0,CamMY)
MoveEntity(#sphere, 0, 0, -0.7, #PB_Local)
RotateEntity(#sphere, 0, -1, 0, #PB_Relative)
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


