Hello to all,
time for a new beta in my Forum
36) new paramter added: MP_Vsync(var); Var=0 Vsync off, mesh speed up; Var = 1 Vsync on, normal speed; Var=2 Vsync off, timed speed; Var=3 Vsync on, timed speed
37) new function added: MP_GetMemPrimitives(Entity); Memorybuffer loaded with Primitives vertex Buffer
38) new function added: MP_SetMemPrimitives(Entity, *Memory); Memorybuffer loaded into Primitives vertex Buffer
39) problem solved: with MP_Vsync(0) the 3d Phsyic works different to MP_Vsync(1), now it works all times
40) new function added: MP_GetTimerResolution(); read the timerresolution -> internal test command
41) new function added: MP_SetTimerResolution(Resolution) ; save the timerresolution -> internal test command
The new command MP_SetMemPrimitives and MP_GetMemPrimitives speed up the greate ApplePi Points Demo with 100K points to 42 FPS
here the new code
Code: Select all
    #Mode = 1 ; #Mode = 1 or #Mode = 7
    Structure PointVertex
      x.f
      y.f
      z.f
      CompilerIf #Mode = 7
        Size.f ;--- Only if Mode = 7
      CompilerEndIf  
      Color.l;d3dcolor
    EndStructure
    
    ; code for MP3D
    Declare DrawMatrix()
    Declare isolate()
    Global angle.f
    Global xres=640, yres=480
    MP_Graphics3D (xres,yres,0,3)
    SetWindowTitle(0, "press up/down to move camera  ")
    camera=MP_CreateCamera()
    light=MP_CreateLight(2)
    MP_LightSetColor (light, RGB(255,255,255))
    MP_PositionEntity(light, 0, 10, 20)
    MP_EntityLookAt(light,0,0,0)
    Global Entity= MP_CreatePrimitives (100000, #Mode)   
     
    Define.f red, green, blue
    Quit.b = #False
    ;==============================================================
           
    MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
    ;MP_MeshSetBlendColor(Entity, $FFFFFFFF)
    ;MP_MeshSetAlpha(Entity,3)
    ;MP_MeshAlphaSort(Entity);
    DrawMatrix()
    MP_PrimitivesBlendingMode(Entity, 5,2)
    MP_PositionCamera(camera, 0, 0, 700)
    MP_CameraLookAt(camera,0,0,0)
    MP_PositionEntity(light, 0 , 0, 10)
    MP_EntityLookAt(light,0,0,0)
    xx.f=0 :zz.f=0
    While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
     
      If MP_KeyDown(#PB_Key_Up)
       
        zz.f + 20
      ElseIf MP_KeyDown(#PB_Key_Down)
       
        zz.f - 20
     
      EndIf
         
        MP_PositionEntity(Entity, xx, 0, zz)
        MP_TurnEntity(Entity,0,1,0)
       
        isolate(); call the routine for rotating only the green points
        
        MP_DrawText (1,1,"FPS = "+Str(MP_FPS()))
        
      MP_RenderWorld()
       
      MP_Flip ()
    Wend
    Procedure DrawMatrix()
      
      *Memory = MP_GetMemPrimitives(Entity)
      
      size = 100000-1
      For i=0 To size
        x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
        *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
     
    ;check if point inside a specific sphere: 
      q.f = (Pow(x,2) + Pow(y,2) + Pow(z,2))
      If q <= 4900
        r=0:g=255:b=0
       
        *myvertex\x = x
        *myvertex\y = y
        *myvertex\z = z
        
        *myvertex\color = MP_ARGB(200,r,g,b)
       
        ElseIf q>10000
          r=255:g=0:b=0
          
        *myvertex\x = x
        *myvertex\y = y
        *myvertex\z = z
        
        *myvertex\color = MP_ARGB(200,r,g,b)
          
      EndIf
      Next
      
      MP_SetMemPrimitives(Entity,*Memory)
      FreeMemory(*Memory)
      
    EndProcedure 
    Procedure isolate() ; rotate green core
      angle.f = 0.05
    
      *Memory = MP_GetMemPrimitives(Entity)
      
      size = 100000-1
      For i=0 To size
         
       *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
        
       col.l = *myvertex\Color
       If MP_Green(col) = 255
         x.f = *myvertex\x
         ; y.f = *myvertex\y ; not needed
         z.f = *myvertex\z
       
         *myvertex\x = Cos(-angle)* x - Sin(angle)* z
         *myvertex\z = Cos(-angle)* z + Sin(angle)* x
         
         CompilerIf #Mode = 7
           *myvertex\Size = 2.5 ;--- Only if Mode = 7
         CompilerEndIf
         
       EndIf
      
       Next
       
       MP_SetMemPrimitives(Entity,*Memory)
       FreeMemory(*Memory)
     EndProcedure
     
     
Demo to show the new MP_Vsync parameter
Code: Select all
MP_Graphics3D (640,480,0,2) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "VSync Demo, how fast is the computer and show MP_VSync(0-3)") 
camera=MP_CreateCamera() ; Kamera erstellen
light=MP_CreateLight(1) ; Es werde Licht
Mesh=MP_CreateCube() ; Und jetzt eine Würfel
MP_PositionEntity (Mesh,0,0,5) ; Position des Würfels
If CreateImage(0, 255, 255)
    Font = LoadFont(#PB_Any, "Arial"  , 138) 
    StartDrawing(ImageOutput(0))
    Box(0, 0, 128, 128,RGB(255,0,0))
    Box(128, 0, 128, 128,RGB(0,255,0))
    Box(0, 128, 128, 128,RGB(0,0,255))
    Box(128, 128, 128, 128,RGB(255,255,0))
    DrawingFont(FontID(Font))
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(73,35,"5",RGB(0,0,0))
  
    StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
    
EndIf
Texture = MP_ImageToTexture(0) ; Create Texture from image 
MP_EntitySetTexture (Mesh, Texture ) ; textur to mesh
a = 1
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
    
    count +1
    
    If count = 500
      a = 0
      MP_VSync(a)
    EndIf   
    If count = 10000
       a + 1
       MP_VSync(a)
     EndIf
    
    If count = 10500
       a + 1
       MP_VSync(a)
    EndIf
    
    If count = 20000
      a + 1
      MP_VSync(a)
      count = 0
    EndIf
     
    MP_DrawText (1,1,"FPS = "+Str(MP_FPS())+" count = "+Str(count) + " VSync Time =" +StrF(MP_VSyncTime()))
    MP_DrawText (1,20,"MP_Vsync("+Str(a)+")     Timer Res: "+Str(MP_GetTimerResolution()))
    
    ElapsedTime = ElapsedMilliseconds()-StartTime 
    If ElapsedTime
      dudu = ElapsedTime
    EndIf  
    MP_DrawText (1,40,"ElapsedMilliseconds("+Str(dudu)+")")
    StartTime = ElapsedMilliseconds()             ; ermittelt den aktuellen Wert
    
    MP_TurnEntity (Mesh,0.1,0.2,0.3) 
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
Wend
 
MP3D Forum problem: 
I am very sorry, currently it is not possible for me to delete these Russian spam mails. I work on it.
I have made some little Updates and it will come a new version very soon
Greetings
Michael