Ähm hab mal bei mir getestet...
Sobald ich das raus nehme fällt die CPU Last von ~50% auf ~5%...
Code: Alles auswählen
;init
InitEngine3D()
InitSprite()
InitKeyboard()
;enumeration
Enumeration
#window
#camera
#sphere
#sphere_mesh
#sphere_material
#sphere_texture
#light
#plane_mesh
#plane
#plane_material
#plane_texture
EndEnumeration
;window
OpenWindow(#window,0,0,800,600,"")
OpenWindowedScreen(WindowID(#window),0,0,800,600)
;SetFrameRate(30)
;enable
EnableWorldCollisions(1)
EnableWorldPhysics(1)
;sphere
CreateSphere(#sphere_mesh,4)
CreateTexture(#sphere_texture,2,2)
StartDrawing(TextureOutput(#sphere_texture))
Box(0,0,2,2,RGB(255,0,0))
StopDrawing()
CreateMaterial(#sphere_material,TextureID(#sphere_texture))
CreateEntity(#sphere,MeshID(#sphere_mesh),MaterialID(#sphere_material),0,5,0)
EntityPhysicBody(#sphere,#PB_Entity_SphereBody)
;plane
CreatePlane(#plane_mesh,30,30,1,1,1,1)
;Add3DArchive("C:\Dokumente und Einstellungen\Gabriel\Desktop",#PB_3DArchive_FileSystem)
;LoadTexture(#plane_texture,"test.jpg")
CreateTexture(#plane_texture,2,2)
StartDrawing(TextureOutput(#plane_texture))
Box(0,0,2,2,RGB(255,255,255))
StopDrawing()
CreateMaterial(#plane_material,TextureID(#plane_texture))
CreateEntity(#plane,MeshID(#plane_mesh),MaterialID(#plane_material),0,0,0)
EntityPhysicBody(#plane,#PB_Entity_StaticBody)
;light
CreateLight(#light,RGB(255,255,0),45,100,0)
;camera
rotateX = -45
rotateY = 0
rotateZ = 0
moveCameraX = 0
moveCameraY = 0
moveCameraZ = 0
CreateCamera(#camera,0,0,100,100)
MoveCamera(#camera,0,40,40)
WorldShadows(#PB_Shadow_Modulative )
FrameTime = 1000/30 ; 1000ms / 30Frames
;loop
Repeat
StartTime = ElapsedMilliseconds() ; ermittelt den aktuellen Wert
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Right)
ApplyEntityImpulse(#sphere,0.5,0,0)
ElseIf KeyboardPushed(#PB_Key_Left)
ApplyEntityImpulse(#sphere,-0.5,0,0)
EndIf
If KeyboardPushed(#PB_Key_Up)
ApplyEntityImpulse(#sphere,0,0,-0.5)
ElseIf KeyboardPushed(#PB_Key_Down)
ApplyEntityImpulse(#sphere,0,0,0.5)
EndIf
If KeyboardPushed(#PB_Key_Pad8)
rotateX -1
ElseIf KeyboardPushed(#PB_Key_Pad2)
rotateX +1
EndIf
If KeyboardPushed(#PB_Key_Pad6)
rotateY -1
ElseIf KeyboardPushed(#PB_Key_Pad4)
rotateY +1
EndIf
If KeyboardPushed(#PB_Key_Pad9)
rotateZ -1
ElseIf KeyboardPushed(#PB_Key_Pad7)
rotateZ +1
EndIf
If KeyboardPushed(#PB_Key_A)
moveCameraX -1
ElseIf KeyboardPushed(#PB_Key_D)
moveCameraX +1
EndIf
If KeyboardPushed(#PB_Key_Q)
moveCameraY -1
ElseIf KeyboardPushed(#PB_Key_E)
moveCameraY +1
EndIf
If KeyboardPushed(#PB_Key_W)
moveCameraZ -1
ElseIf KeyboardPushed(#PB_Key_S)
moveCameraZ +1
EndIf
RotateCamera(#camera,rotateX,rotateY,rotateZ)
MoveCamera(#camera,moveCameraX,moveCameraY,moveCameraZ)
moveCameraX = 0
moveCameraY = 0
moveCameraZ = 0
RenderWorld()
FlipBuffers()
ElapsedTime = ElapsedMilliseconds()-StartTime ; der 'ElapsedTime' Wert sollte ca. 1000 Millisekunden betragen
If ElapsedTime < FrameTime
Delay(FrameTime-ElapsedTime)
EndIf
Until WindowEvent() = #PB_Event_CloseWindow