MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 27

Post by djes »

Some remarks...

Is it possible to use the MP_MeshSetData() function with only #PB_Mesh_Vertex, and in a second step with #PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate, or only the first time must I set all #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate ?

I had some big crashes (complete hang with reboot!!!) with some tests.

Translation : pitch, yaw, roll : y-axis, x-axis, z-axis ; rectangle, not retangle ; Effect, not Effekt (almost no "k" in english)

Loot a the following code. I have sort of a pause every second. After one minute, wave effect is suspended. Maybe the sinus function, but strange, isn't it?

Code: Select all

;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Test
;// Created On: 2.12.2010
;// Author: djes
;// OS:Windows
;// 
;////////////////////////////////////////////////////////////////

#subdivisions = 64

MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "3D Darstellung eines Mesh Objektes")
camera=MP_CreateCamera() ; Kamera erstellen
light=MP_CreateLight(1) ; Es werde Licht

grid = MP_CreatePlane(#subdivisions, #subdivisions) 

If CreateImage(0, 1024, 1024)
   Font = LoadFont(#PB_Any, "Arial"  , 138*4) 
   StartDrawing(ImageOutput(0))
   Box(0, 0, 512, 512,RGB(255,0,0))
   Box(512, 0, 512, 512,RGB(0,255,0))
   Box(0, 512, 512, 512,RGB(0,0,255))
   Box(512, 512, 512, 512,RGB(255,255,0))
   DrawingFont(FontID(Font))
   DrawingMode(#PB_2DDrawing_Transparent)
   DrawText(73*4,35*4,"5",RGB(0,0,0))
   StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
EndIf
; 
Textur = MP_ImageToTexture(0) ; Create Texture from image 
MP_EntitySetTexture (grid,Textur)
MP_ScaleEntity (grid, 0.1, 0.1, 0.1)
MP_TurnEntity (grid, 0, 30, 0) ; Ein bischen drehen

i.f = 0
x.f=0 : y.f=0 : z.f+6

While Not MP_KeyDown(#PB_Key_Escape) And Not MP_WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
 
 If MP_KeyDown(#PB_Key_Left)=1 : x=x-1 : EndIf ;links Debug #PB_Key_Left
 If MP_KeyDown(#PB_Key_Right)=1 : x=x+1 : EndIf ;rechts #PB_Key_Right
 If MP_KeyDown(#PB_Key_Down)=1 : y=y-1 : EndIf ;Runter #PB_Key_Down
 If MP_KeyDown(#PB_Key_Up)=1 : y=y+1 : EndIf ;rauf #PB_Key_Up
 If MP_KeyDown(#PB_Key_Z)=1  : z=z+0.1 : EndIf ;y Vertauscht bei y-z bei deutscher tastatur
 If MP_KeyDown(#PB_Key_Y)=1  : z=z+0.1 : EndIf ;y Vertauscht bei y-z bei deutscher tastatur
 If MP_KeyDown(#PB_Key_A)=1  : z=z-0.1 : EndIf ;a #PB_Key_A
 
 MP_PositionEntity (grid, x, y, z) ; Position des Würfel
 MP_TurnEntity (grid, 1, 0, 0) ; Ein bischen drehen
 MP_RenderWorld() ; Erstelle die Welt
 MP_Flip () ; Stelle Sie dar
     
;****************
; Vertices deform
  
For gz = 0 To #subdivisions ;min 1
  
  For gx = 0 To #subdivisions ;min 1
    
     MP_VertexSetz(grid, (gz * (#subdivisions + 1)) + gx, Sin(i + gx / 2 + gz / 2))
     i+0.0001
  
  Next gx
  
Next gz
   

Wend
 
End
 
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 27

Post by mpz »

Hi djes,

nice example and thanks for working with mp3d. The problem must be in the sin function. I have checked my code and found no error. If you reset the i variable, the function works fine again, but i dont know why ;)

Code: Select all

For gz = 0 To #subdivisions ;min 1
  
  For gx = 0 To #subdivisions ;min 1
    
     MP_VertexSetz(grid, (gz * (#subdivisions + 1)) + gx, Sin(i + gx / 2 + gz / 2))
     i+0.0001
    If MP_KeyDown(#PB_Key_R) ; reset i
        i = 0
   EndIf 
  
  Next gx
  
Next gz

The command MP_MeshSetData() was only for some compatibility of PB codes and and has not a good command input error detection. You must set the #PB_Mesh_Vertex with #PB_Mesh_Normal etc etc. in one step. Do you need this function with step by step ?!?

Translation : pitch, yaw, roll : y-axis, x-axis, z-axis ; rectangle, not retangle ; Effect, not Effekt (almost no "k" in english)
Thanks, i need help in this case...


best regards Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 27

Post by djes »

Thanx for reply! Do you have an idea for the frame drop every second?
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 27

Post by mpz »

Hi Djes,

what exactly does it mean "frame drope every second"? If you move the Mesh away does the "frame drope" happens again?!?

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 27

Post by djes »

I have a small lag every second, happening whatever I do. I'll try on another PC.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 27

Post by mpz »

Hi Dijes,

icesoft use the mp3d engine to make games. Have you the same problem with his compiled program too?
http://www.purebasic.fr/english/viewtop ... 69&start=0

i have compiled your "flag program". Does it have the same problem on your pc?
http://www.file-upload.net/download-301 ... g.exe.html

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 27

Post by djes »

No the problem disappeared, the video card is faulty (intel!). For the sin bug, it's a float one, see this : http://www.purebasic.fr/english/viewtop ... 64#p340264
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: MP3D Engine Alpha 27

Post by Rook Zimbabwe »

having some problems doing what I want. I havea wheel and I want to slow the spin down gradually (like decay) but using the friction functions is not working right...

Code: Select all

; Slots Demo 001
;////////////////////////////////////////////////////////////////

; ########   SETUP PLACE HOLDERS FOR EULER ANGLES
Dim rol.l(9) ; ROLL
Global stillspinning
Global turns
Global wheelnumber

; ########## These are the YAW numbers for EACH of the numbers
; based on how the wrapping worked un UU3D...
; don't feel like messing with it so it goes this way...

rol(0)=-255 ; 0
rol(1)=-294 ; 1
rol(2)=-331 ; 2
rol(3)=0 ; 3
rol(4)=-40 ; 4
rol(5)=-73 ; 5
rol(6)=-109 ; 6
rol(7)=-149 ; 7
rol(8)=-184; 8
rol(9)=-222 ; 9

; ########  Randomly position the wheel
wheelend=Random(9)
whee = wheelend
wheel = wheelend * 2
wheelend = wheelend - wheel ; to get negative position number as we want this  direction rotation

Decay.f= 0.01
;////////////////////////////////////////////////////////////////

MP_Graphics3D (800,600,0,1) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "SLOT DEMO 0.1a")

camera=MP_CreateCamera()

light=MP_CreateLight(2)

; ************************************
;- LOAD ALL MESH

Mesh1 = MP_LoadMesh("wheel2.b3d")

;- MESH START POSITIONS

MP_PositionEntity (Mesh1, 0,0,72)

;- MAIN LOOP
InitKeyboard()

HaveWheelsStopped=#False

speed = 1

MP_EntitySetPhysics(Mesh1, 0 , 0 ,0.25)

While Not MP_KeyDown(#PB_Key_Escape) And Not MP_WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
  
  If HaveWheelsStopped=#False
    speed = speed + (20 - decay)
    If speed > 360
      speed = 0
    EndIf
    ;MP_EntitySetPhysics(Mesh1, 0 , 0 ,Decay) ; does not seem to slow wheel down
    MP_RotateEntity(Mesh1,0,speed,0) ; rotate the wheel
    Decay = decay + 0.1
  EndIf
  
  MP_DrawText (1,1,"END :"+ Str(whee))
  MP_DrawText (1,22,"YAW :"+ Str(MP_EntityGetYaw(Mesh1)))
  MP_DrawText (1,44,"Speed:"+ Str(speed))
  MP_DrawText (1,66,"Friction:"+ StrF(Decay,2))
  MP_UpdateWorld()
  MP_RenderWorld()
  MP_Flip ()
  
Wend

End
;- END OF PROGRAM
You can get the model and texture HERE (model and texture must be in same folder!)
http://www.bluemesapc.com/Downloads/wheel.zip
I just want to set up a random speed and then slow the wheel down to 0 while being able to tell the location landed on.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
IceSoft
Addict
Addict
Posts: 1682
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: MP3D Engine Alpha 27

Post by IceSoft »

is this ok for you?
LMB starts the wheel.

Code: Select all

; Slots Demo 001
;////////////////////////////////////////////////////////////////

; ########   SETUP PLACE HOLDERS FOR EULER ANGLES
Dim rol.l(9) ; ROLL
Global stillspinning
Global turns
Global wheelnumber


MP_Graphics3D (800,600,0,1) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "SLOT DEMO 0.1a")

camera=MP_CreateCamera()

light=MP_CreateLight(2)

; ************************************
;- LOAD ALL MESH

Mesh1 = MP_LoadMesh("wheel2.b3d")

;- MESH START POSITIONS

MP_PositionEntity (Mesh1, 0,0,72)


HaveWheelsStopped=#False

speed = 1

;MP_EntitySetPhysics(Mesh1, 0 , 0 ,0.25)
rot.F = 0
deltA.f = 0
HaveWheelsStopped = #True
While Not MP_KeyDown(#PB_Key_Escape) And Not MP_WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
  If MP_MouseButtonDown(0) 
    HaveWheelsStopped = #False
    deltA.f = 50
  EndIf

  If HaveWheelsStopped=#False
    rot = delta
    delta - delta/20
    If delta <= 0
      HaveWheelsStopped = #True
    EndIf
  Else
    rot = 0
  EndIf
  
  MP_TurnEntity(Mesh1, 0, rot, 0) 

  MP_DrawText (1,1,"END :"+ Str(whee))
  MP_DrawText (1,22,"YAW :"+ Str(MP_EntityGetYaw(Mesh1)))
  MP_DrawText (1,44,"Speed:"+ Str(speed))
  MP_DrawText (1,66,"Friction:"+ StrF(rot,2))
  ;MP_UpdateWorld()
  MP_RenderWorld()
  MP_Flip ()
  
Wend

End
;- END OF PROGRAM
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 27

Post by mpz »

Thanks IceSoft,

you found a good solution. The Physik engine is not very good and can't handle weels for now. I will update this in the next time. Now i am working on some nice feature like x64 lib, FX lib and postprocessing...

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 28

Post by mpz »

MP3D Engine Alpha 28

is out

* The most important innovation is the integration of many function of the FXLib by Epyx in mp3D (Thanks to the implementation of Epyx).
* post processing with shader.

Best regards Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 28

Post by djes »

Wow, great :)
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 28

Post by mpz »

Hi Djes,

thanks, in the next version will come some "little" shader like the 5 pass planet shader. This shader has light and bumpmap, nightmap, moving waves and moving clouds
http://www.file-upload.net/download-323 ... r.exe.html

greatings michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: MP3D Engine Alpha 28

Post by djes »

mpz wrote:Hi Djes,

thanks, in the next version will come some "little" shader like the 5 pass planet shader. This shader has light and bumpmap, nightmap, moving waves and moving clouds
http://www.file-upload.net/download-323 ... r.exe.html

greatings michael
Thanks for sharing, great FX! :)
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 28

Post by mpz »

Hi,

i am translating the greate XNA Shader Programming Demos of digitalerr0r to MP3D. I think it is one of the best tutorials in the net fro shader. mp3d has all commands to make the transfer easly. I know it is not the "BIG BIG OGRE" but i think it is fine ;)

XNA Shader Programming – Tutorial 13, Alpha mapping
http://digitalerr0r.wordpress.com/2009/ ... a-mapping/

MP3D Demotranslation:
http://www.file-upload.net/download-324 ... r.exe.html

Greeting Michael
Working on - MP3D Library - PB 5.73 version ready for download
Post Reply