Plotting data with Static Geometry, and display 300000 cubes

Everything related to 3D programming
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Plotting data with Static Geometry, and display 300000 cubes

Post by applePi »

the first code are displaying 4000 random numbers with spheres and cubes, note that spheres are too much hard for the computer than the cubes.
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.
Image
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
EndIf
in this link a geometry shader cubes which display 300000 animated cubes,
http://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
Last edited by applePi on Tue Oct 08, 2013 6:09 pm, edited 1 time in total.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Plotting data with Static Geometry, and display 300000 c

Post by Samuel »

Q1: how to stay inside the cloud and to rotate and stop from any position while the camera follow the Guide sphere ?
If I get some free time later I'll try fiddling with it.
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 !!.
I didn't notice anything, but maybe I'm not looking close enough.
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
It takes about 12 seconds to load and the FPS stays at about 30.

Windows 7 x64
[CPU] AMD Phenom II x4 965 Processor 3.40GHz
[RAM] 8.00 GB
[GPU] ati firegl v7600
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Plotting data with Static Geometry, and display 300000 c

Post by IdeasVacuum »

Impressive stuff applePi. Load time: 10+ seconds; FPS: 9

[PB5.20 WinXP x86]
[CPU] Intel Core 2 Duo 2133Mhz
[RAM] 4GB
[GPU] NVIDIA GeForce 7900 GT
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Plotting data with Static Geometry, and display 300000 c

Post by LuCiFeR[SD] »

Haha, you know I was worried for a second... I was like "What the hell is going on here? 5 FPS!"... Then I realised that the font from CEGUI was being scaled up, but the 3D window was a constant size so was clipping a lot of the text off :P

so here are my results...
Engine Stats (Image - Google Drive)

my hardware is pretty old and modest (core2 6400@2.13Ghz 4GB ram and a 1GB Nvidia GeForce GTS 450.

You have been writing a lot of cool stuff of late applePi, I wish I could get my head around this 3D stuff as well as you have :) Thanks very much for all of these really cool examples you have been providing. I am finding them all very interesting :)

Edit:

Just wanted to throw my modified code into the mix. I am hoping the timer is accurate enough to work out the loading times :)

Code: Select all

EnableExplicit
;- Added by LuCiFeR[SD]
;
Define.i TimerStart,TimerEnd,stop,Loop,id,y,Exit,Event,Event3D
TimerStart=ElapsedMilliseconds()
;

#CamSpeed      =6
#MouseSpeed   =0.2
#sphere = 3
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,#PB_Screen_WaitSynchronization)
      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()
      
      ;- Changed by LuCiFeR[SD]
      ;
      ; Original line was : CreateCamera(0,0,0,WindowWidth(0),WindowHeight(0))
      CreateCamera(0,0,0,100,100) ;-NOTE: Seems to take a percentage value for width and height... Thanks IdeasVacuum ;)
      ;
      
      CameraBackColor(0,RGB(0, 0, 0))
      MoveCamera(0,10,100,160)
      
      CreateLight(0,RGB(255, 255, 95),-50,50,100)
      
      ;- Added by LuCiFeR[SD]
      ;
      ;;============================================
      ; Changed and added a few lines here.
      ;
      OpenWindow3D(0,0,0,550,180,"Engine Stats")
      TextGadget3D(0,2,0,550,50,"")
      TextGadget3D(1,2,30,400,50,"")
      TextGadget3D(2,2,60,400,50,"")
      TextGadget3D(3,2,90,500,50,"")
      ;
      
      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 Loop=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
      
      ;- Added by LuCiFeR[SD]
      ;   
      TimerEnd=ElapsedMilliseconds()
      SetGadgetText3D(2,"Time to load: "+StrF((TimerEnd - TimerStart)/1000,2)+"sec")
      SetGadgetText3D(3,"Screen Res: "+ScreenWidth()+"*"+ScreenHeight()+"@"+ScreenDepth()+"bit")
      ;
      
      Repeat
        ExamineKeyboard()
        ExamineMouse()
        
        If KeyboardReleased(#PB_Key_Space)
          stop !1
        EndIf  
        If KeyboardReleased(#PB_Key_Escape)
          Exit=#True
        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()
        ;- Added by LuCiFeR[SD]
        ;  Added proper Window event handling.
        ;
        Repeat
          Event=WindowEvent()
          ;Event3D=WindowEvent3D()
          If Event=#PB_Event_CloseWindow
            Exit=#True
          EndIf
        Until Event=#False And Event3D=#False
        
        FlipBuffers()
        
        ;- Changed by LuCiFeR[SD]
        ;
        ;;==============================================
        SetGadgetText3D(0,"FPS: "+StrF(Engine3DFrameRate(#PB_Engine3D_Current),2)+" (Highest) "+StrF(Engine3DFrameRate(#PB_Engine3D_Maximum),2))
        SetGadgetText3D(1,"Tris: "+StrF(CountRenderedTriangles()))
        
        ;;================================================
      Until Exit=#True
    EndIf
  EndIf
EndIf

Code: Select all

EnableExplicit
;- Added by LuCiFeR[SD]
;
Define.i TimerStart,TimerEnd,stop,Loop,id,y,Exit,Event,Event3D
TimerStart=ElapsedMilliseconds()
;
#CamSpeed      =6
#MouseSpeed   =0.2
#sphere = 3
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, #PB_Screen_WaitSynchronization)
      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()
      
      
      ;- Changed by LuCiFeR[SD]
      ;
      ; Original line was : CreateCamera(0,0,0,WindowWidth(0),WindowHeight(0))
      CreateCamera(0,0,0,100,100) ;-NOTE: Seems to take a percentage value for width and height... Thanks IdeasVacuum ;)
      ;
      CameraBackColor(0,RGB(0, 0, 0))
      MoveCamera(0,10,100,160)
      
      CreateLight(0,RGB(255, 255, 95),-50,50,100)
      ;- Added by LuCiFeR[SD]
      ;
      ;;============================================
      ; Changed and added a few lines here.
      ;
      OpenWindow3D(0,0,0,550,180,"Engine Stats")
      TextGadget3D(0,2,0,550,50,"")
      TextGadget3D(1,2,30,400,50,"")
      TextGadget3D(2,2,60,400,50,"")
      TextGadget3D(3,2,90,500,50,"")
      ;
      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 Loop=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
      ;- Added by LuCiFeR[SD]
      ;   
      TimerEnd=ElapsedMilliseconds()
      SetGadgetText3D(2,"Time to load: "+StrF((TimerEnd - TimerStart)/1000,2)+"sec")
      SetGadgetText3D(3,"Screen Res: "+ScreenWidth()+"*"+ScreenHeight()+"@"+ScreenDepth()+"bit")
      ;
      
      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()
        ;- Added by LuCiFeR[SD]
        ;  Added proper Window event handling.
        ;
        Repeat
          Event=WindowEvent()
          ;Event3D=WindowEvent3D()
          If Event=#PB_Event_CloseWindow
            Exit=#True
          EndIf
        Until Event=#False And Event3D=#False
        FlipBuffers()
        
        ;- Changed by LuCiFeR[SD]
        ;
        ;;==============================================
        SetGadgetText3D(0,"FPS: "+StrF(Engine3DFrameRate(#PB_Engine3D_Current),2)+" (Highest) "+StrF(Engine3DFrameRate(#PB_Engine3D_Maximum),2))
        SetGadgetText3D(1,"Tris: "+StrF(CountRenderedTriangles()))
        ;;================================================
      Until WindowEvent()=#PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
      
    EndIf
  EndIf
EndIf
Last edited by LuCiFeR[SD] on Thu Oct 03, 2013 12:17 pm, edited 9 times in total.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Plotting data with Static Geometry, and display 300000 c

Post by applePi »

thank you guys for the feedback. so the hightest FPS: 59.58 @ 1920*1080 are from LuCiFeR[SD] , i was using Geforce 210 , so today i have replaced my old card with a little more advanced Geforce 520, and its results are worst than before it is FPS: 10 , while before it was 16. i begins to think to reinstall the older card but the newer have a quieter fan noise so there is some hesitation. i will check what is the ram kind and speed on both cards.
User avatar
tft
Enthusiast
Enthusiast
Posts: 100
Joined: Mon Dec 29, 2008 9:34 am

Re: Plotting data with Static Geometry, and display 300000 c

Post by tft »

Hi,

Full HD
360 FPS
3600648 Tris rendered.

My System
i5 3,2 GHz
GTX Titan

i am modefy the code to Display on my screen.

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, #PB_Screen_NoSynchronization    )
         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,WindowWidth(0),WindowHeight(0))
         CameraBackColor(0,RGB(0, 0, 0))
         MoveCamera(0,10,100,160)
         
         CreateLight(0,RGB(255, 255, 95),-50,50,100)
         ;;============================================
         OpenWindow3D(0,0,0,300,120,"Engine Stats")
         TextGadget3D(0,2,0,300,30,"")
         TextGadget3D(1,2,0,300,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
TFT seid 1989
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak :-)
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Plotting data with Static Geometry, and display 300000 c

Post by applePi »

thank you tft , thats too much score 360 but going to the card page http://www.nvidia.co.uk/titan-graphics-card they said ( Supercomputer technology. the Oak Ridge National Laboratory's Titan supercomputer to your next gaming experience.. ))
but its price are too high for me about £839 . but i don't know before about those graphics cards.
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Plotting data with Static Geometry, and display 300000 c

Post by DK_PETER »

Nice work ApplePi. :-)

From me: (Second example)
Fps: 60.03 (Screen can't go any higher)
Tris: 360063
Loadtime: 6 sec.

First example:
Fps 60.03
Tris: 1212379
Loadtime: hmmm very fast.

Hardware:
Gigagyte GTX 770 4 GB.
16 GB ram
Amd: Phenom X4 945

Best regards
Peter
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Plotting data with Static Geometry, and display 300000 c

Post by IdeasVacuum »

@LuCiFeR[SD]
Just wanted to throw my modified code into the mix. I am hoping the timer is accurate enough to work out the loading times
...erm, modified code is much faster:
The compiler appears to have crashed or quit unexpectedly.
It will be restarted.

Please report the conditions that caused this as a bug.
:shock:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Plotting data with Static Geometry, and display 300000 c

Post by LuCiFeR[SD] »

IdeasVacuum wrote:@LuCiFeR[SD]
Just wanted to throw my modified code into the mix. I am hoping the timer is accurate enough to work out the loading times
...erm, modified code is much faster:
The compiler appears to have crashed or quit unexpectedly.
It will be restarted.

Please report the conditions that caused this as a bug.
:shock:
Erm, erm.... what can I say... works for me?

Antivirus? Have you tried commenting out anything that I added to see if you can stop it crashing to narrow it down a little lol :)

Edited modified code above to make changes more obvious.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Plotting data with Static Geometry, and display 300000 c

Post by davido »

@applePi
I really enjoy looking at your prolific 3D output. Don't know how you do it.

I could not read the output from your second example. However, I emended it using the code LuCiFeR[SD] used in his post.
Here are the results:

PB5.20LTS 64 bit.
Windows 7 64 bit
Core i3 2x core. 3.06MHZ - No graphic card.
FPS: 8.4
TRIS: 3600644
Load time: 14 seconds.
DE AA EB
User avatar
mk-soft
Always Here
Always Here
Posts: 6405
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Plotting data with Static Geometry, and display 300000 c

Post by mk-soft »

Crash by ESC
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!

Program: C:\...

R6016

- not enough space for thread data


---------------------------
OK
---------------------------
FPS 7,92
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Plotting data with Static Geometry, and display 300000 c

Post by PMV »

125-130 FPS by 3,6 Million triangles. Loading took less then 10s.

AMD Phenom II @3,2 GHZ (3 Cores)
Radeon HD 7870 OC
4 GB DDR2-SDRAM
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Plotting data with Static Geometry, and display 300000 c

Post by IdeasVacuum »

The codes above seem to be using CreateCamera incorrectly?
Code:

Code: Select all

CreateCamera(0,0,0,WindowWidth(0),WindowHeight(0))
CreateCamera(0,0,0,ScreenWidth(),ScreenHeight())
Help:
CreateCamera(#Camera, x, y, Width, Height [, VisibilityMask])
x, y, Width and Height are a % of the width of the screen, not a literal distance.
See: http://www.purebasic.fr/english/viewtop ... 37&t=56793
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Plotting data with Static Geometry, and display 300000 c

Post by applePi »

i can't reproduce the crash , it worked okay on my windows xp with the new card Geforce GT 520, i force my screen to be of resolution 640 X 480 using xp_quickres http://www.dougknox.com/xp/utils/xp_quickres.htm my eyes feel better with the low resolution, and the utility works also with windows 7 even its name is xp_quickres.
could it be the high resolution 1920*1080 sometimes used.
the example are just the StaticGeometry.pb official purebasic example with some more decorations . but StaticGeometry.pb are using IncludeFile "Screen3DRequester.pb" which i hate to use but may be suitable for a wider users and computers.
by the way i have downloaded GPU-Z.0.7.3 http://www.techpowerup.com/190682/techp ... 0-7-3.html
and it is great to show the spec. of the graphics cards.
Post Reply