Page 2 of 2

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

Posted: Thu Oct 03, 2013 12:13 pm
by LuCiFeR[SD]
IdeasVacuum wrote: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, I think you have hit the nail on the head with that.... it does indeed seem to take a percentage value! and that little diagram does speak a thousand words indeed :) I'll adapt my version of the code above (again!!!) hahaha :)

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

Posted: Mon Oct 07, 2013 6:36 am
by applePi
a friend said are you crazy ?? the cubes collection are rotating and not the camera . i said that this is because there is no reference point on the world. so added a stationary skybox picture we can be sure that we (ie the camera) who are rotating around the cubes cloud and in fact following the stanalone big sphere which are rotating inside the cube and while we follow it it appears stationary.

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 Q/A  to zoom. 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)
         Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/desert.zip", #PB_3DArchive_Zip)

         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  ; number of objects
           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))
   
SkyBox("desert07.jpg")                        
Define.f CamMX,CamMY,MouseLX,MouseLY, camMY2
camMY2 = 170
Global Height.f = 100
Global dist.f = -50

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
              camMY2=camMY2+camMY
            ElseIf KeyboardPushed(#PB_Key_Down)
               CamMY=#CamSpeed
            Else
               CamMY=0
            EndIf
          Else
            
            If KeyboardPushed(#PB_Key_Q)
              Height.f-1 : dist+1
              ElseIf KeyboardPushed(#PB_Key_A)
                Height.f+1: dist-1
              EndIf 
            
            ;CameraFollow(#Camera, ObjectID, Angle, Height, Distance, RotationPercent, PositionPercent [, Mode])
            CameraFollow(0, EntityID(#sphere) , 90, Height,CamMY2-dist, 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

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

Posted: Mon Oct 07, 2013 11:03 pm
by IdeasVacuum
Phew, watching that rotation for a while might make you crazy :lol: Great job ApplePi.