MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
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,

and the winner with the fastes methodic is ...... IceSoft

But not for long... :D

I think it is not fast enough and i must upgrade my new command. With a new parameter i get 180fps.

http://www.flasharts.de/mpz/ApplePi_points_test.exe


Now we need only a water/wind/tornado algorythmic and we make our own weather...

Greetings
Michael
Working on - MP3D Library - PB 5.73 version ready for download
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Thanks IceSoft for the big improvement, your version can be used to simulate a gaseous planet core rotating and other things. and for Michael: thats too much speed and unexpected , but not fair since when i have said my hope is to simulate a tornado or a dust storm i mean after 10 years and not after 5 hours :) . any way i hope you will post an update soon to try this big speed. i will do more tests on the current library especially on a dynamically chaotic unpredictable crowds of points
regards
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,

function added for more speed:

42) function changed: MP_GetMemPrimitives(Entity); dont use a Memorybuffer, open the dx9 vertexbuffer directly
43) function deleted: MP_SetMemPrimitives(Entity, *Memory); not needed anymore
44) new function added: MP_CloseMemPrimitives(Entity); Close dx9 vertexbuffer, important to use after MP_GetMemPrimitives(Entity);
45) new function added: MP_SizeMemPrimitives(Entity) ; Get Size of Vertex memorybuffer of primitives

If you delete the MP_Vsync(0) you have your slow speed :lol:

Demo now with 200k points (on my pc with 100fps)

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
    
    Global mAngle.f = Cos(-0.05)
    Global pAngle.f = Sin(0.05)
    
    ; 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 size = 200000
    Global Entity= MP_CreatePrimitives (size, #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)
    
    MP_VSync(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)
      
      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
        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> size / 20
          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_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
     
     
      CompilerIf #Mode = 7
        *myvertex\Size = 2.5 ;--- Only if Mode = 7
      CompilerEndIf
     
    EndIf 
    *myvertex + SizeOf(PointVertex)
      
       Next
       
       MP_CloseMemPrimitives(Entity)

     EndProcedure
     
     
Greetings
Michael
Working on - MP3D Library - PB 5.73 version ready for download
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Hi Michael
on my very poor graphics card Geforce 520 GT and using 100000 points the fps 34 and this is great for me, using 200000 points the fps = 16 and still easy for me to move by arrow keys.
while thinking about a possible demo i thought of a human face research. so using the MP3D official example MP_Picture_to_3D.pb in the Extra folder to load this face http://seedmagazine.com/content/article ... _beholder/
and while rotating the face in a 3d context i have noticed it turns from the beauty to ugly depends on the viewing angle such as Image
so to try to look at the face points (and not triangles) we can morph it and study it more. so how to save the points coordinates easily from the the picture loaded by MP_Picture_to_3D.pb to a file, so we can load it later as a 3D points cloud. i have posted before about turning a 2D picture to a mesh but it is still 2D in a 3D context. your MP_Picture_to_3D.pb seems have a terrain like capability which turns pictures to 3D models.
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 »

i´ve asked mpz and i will post my question here too.
have anyone an car physics example for mp3d?
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

Holy CRAP! O_O There's a freakin' Pointcloud demo and I didn't KNOW about it?! O_O

Is there a way to grab a live, high-quality, colored pointcloud from the kinect, mpz? :)

Thank You! You just made my day! Again!
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

@applePi, where can I get that MP3D Picture_to_3D? I want to modify it!
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 »

Mythros wrote:Is there a way to grab a live, high-quality, colored pointcloud from the kinect, mpz? :)
Maybe this can help:
https://github.com/mdkus/kinect-mssdk-o ... cl-bridge/
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Mythros, it is in "C:\PureBasic\MP3D Demos\Extra" folder, just press space then choose a picture , and a second time choose the same picture. then rotate the new 3D picture by arrow keys.
Michael, i have used MP_SaveMesh("face.x",terrain) to save the woman 3D face as demonstrated in the MP_Picture_to_3D example , and inspecting the "x" file i have guessed just a guess where is the x,y,z coordinates, i attach it here
http://www.2shared.com/file/MdTLSTuA/data.html
so using your example above but loading those points and attaching green color to them then displaying them i get 2D and not 3D shape.

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
    
    Global mAngle.f = Cos(-0.005)
    Global pAngle.f = Sin(0.005)
    
    ; 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 size = 16642
    Global Entity= MP_CreatePrimitives (size, #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)
    
    MP_VSync(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()
      ReadFile(0, "data.txt") 
      Dim vx.f(3)
      x.f:y.f:z.f
      *Memory = MP_GetMemPrimitives(Entity)
      
      For i=0 To size ;size 16641
        
        *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
     
          a$ = ReadString(0) 
           For k=1 To 3
         
           vx(k) = ValF(StringField(a$, k, " "))
          Next
              
        r=0:g=255:b=0
       
        *myvertex\x = vx(1)/64
        *myvertex\y = vx(2)/64
        *myvertex\z = vx(3)/16
        
        *myvertex\color = MP_ARGB(200,r,g,b)
       

      Next
      
      MP_CloseMemPrimitives(Entity)
      CloseFile(0) 
      
    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
           
      CompilerIf #Mode = 7
        *myvertex\Size = 2.5 ;--- Only if Mode = 7
      CompilerEndIf
     
    ;EndIf 
    *myvertex + SizeOf(PointVertex)
      
       Next
       
       MP_CloseMemPrimitives(Entity)

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

@applePi -> how to save the points coordinates easily

MP_SavePrimitives (Entity, File.s)
and
MP_LoadPrimitives (File.s)

or
*memory = MP_GetMemPrimitives(Entity)
size = MP_SizeMemPrimitives(Entity)
openfile...
WriteData(0, *memory , size )
closefile

@Gnom -> car physics example for mp3d
i use newton dynamic 3.11, if you find a demo i can make an example. i had no time fro searching...

@Mythros -> kinect
i have no kinetic device, i think the price is 100 Euro. If you have some data file i can have a look on it to make a 3d mesh from these

@applePi -> i get 2D and not 3D shape

little error, you read only 2 parameter not three -> use -> vx(k) = ValF(StringField(a$, k+1, " "))

greetings Michael

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.005)
    Global pAngle.f = Sin(0.005)
   
    ; 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 size = 16642
    Global Entity= MP_CreatePrimitives (size, #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)
   
    ;MP_VSync(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()
      ReadFile(0, "data.txt")
      Dim vx.f(3)
      x.f:y.f:z.f
      *Memory = MP_GetMemPrimitives(Entity)
     
      For i=0 To size ;size 16641
       
        *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
     
          a$ = ReadString(0)
           For k=1 To 3
             vx(k) = ValF(StringField(a$, k+1, " "))
           Next
           
        r=0:g=255:b=0
       
        *myvertex\x = vx(2)/64
        *myvertex\y = -vx(1)/64
        *myvertex\z = vx(3)/64
       
        *myvertex\color = MP_ARGB(200,r,g,(vx(2)+800)/10)
       

      Next
     
      MP_CloseMemPrimitives(Entity)
      CloseFile(0)
     
    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
           
      CompilerIf #Mode = 7
        *myvertex\Size = 2.5 ;--- Only if Mode = 7
      CompilerEndIf
     
    ;EndIf
    *myvertex + SizeOf(PointVertex)
     
       Next
       
       MP_CloseMemPrimitives(Entity)

     EndProcedure
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, yes as a matter of fact, I do. It's just your basic PLY format. Here's a link to the specifications:

http://en.wikipedia.org/wiki/PLY_(file_format)

NOTE: The texture MUST be from the point cloud, and the texture MUST be of EXTREMELY high quality if this is to work great.

Thank You once again, mpz! You are a PureBasic GOD!
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

@Michael, this is exactly the 3D shape i want, thank you.
regarding MP_SavePrimitives it is not documented yet in this page http://www.morty-productions.de/gamedev ... 160&page=1

Edit: sorry i found the docs for MP_SavePrimitives here http://www.morty-productions.de/gamedev ... hp?tid=145
thanks for all your efforts.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

here is using the new functions to copy a picture to mesh.
i can't say high quality may be depends on several factors, may be a medium.
also why when we color the plane the picture colored the same !!
such as use
MP_EntitySetTexture(plane, texture) ; color red
instead of
MP_EntitySetTexture(plane, texture2) ; line 30 color white
and of course someone will said why the mesh rotate like a door and not around itself, i think the reason is what Comtois said "your mesh is not centered on the y-axis" http://purebasic.fr/english/viewtopic.p ... 15#p417662 and he provides a solution and after that an automatic solution, i will try to apply here later.
Image
use any pic or the woman pic here http://seedmagazine.com/content/article ... _beholder/ and save it as woman.bmp

Code: Select all

Declare DrawMatrix()

#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

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, "Pic_to_Mesh .. press Up, Down keys to move camera")

camera=MP_CreateCamera()

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

texture2 = MP_CreateTextureColor(256, 256, MP_ARGB(0,255,255,255))
texture = MP_CreateTextureColor(256, 256, MP_ARGB(0,255,0,0))

plane = MP_CreatePlane(10, 10)
MP_EntitySetTexture(plane, texture2)
MP_RotateEntity(plane, 90, 0, 90)
MP_PositionEntity(plane, 0, -5, 0)

MP_PositionCamera(camera, 0, 5, 20)
MP_CameraLookAt(camera,0,0,0)

MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
;==============================================================
; load image
Global image_id.i
image_id = LoadImage( #PB_Any, "woman.bmp" )
;Dim image_pixel_data.b( ImageWidth(image_id), ImageHeight(image_id) )
Global size = Int(ImageWidth(image_id)*ImageHeight(image_id))
Global Entity= MP_CreatePrimitives (size, #Mode)   

DrawMatrix()
;==============================================================

MP_PositionEntity(light, 0 , 10, 10)
MP_EntityLookAt(light,0,0,0)

xx.f=-5 :z.f=-4
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
  
  If MP_KeyDown(#PB_Key_Up) 
    xx.f + 0.1
    z.f + 0.1
  ElseIf MP_KeyDown(#PB_Key_Down) 
    xx.f - 0.1
    z.f - 0.1
  EndIf 
  
    MP_PositionEntity(Entity, xx, 10, z)
    MP_TurnEntity(Entity,0,1,0) 
   
  MP_RenderWorld()
   
  MP_Flip ()

Wend


 Procedure DrawMatrix()
 i=-1
*Memory = MP_GetMemPrimitives(Entity)

StartDrawing( ImageOutput( image_id ) )

For y = 0 To ImageHeight(image_id) - 1
  For x = 0 To ImageWidth(image_id) - 1
    r=MP_Red(Point( x, y ))
    g=MP_Green(Point( x, y ))
    b=MP_Blue(Point( x, y ))
    
    i+1
    
    *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)        
    
     *myvertex\x = x
     *myvertex\y = y
     *myvertex\z = z
        
     *myvertex\color = MP_ARGB(0,r,g,b)  
  Next x
  Next y
  StopDrawing()
  MP_ScaleEntity(Entity, 0.03, 0.03, 0.03)
  ;MP_MeshSetAlpha(Entity,2)
  MP_PositionEntity(Entity, 0, 0, 0)
  MP_RotateEntity(Entity,180,0,0)
      
  MP_CloseMemPrimitives(Entity)
      
  EndProcedure 
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,

here comes a little update. Image turn now in the middle, points a little bit bigger and in the middle of the picture you get now in 3d. dx 9 rgb ist a little bit different to image rgb so i solve this problem (red () insted of mp_red() if you work with images)


Greetings Michael

Code: Select all

Declare DrawMatrix()

#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

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, "Pic_to_Mesh .. press Up, Down keys to move camera")

camera=MP_CreateCamera()

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

texture2 = MP_CreateTextureColor(256, 256, MP_ARGB(0,255,255,255))
texture = MP_CreateTextureColor(256, 256, MP_ARGB(0,255,0,0))

plane = MP_CreatePlane(10, 10)
MP_EntitySetTexture(plane, texture2)
MP_RotateEntity(plane, 90, 0, 90)
MP_PositionEntity(plane, 0, -5, 0)

MP_PositionCamera(camera, 0, 5, 20)
MP_CameraLookAt(camera,0,0,0)

MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
;==============================================================
; load image
Global image_id.i
image_id = LoadImage( #PB_Any, "f:\temp\MP_33\18\woman.bmp" )
;Dim image_pixel_data.b( ImageWidth(image_id), ImageHeight(image_id) )
Global size = Int(ImageWidth(image_id)*ImageHeight(image_id))
Global Entity= MP_CreatePrimitives (size, #Mode)   

DrawMatrix()
;==============================================================

MP_PositionEntity(light, 0 , 10, 10)
MP_EntityLookAt(light,0,0,0)

xx.f=0 :z.f=-4
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
 
  If MP_KeyDown(#PB_Key_Up)
    xx.f + 0.1
    z.f + 0.1
  ElseIf MP_KeyDown(#PB_Key_Down)
    xx.f - 0.1
    z.f - 0.1
  EndIf
 
    MP_PositionEntity(Entity, xx, 10, z)
    MP_TurnEntity(Entity,0,1,0)
   
  MP_RenderWorld()
   
  MP_Flip ()

Wend


 Procedure DrawMatrix()
 i=-1
*Memory = MP_GetMemPrimitives(Entity)

StartDrawing( ImageOutput( image_id ) )

For y = 0 To ImageHeight(image_id) - 1
  For x = 0 To ImageWidth(image_id) - 1
    r = Red(Point( x, y ))
    g = Green(Point( x, y ))
    b = Blue(Point( x, y ))
    
    ;r = MP_Red(Point( x, y ))
    ;g = MP_Green(Point( x, y ))
    ;b = MP_Blue(Point( x, y ))
    
    i+1
   
    *myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)       
   
     *myvertex\x = x - ImageWidth(image_id)/2
     *myvertex\y = y
     
     If Y > ImageHeight(image_id)/2
        *myvertex\z = MP_Red(Point( x, y ))/16
      EndIf
      
     *myvertex\Size = 3  
     *myvertex\color = MP_ARGB(0,r,g,b) 
  Next x
  Next y
  StopDrawing()
  MP_ScaleEntity(Entity, 0.03, 0.03, 0.03)
  ;MP_MeshSetAlpha(Entity,2)
  MP_PositionEntity(Entity, 0, 0, 0)
  MP_RotateEntity(Entity,180,0,0)
  
  
  
  MP_CloseMemPrimitives(Entity)
     
  EndProcedure 
Working on - MP3D Library - PB 5.73 version ready for download
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

thats a welcome changes and improvements Michael it turns the picture to a piece of art merging 2D with 3D, centering the mesh, the quality of color are much better.
there is still the problem of that coloring the plane affect the picture color, in line 30 of your version if we change as
MP_EntitySetTexture(plane, texture)
the picture will be colored red
not an emergency issue, just we make too much tests.
Edit: if this is of significance: in PB Ogre we set the mesh material to white.jpg before plotting points on the mesh, this is happened many times in the examples such as MeshManual2.pb in the 3d folder else the color will not appears as expected. don't know if this info of significance or not.
Last edited by applePi on Fri Dec 20, 2013 7:21 pm, edited 1 time in total.
Post Reply