MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

The nanosecond we can turn a 2D image into a complete 3D model, is the nanosecond I will cry myself to sleep of happiness =D Lets work together to make this dream a reality!
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

Um, where did I get MP_GetMemPrimatives?

I'm pretty sure mpz forgot to update thread safe / unicode safe mp 33 for 5.11. :/
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 Mythros,

i have made an update to the 511_thread safe / unicode safe too now....

Greetings Michael
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 »

@mpz: The new update crashes my entire program silently, both with and without Unicode / Threadsafe :( PB 5.11
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 Mythos,

i complied it with 511 threadsave and unicode again, tested it with some codes and copied it again on the server. I hope it works now...

Greetings Michael
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 »

@mpz: It still crashes on me with no explanation :(
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

here is what is like a bio structure, when its size 20000 (line 34) it is behaving like an organism or a small tornado and after 1 minute it is exploding vertically with two heads and a body which rotates like a DNA. and when its size 100000 (line 34) it is like a bulk which evaporates slowly to a very long tail .indeed i don't know why just changing the size makes this bio structure behaves like this. there is no direct interactions between particles . when we implement some interactions we we may have more interesting phenomena.
Image

when the 20000 points organism explodes to a two heads follow them up/down with A/Z keys
to try these examples install MP3D from page 1 in this forum, then download the experimental library (x86 for pb 520 and newer) from here http://www.morty-productions.de/gamedev ... hp?tid=160 until Michael update the setup file.
and copy the sole file to the C:\PureBasic\SubSystems\DX9\purelibraries\userlibraries replacing the old file.

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
    
    Global mAngle.f = Cos(-0.1)
    Global pAngle.f = Sin(0.1)
    Global move.f = 0
    
    ; code for MP3D
    Declare DrawMatrix()
    Declare isolate()
    
    Global angle.f
    
ExamineDesktops()
MP_Graphics3D (DesktopWidth(0),DesktopHeight(0),0,3) ; Erstelle ein WindowsFenster #Window = 0
MP_Viewport(0,0,DesktopWidth(0),DesktopHeight(0)-5)
SetWindowTitle(0, "press up/down to move camera, A/Z to move up.down  ")

    camera=MP_CreateCamera()

    light=MP_CreateLight(2)
    MP_LightSetColor (light, RGB(255,255,255))

        
    Global size = 20000
    Global Entity= MP_CreatePrimitives (size, #Mode)   
     

    Define.f red, green, blue


    Quit.b = #False

    ;==============================================================
    
    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)
    
    MP_VSync(0)
    
    xx.f=0 :zz.f=0 : camY=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
      If MP_KeyDown(#PB_Key_A)
        camY+10
        MP_PositionCamera(camera, 0, camY, 700)
          ElseIf MP_KeyDown(#PB_Key_Z)
            camY-10
            MP_PositionCamera(camera, 0, camY, 700)
            ElseIf MP_KeyHit(#PB_Key_R)
            MP_ScaleEntity(Entity, 1, 0.1, 1)
            
        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
    ;Debug move

    Procedure DrawMatrix()
      
      *Memory = MP_GetMemPrimitives(Entity)
      
      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 <= (size / 40)-100
      If q <= 4900
        r=0:g=255:b=0
        ;r=255:g=119:b=119
       
        *myvertex\x = x
        *myvertex\y = y
        *myvertex\z = z
        
        *myvertex\color = MP_ARGB(200,r,g,b)
       
        ;ElseIf q> size / 20
        ;ElseIf q> 10000
          ;r=0:g=0:b=0
          ;r=119:g=255:b=119
          
        ;*myvertex\x = x
        ;*myvertex\y = y
        ;*myvertex\z = z
        
        ;*myvertex\color = MP_ARGB(200,r,g,b)
          
      EndIf

      Next
      
      MP_CloseMemPrimitives(Entity)
      
    EndProcedure 

    Procedure isolate() ; rotate green core
      angle.f = 0.05
    
      *Memory = MP_GetMemPrimitives(Entity)
      *myvertex.PointVertex = *Memory
      
    For i=0 To size
         
    If *myvertex\Color & $FF00
      x.f = *myvertex\x
      z.f = *myvertex\z
      *myvertex\x = mAngle * x - pAngle * z
      *myvertex\z = mAngle * z + pAngle * x
      
      move + 0.01
      
      *myvertex\x + Sin(move)
      *myvertex\y + Cos(move/t)
      *myvertex\z + Cos(move)
      t+1
      If t=15000
        t=0
        move = 0
      EndIf
      
           
      CompilerIf #Mode = 7
        *myvertex\Size = 2.5 ;--- Only if Mode = 7
      CompilerEndIf
     
    EndIf 
    *myvertex + SizeOf(PointVertex)
      
       Next
       
       MP_CloseMemPrimitives(Entity)

     EndProcedure
     
    
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 »

A morph tip:

Code: Select all

#Mode=1 ; #Mode=1 or #Mode=7
Structure Vector
  x.f
  y.f
  z.f
  m.f
EndStructure
Structure PointVertex
  x.f
  y.f
  z.f
  CompilerIf #Mode=7
    Size.f ;--- Only if Mode=7
  CompilerEndIf 
  color.l;d3dcolor
EndStructure
Global xres.l=640,yres.l=480
MP_Graphics3D(xres,yres,0,3):MP_VSync(1)
SetWindowTitle(0,"press up/down to move camera")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(245,245,245))
MP_PositionEntity(light,0,10,20)
MP_EntityLookAt(light,0,0,0)
Global size=100000,objeto.l=1
Global Entity=MP_CreatePrimitives(size,#Mode),*Memory.PointVertex,Dim *OriginVertex.PointVertex(size),Dim TargetVertex.Vector(size),Dim trans.Vector(size)
Global TransCount.l
#TransSteps=90:#ObjectStayTime=500
Procedure DrawMatrix()
  Protected r.w=20,g.w=200,b.w=0,i.l
  *Memory=MP_GetMemPrimitives(Entity)
  For i=0 To size
    *OriginVertex(i)=*Memory+i*SizeOf(PointVertex)
    *OriginVertex(i)\color=MP_ARGB(200,r,g,b)
    *OriginVertex(i)\x=(Random(1800)-900)/10*i/size
    *OriginVertex(i)\y=(Random(1800)-900)/10*i/size
    *OriginVertex(i)\z=(Random(1800)-900)/10*i/size
  Next
  MP_CloseMemPrimitives(Entity)
EndProcedure
Macro getmod(ve)
  v#\m=Sqr(v#\x*v#\x+v#\y*v#\y+v#\z*v#\z)
EndMacro
Macro GetTransStepVector()
  trans(i)\x=(TargetVertex(i)\x-*OriginVertex(i)\x)/#TransSteps
  trans(i)\y=(TargetVertex(i)\y-*OriginVertex(i)\y)/#TransSteps
  trans(i)\z=(TargetVertex(i)\z-*OriginVertex(i)\z)/#TransSteps
EndMacro
Procedure object(obj.l)
  Protected i.l,xd.f
  MP_GetMemPrimitives(Entity)
  Select obj
    Case 2
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(xd)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(xd)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 3
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(xd)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 4
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Sin(i*360/size)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 5
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(xd)*100
        TargetVertex(i)\y=Cos(xd)*Sin(xd)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 6
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(xd)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(xd)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 7
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(i*360/size)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(xd)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 8
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(xd)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(xd)*Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 9
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Sin(i*360/size)*Cos(i*360/size)*Sin(xd)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(xd)*Cos(xd)*100
        TargetVertex(i)\z=Sin(xd)*Cos(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 10
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(xd)*100
        TargetVertex(i)\z=Cos(xd)*Sin(xd)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 11
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Sin(xd)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(xd)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 12
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(i*360/size)*Cos(xd)*100
        TargetVertex(i)\y=Sin(i*360/size)*Sin(xd)*100
        TargetVertex(i)\z=Sin(i*360/size)*Sin(xd)*Cos(i*360/size)*Cos(xd)*200 
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 13
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(xd)*100
        TargetVertex(i)\y=Sin(i*360/size)*Sin(xd)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 14
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Sin(xd)*Cos(xd)*100
        TargetVertex(i)\y=Sin(xd)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 15
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(xd)*Cos(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 16
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(i*360/size)*Sin(i*360/size)*100
        TargetVertex(i)\y=Sin(i*360/size)*Sin(xd)*Cos(i*360/size)*100
        TargetVertex(i)\z=Sin(xd)*Cos(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 17
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Cos(xd)*100
        TargetVertex(i)\y=Cos(i*360/size)*Sin(i*360/size)*100
        TargetVertex(i)\z=Sin(i*360/size)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 18
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Cos(xd)*Sin(i*360/size)*100
        TargetVertex(i)\y=Cos(xd)*Cos(i*360/size)*100
        TargetVertex(i)\z=Cos(xd)*100
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 19
      For i=0 To size
        xd=Random(1800)
        TargetVertex(i)\x=Sin(xd)*Cos(xd)*Sin(i*360/size)*200
        TargetVertex(i)\y=Sin(i*360/size)*Cos(i*360/size)*Sin(xd)*200
        TargetVertex(i)\z=Sin(i*360/size)*Cos(xd)*Cos(i*360/size)*200
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Case 20
      For i=0 To size
        TargetVertex(i)\x=Random(150)-75
        TargetVertex(i)\y=Random(150)-75
        TargetVertex(i)\z=Random(150)-75
        If Random(1)
          PokeF(TargetVertex(i)+SizeOf(float)*(Random(2)),75)
        Else
          PokeF(TargetVertex(i)+SizeOf(float)*(Random(2)),-75)
        EndIf
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
    Default
      For i=0 To size
        TargetVertex(i)\x=(Random(1800)-900)/10*i/size
        TargetVertex(i)\y=(Random(1800)-900)/10*i/size
        TargetVertex(i)\z=(Random(1800)-900)/10*i/size
        ;Get "trans" step-vector:
        GetTransStepVector()
      Next
  EndSelect
  Transcount=#TransSteps
  MP_CloseMemPrimitives(Entity)
EndProcedure
;==============================================================
MP_ScaleEntity(Entity,1.5,1.5,1.5)
;MP_MeshSetBlendColor(Entity,$FFFFFFFF)
;MP_MeshSetAlpha(Entity,3)
;MP_MeshAlphaSort(Entity);
MP_PrimitivesBlendingMode(Entity,5,2)
MP_PositionCamera(camera,0,0,500)
MP_CameraLookAt(camera,0,0,0)
DrawMatrix()
zz.f=0
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow
  If MP_KeyDown(#PB_Key_Up)
    zz.f+20
  ElseIf MP_KeyDown(#PB_Key_Down)
    zz.f-20
  EndIf
  contador.l+1
  If contador>=#ObjectStayTime
    contador=0
    objeto+1:If objeto>20:objeto=1:EndIf
    object(objeto.l)
  EndIf
  If TransCount>0
    TransCount-1
    If TransCount>0
      MP_GetMemPrimitives(Entity)
      For i.l=0 To size
        *OriginVertex(i)\x+trans(i)\x
        *OriginVertex(i)\y+trans(i)\y
        *OriginVertex(i)\z+trans(i)\z
      Next
      MP_CloseMemPrimitives(Entity)
    Else
      MP_GetMemPrimitives(Entity)
      For i.l=0 To size
        *OriginVertex(i)\x=TargetVertex(i)\x
        *OriginVertex(i)\y=TargetVertex(i)\y
        *OriginVertex(i)\z=TargetVertex(i)\z
      Next
      MP_CloseMemPrimitives(Entity)
    EndIf
  EndIf
  MP_PositionEntity(Entity,0,0,zz)
  MP_TurnEntity(Entity,1.333,0.5,0.2)
  MP_DrawText(1,1,"FPS="+Str(MP_FPS()))
  MP_RenderWorld()
  MP_Flip()
Wend
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 »

@Psychophanta, i suspect you was guided by Aliens from outer space when you have written this code, from a star at the center of a cube to a planet with 2 poles there are too much curves morphing to each other. i still can't believe.
the fps on my poor machine between 28 to 70 depends on the 3D curve displayed so it is good and smooth mostly.
for the users who wants to run this great example apply the instruction at the end of my latest post above. and you need to choose dx9 in the compiler options
thanks
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 »

Because in german forum no answers for my problem, i post it here.

After a fresh windows 7 32bit installation i install graphiccard driver and dx9.0c.

No purebasic with mp3d because i couldn´t compile it.

Every exe wich use mp3d crashes.

dx9 and driver are installed.

I don´t understand why it crashes.
Other dx9 apps runs.

Problem solved, wrong audio driver.
It should possible that mp3d sends a message if something is wrong.
Or if we haven´t installed audio driver apps should run without sound, but no crashes.
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 Gnom,

oh i dont have an error request if the audio driver is not activated. I will have alook 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 »

Yes if i install the audio driver all works fine with the executables.

The only problem now is pb don´t know your mp3d library.
MP_Graphics3D() isn´t a function, macro ... and so on.
Installed mp3d two times, doesn´t work.
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,

please copy the mp3d lib into the following folder and restart Purebasic:

c:\Program Files (x86)\PureBasic\SubSystems\DX9\

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 »

its correct installed. (D:\Apps\PureBasic\SubSystems\DX9\purelibraries\userlibraries\MP3D_Library)
have copied it twice as you said in dx9 folder.
restart, don´t run.

see:
Image


Have installed pb 5.20 in c:\program files\ now, too.Installed mp3d and the library the same way.
No solution it don´t find your library system.
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 say :

D:\Apps\PureBasic\SubSystems\DX9

NOT
D:\Apps\PureBasic\SubSystems\DX9\purelibraries\userlibraries\


Greetings Miochael
Working on - MP3D Library - PB 5.73 version ready for download
Post Reply