MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

Multitexturing works very fine.
Can we use MP_EntityGetTexture(mesh[,n]) to add a normal map texture to the specific texture?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Aleks_Longard wrote:Hi Michael
You will make the team for 3d sound?
And please add the function to get the volume and pan, for example:
mp_soundgetpan ()
mp_soundgetvolume ()
+1
Aleks_Longard wrote:Very thanks for you best library!
+1
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hi,

i think normal map and light map will be on of the next step. 3d Sound ist also possible, i will hav a look on it.

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

You are my hero....fantastic...
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

Hey guys. I can't get this example from the MP3D docs to work right with 5.11 (x86) 32 / 64 bit.

The movie DOES INDEED exist, I DID load it into windows media player and it worked perfectly fine.

What am I missing here, and why is it covering up the text "FPS" except for the "F"? :(

Code: Select all

MP_Graphics3D(800, 600, 0, 2) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "3D with Video") ; Setzt einen Fensternamen

camera=MP_CreateCamera() ; Kamera erstellen
MP_PositionCamera(camera, 0, 1, -10)

light=MP_CreateLight(1) ; Es werde Licht

Mesh=MP_CreateCube() ; Und jetzt eine WürfelMesh2=MP_CreateCube() ; Und jetzt eine Würfel

MP_PositionEntity (Mesh,0,1,10) ; Position des Würfels

avifile.s = OpenFileRequester ( "AVI File", "", "Video|*.avi", 0 ) 
MessageRequester(avifile, avifile)

Movie = MP_MovieInit (avifile)
MessageRequester(Str(Movie), Str(Movie))

Texture = MP_CreateTexture(0,0)
MP_EntitySetTexture (Mesh, Texture)

max = MP_MovieNumFrames (   Movie ) 
MessageRequester(Str(max), Str(max))

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   
      Frame.f + 0.5
      If Frame > Max : Frame = 0 : EndIf
      
      MP_MovieToTexture (   Movie, Texture, Frame ) 
      
      If MP_KeyHit(#PB_Key_Space) 
         avifile.s = OpenFileRequester ( "AVI File", "", "Video|*.avi", 0 )
         MP_CloseMovie(   Movie ) 
         Movie = MP_MovieInit (avifile)
         max = MP_MovieNumFrames (   Movie )
      EndIf
      
      MP_DrawText (10,10,"FPS: "+Str(MP_FPS ()))
      
      MP_TurnEntity (Mesh,0.1,0.1,0.1) ; dreh den Würfel
      MP_RenderWorld() ; Erstelle die Welt
      MP_Flip () ; Stelle Sie dar
      
Wend

MP_CloseMovie(   Movie ) 
Thank you!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: MP3D Engine Alpha 32

Post by Danilo »

Mythros wrote:What am I missing here, and why is it covering up the text "FPS" except for the "F"? :(
This usually happens if you call a ASCII function with an Unicode string.

The string ends after one character for the Ascii-function, because the next char is a 0, if the first character is within the Ascii range (<255).
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

@Mythros , me also can't display half of the avi files on the MP3D cube.
this depends on the avi codecs ie the compression types
Image
, so use video converter to change this , as an example when i choose indeo compressor it is displayed on the MP3D cube but not when using ffdshow video compressor, also No compressor works but the avi file will be very huge, the utility i have used: Power Video Converter.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

What happened to MPZ?

He just... disappeared.. ?
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: MP3D Engine Alpha 32

Post by DK_PETER »

Mythros wrote:What happened to MPZ?

He just... disappeared.. ?
Nope...Michael is working hard on MP3D and he has a family to take care of too.
A lot of new features and enhancements are being finetuned and tested.
He'll be back soon. :-)

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.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hello to all,

yes i am working on the mp3d but i have family and much work at work in the last days.

@Mythros what exactly for a problem do you have?!? I use on Windows XP and Windows 7 Prof. the divx codec for playing and rendering. My 3d film creating works fine with divx and the films are very small. I use the AVIFIL32.DLL for that and perhaps some kinds of film files (mp4 for examples) doesnt work with this dll. So i think the answer from Danilo and from applePi are correcta nd i yould not answer better :)

Greetings Michael
Last edited by mpz on Fri Dec 06, 2013 11:26 pm, edited 1 time in total.
Working on - MP3D Library - PB 5.73 version ready for download
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

Thanks, @mpz. It works. I got it to work the other day, sorry for not posting back.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

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

Image

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
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Awesome,
I will take a look on weekend and next week.
Looks promising!
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Thanks Michael for the big speed improvements in the points functions, the previous example was extremely slow, and now there is a big difference.
my extreme and far hope is to simulate a tornado , or a dust storm like that in the movie "The Mummy (1999 film)" http://www.youtube.com/watch?v=ersxqFwDkWA&t=1m57s
how they do that !!, possibly using a super computer simulation in 1999.
User avatar
IceSoft
Addict
Addict
Posts: 1682
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: MP3D Engine Alpha 32

Post by IceSoft »

applePi wrote:Thanks Michael for the big speed improvements in the points functions, the previous example was extremely slow, and now there is a big difference.
my extreme and far hope is to simulate a tornado , or a dust storm like that in the movie "The Mummy (1999 film)" http://www.youtube.com/watch?v=ersxqFwDkWA&t=1m57s
how they do that !!, possibly using a super computer simulation in 1999.
@applePi,
after some little code optimizations it should be extremely faster as the latest fastest version before: :mrgreen:

Code: Select all

#Mode = 7 ; #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  ")
MP_VSync(0)

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)   

Global mAngle.f = Cos(-0.05)
Global pAngle.f = Sin(0.05)
Global *Memory = MP_GetMemPrimitives(Entity)


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
FreeMemory(*Memory)
End

Procedure DrawMatrix()
  *myvertex.PointVertex = *Memory
  
  size = 100000-1
  For i=0 To size
    x = Random(200)-100:y = Random(200)-100:z = Random(200)-100

    
    ;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
    *myvertex + SizeOf(PointVertex)
    
  Next
  
  MP_SetMemPrimitives(Entity,*Memory)
  
  
EndProcedure 

Procedure isolate() ; rotate green core
  *myvertex.PointVertex = *Memory
  
  For i=0 To 99999

    If *myvertex\Color & $FF00
      x.f = *myvertex\x
      z.f = *myvertex\z
      *myvertex\x = mAngle* x - pAngle* z
      *myvertex\z = mAngle* z + pAngle* x
      
      
      CompilerIf #Mode = 7
        *myvertex\Size = 2.5 ;--- Only if Mode = 7
      CompilerEndIf
      
    EndIf  
    *myvertex + SizeOf(PointVertex)
  Next
  MP_SetMemPrimitives(Entity,*Memory)
EndProcedure
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Post Reply