MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 31

Post by Psychophanta »

AndyLy wrote:Psychophanta
Do not be so strict with Michael. He does what he can and does it well. Bugs and flaws exist in all programs. Even in professional.
Maybe not tomorrow, not next year, but he will finish the engine to fine state. I believe in him.
Agree, no problem, just made a little pressure to him :twisted:

By the way, there is also a bug in MP_MoveCamera():
Like this it works nice:

Code: Select all

If MouseWheel
  MP_PositionCamera(*camera,*camera\CameraPoint\x+*camera\view\_13*MouseWheel,*camera\CameraPoint\y+*camera\view\_23*MouseWheel,*camera\CameraPoint\z+*camera\view\_33*MouseWheel)
EndIf
But like this it should work in the same way but it does not:

Code: Select all

If MouseWheel
  MP_MoveCamera(*camera,*camera\view\_13*MouseWheel,*camera\view\_23*MouseWheel,*camera\view\_33*MouseWheel); no funciona
EndIf
One more thing, as a request: please treat camera just as another entity so commands like MP_PositionCamera(), MP_MoveCamera(), etc. should not exist, as there are MP_PositionEntity(), MP_MoveEntity(), etc.
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 31

Post by mpz »

Dear Psychophanta,

i had a discusion in the german forum and the problem was not the x,y,z coords. The

MP_PositionEntity (Mesh,x,y,z) command work correct. The problem ist the

MP_TurnEntity(Entity, pitch.f, yaw.f, roll.f) command. the variables
pitch.f, yaw.f, roll.f works is in my opinion with MP32 correct now, please see

http://en.wikipedia.org/wiki/Degrees_of ... chanics%29

If you find an mistake or an error, please say it.

MP3D_32 and bugs? oh noooooo. I say "it is not a bug.... ist a feature" :lol:

@Psychophanta "Primitives object (entity) is not able to be hidden". I will install these bug ähhh feature in the mp3D_32 too

With your helps, the mp3d will be better and better, Thanks ;)

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 31

Post by Psychophanta »

mpz wrote: MP_PositionEntity (Mesh,x,y,z) command work correct. The problem ist the

MP_TurnEntity(Entity, pitch.f, yaw.f, roll.f) command. the variables
pitch.f, yaw.f, roll.f works is in my opinion with MP32 correct now, please see

http://en.wikipedia.org/wiki/Degrees_of ... chanics%29

If you find an mistake or an error, please say it.

MP3D_32 and bugs? oh noooooo. I say "it is not a bug.... ist a feature" :lol:
:lol:

Ok , is MP_TurnEntity() healthy?, if yes, then native meshes like MP_CreateCube() or MP_CreatePyramid(), and maybe others, are bad. Run this code AS IS, and tell me; Do you think this is a 'Yaw' modification????:
(apart of it, look at the comments in code please, and play with it)

Code: Select all

MP_Graphics3D (640,480,0,3)
SetWindowTitle(0,"Rotiere Textur auf Würfel")
camera=MP_CreateCamera()
light=MP_CreateLight(1)
Mesh=MP_CreateCube()
;Just Now to do this:
; MP_TurnEntity(Mesh,-180,0,-90)
;should give the same result that:
; MP_RotateEntity(Mesh,-180,0,-90)
;but it does not, so i see MP_TurnEntity() seems to not work correctly
MP_PositionEntity(Mesh,0,0,0)
MP_PositionCamera(camera,0,0,-4)
MP_CameraLookAt(camera,MP_EntityGetX(Mesh),MP_EntityGetY(Mesh),MP_EntityGetZ(Mesh))
While MP_KeyUp(#PB_Key_Escape)
  MP_TurnEntity(Mesh,0,1,0)
  MP_RenderWorld():MP_Flip()
Wend
Well, please don't forget to fix MP_MoveCamera() command, look at my previous post.

EDIT: I forgot to say MP_MeshSetParent() seem not works for Primitives.

EDIT2: To move Entities positions around world, the ideal is 2 only commands:
MP_MoveEntity(). Moves an entity relative to its current position and orientation.
MP_TranslateEntity(). Moves an entity relative to its current position disregarding orientation.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
marc_256
Addict
Addict
Posts: 835
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: MP3D Engine Alpha 31

Post by marc_256 »

Hi mpz, and all other mp31 users,

I like to use your 3D program for some 3D tests.
I downloaded your mpz_v31 and installed it.
than I copied the files to my new installed PB510Final sub dirs
- PB510Final\PureLibraries\Windows\Libraries\
- PB510Final\SubSystems\DX9\PureLibraries\UserLibraries\MP3D_Library
- and the d3dx9d_43.dll file to my c:\Windows\system32\ SubDir

When i start your demos,
I get the error file d3dx9d_43.dll not found

DX9c is already installed on my PC Win/XP sp3 for playing some games...

Sorry for asking :oops: , what can be the problem ?

Marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 31

Post by Psychophanta »

marc_256 wrote:Hi mpz, and all other mp31 users,

I like to use your 3D program for some 3D tests.
I downloaded your mpz_v31 and installed it.
than I copied the files to my new installed PB510Final sub dirs
- PB510Final\PureLibraries\Windows\Libraries\
- PB510Final\SubSystems\DX9\PureLibraries\UserLibraries\MP3D_Library
- and the d3dx9d_43.dll file to my c:\Windows\system32\ SubDir

When i start your demos,
I get the error file d3dx9d_43.dll not found

DX9c is already installed on my PC Win/XP sp3 for playing some games...

Sorry for asking :oops: , what can be the problem ?

Marc,
After a correct installation of the pack I had to put a copy of d3dx9d_43.dll into the system32 directory and rename it to d3dx9_43.dll
(I run it on PB5.00, as in the 5.10 it does not work)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
marc_256
Addict
Addict
Posts: 835
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: MP3D Engine Alpha 31

Post by marc_256 »

Hi Psychophanta,

Sorry, I did not corrected the file name to d3dx9_43.dll in place of d3dx9d_43.dll
It works very well now with PB510Final
Thanks for helping here,
marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Dear Psychophanta,

i understand now the problem. It is not the pitch,yaw and roll problem ist is a function i build in. Please see the MP_VSyncDemo.pb program. If you have "vsync off" the cube must speed up fery fast (6000 loops per second). Do solfe this problem i use a time function:

ProcedureDLL MP_TurnEntity (Entity, pitch.f, yaw.f, roll.f,flag) ;

pitch = pitch * 60 * fElpasedAppTime
yaw = yaw * 60 * fElpasedAppTime
roll = roll * 60 * fElpasedAppTime
...
EndProcedure


But this function is not very exactly, so the with MP_TurnEntity you get:
pitch = -172.80000305175781
yaw = 0.0
roll = -86.40000152587891

with MP_RotateEntity (has not the time function)
pitch = -180
yaw = 0.0
roll = -90

I want to move the objects regardless from the frame rate and vsync.

I use these function in
MP_MoveCamera
MP_TurnCamera
MP_MoveEntity
MP_TurnEntity
MP_TurnSprite

too. I must think about a solution for that. The time fiunction works not very well and i must chnage it. Perhaps anybody has an idea too?

EDIT: I forgot to say MP_MeshSetParent() seem not works for Primitives.
* I can add these funtion in the next version mp32_32 too

EDIT2: To move Entities positions around world, the ideal is 2 only commands:
MP_MoveEntity(). Moves an entity relative to its current position and orientation.
MP_TranslateEntity(). Moves an entity relative to its current position disregarding orientation.

* To turn an objekt you have flag=0 for absolute angel and flag = 1 to relative angel. Test this and use then move command please
* MP_TurnEntity (Entity, pitch, yaw, roll, flag = 1) and MP_RotateEntity (Entity, pitch, yaw, roll, flag = 1)

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 31

Post by mpz »

Hello Psychophanta,

i have deactivated the function to move the objects regardless from the frame rate and vsync. Now you can activate this function with MP_VSync(3) and deactivate it (standard) with MP_VSync(4). The new alpatest version do you find in the m3d forum. Please test this, i think it work now and solve the camer problems too.
For now i have two fuction to create the parent functions: MP_MeshSetParent and MP_PrimitivesSetParent. I think the next step is it to create for that only one command like MP_EntitySetParent. Then yoi can mix mesh and primitves as parent - kid too..

Primitves with parent

Code: Select all

MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "Show Primitives") ; Setzt einen Fensternamen

camera=MP_CreateCamera() ; Kamera erstellen

Entity = MP_CreatePrimitives (6, 2) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity, 8)
    
MP_SetPrimitives(Entity, 0,  0, 2, 0,  $FFFFFFFF)
MP_SetPrimitives(Entity, 1,  0, -2, 0, $FF0000FF)
MP_SetPrimitives(Entity, 2,  -2, 0, 0, $FF00FF00)
MP_SetPrimitives(Entity, 3, 2, 0, 0,   $FF00FFFF)    
MP_SetPrimitives(Entity, 4, 0, 0, 2,   $FFFF0000) 
MP_SetPrimitives(Entity, 5, 0, 0, -2,  $FFFF00FF)    

Entity2 = MP_CreatePrimitives (6, 2) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity2, 2)
    
MP_SetPrimitives(Entity2, 0,  0, 1, 0,  $FFFFFFFF)
MP_SetPrimitives(Entity2, 1,  0, -1, 0, $FF0000FF)
MP_SetPrimitives(Entity2, 2,  -1, 0, 0, $FF00FF00)
MP_SetPrimitives(Entity2, 3, 1, 0, 0,   $FF00FFFF)    
MP_SetPrimitives(Entity2, 4, 0, 0, 1,   $FFFF0000) 
MP_SetPrimitives(Entity2, 5, 0, 0, -1,  $FFFF00FF)    

MP_PrimitivesSetParent (Entity2, Entity)

Entity3 = MP_CreatePrimitives (6, 2) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity3, -2)
    
MP_SetPrimitives(Entity3, 0,  0, 1, 0,  $FFFFFFFF)
MP_SetPrimitives(Entity3, 1,  0, -1, 0, $FF0000FF)
MP_SetPrimitives(Entity3, 2,  -1, 0, 0, $FF00FF00)
MP_SetPrimitives(Entity3, 3, 1, 0, 0,   $FF00FFFF)    
MP_SetPrimitives(Entity3, 4, 0, 0, 1,   $FFFF0000) 
MP_SetPrimitives(Entity3, 5, 0, 0, -1,  $FFFF00FF)    

MP_PrimitivesSetParent (Entity3, Entity)

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen

    MP_TurnEntity (Entity,0.1,0.1,0.1) ; dreh den Würfel
    MP_TurnEntity (Entity2,0.5,0.5,0.5) ; dreh den Würfel
    MP_TurnEntity (Entity3,-0.5,-0.5,-0.5) ; dreh den Würfel
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend
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 31

Post by applePi »

Thanks Michael, the demo above are Beautiful, i will make experiments tomorrow. you need to correct some examples to be compatible with the new version when you issue the looong awaited v32 such as "MP_ChessShadow.pb" in shadow folder it display the black pieces of the chess upside down.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 31

Post by Psychophanta »

Thanks mpz,
i will test it!
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 31

Post by mpz »

Hi applePi,

yes, the Demos and the help file will be much work for me.

P.S: "MP_ChessShadow.pb" please change the command MP_RotateEntity (e, 180,0,0) with MP_RotateEntity (e, 0,180,0) and everything works fine

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: MP3D Engine Alpha 31

Post by IdeasVacuum »

Hello mpz

PB's 3D viewing defaults to perspective. It has a Camera Mode that can switch from perspective to orthographic, but in PB5.10 the command fails (also causes the app to crash eventually http://www.purebasic.fr/english/viewtop ... =4&t=53567).

So, the multi-million dollar question is - does the MP3D Engine have an orthographic view mode?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 31

Post by applePi »

here is the plotting of the mandelbrot set 3D in MP3D. look my previous post http://www.purebasic.fr/english/viewtop ... 36&t=53558 about it in PB Ogre.
i have a few none essential problems:
1- there must a line like this
sphere = MP_CreateSphere(30) "code Line 11"
comment it and we can't see the colored points. is it a bug ?
2- is it possible to have thicker points ?? can be usefull in a less points numbers, it is possible in ogre as demonstrated in my previous pb ogre code.
the iterations here is 2 million, you can change it in Line 105 to less numbers to speed calculations.
if you want julia set change line 41 to mand = 0
you must download the latest "MP3D_Library" file http://www.morty-productions.de/gamedev ... hp?tid=145 and replace the original in C:\PureBasic\SubSystems\DX9\purelibraries\userlibraries
the execution time is about 12 seconds on my pc

Code: Select all

Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "Mandel 3D, press Z, X keys to shift picture")
;MP_Wireframe(1)
camera=MP_CreateCamera()

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

sphere = MP_CreateSphere(30)

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

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

Global Entity= MP_CreatePrimitives (2000000, 1)   
  
Global.f dx, dy, x, y, z
Global wd, ht, i, count, n, iter
Global.f w, leng, tx, ty, tz, tem
Global.f cr, ci, cj, ck, wk, inc, distance
Global mand, zval
Global.f angle
Define.f red, green, blue
;zval = 1 shows entire set
;zval = 0 cuts set in half
;zval = 0 is an interesting effect
wd = 500
ht = 500
;defines the shape of the Julia Set
cr = -0.200
ci = 0.800
cj = 0.000
ck = 0.000
wk = 0.000
;mand = 0 is Julia Set
;mand = 1 is Mandelbrot 3D
mand = 1
;zval = 1 shows entire set
;zval = 0 cuts set in half
;zval = 0 is an interesting effect
zval = 1
iter = 5
inc = 5 
;#quat = 1
zval = 1
iter = 5
inc = 5 
Procedure.f RandF(Min.f, Max.f, Resolution.i = 10000)
  ProcedureReturn (Min + (Max - Min) * Random(Resolution) / Resolution)
EndProcedure

Quit.b = #False
rot.l=1 :stopFlag = 1
xs.f = 0.3:ys.f = 0.3:zs.f = 0.3
x.f: y.f :z.f: x0.f: y0.f=1 :z0.f
rotx.f:roty.f=1:rotz.f :rotx0.f: roty0.f: rotz0.f
up.f = 2.2: depth.f=0

;==============================================================

;
Procedure.f calcleng( x.f,  y.f,  z.f)
    w.f: kr.f: ki.f: kj.f: kk.f
    w = wk
    n = 0
    If mand = 1  ;full Mandelbrot set
        kr = x
        ki = y
        kj = z
        kk = 0
    Else                ;else draw Julia Set
        kr = cr
        ki = ci
        kj = cj
        kk = ck
    EndIf
    
    While n < iter
        tem = x+x
        x = x*x-y*y-z*z-w*w+kr
        y = tem*y + ki
        z = tem*z + kj
        w = tem*w + kk
        
        n+1
        distance = x*x+y*y+z*z+w*w
        
        If distance > 4 
          n = iter
        EndIf
        
    Wend
        
    ;Return distance
    ProcedureReturn distance
  
EndProcedure

zz.f
    foo.l
    iterations = 2000000
    count = 0
    
    If zval = 0
        zz = 2.0
    Else
        zz = 4.0
    EndIf
      
      For foo = 0 To iterations
          ;x.f = RandF(0, 1)
          ;y.f = RandF(0, 1)
          x.f = RandF(-2, 2)
          y.f = RandF(-2, 2)
          
          z.f = zz*RandF(0, 1) -2.0
          
          ;calls the quaternion calculation
          leng.f = calcleng(x,y,z)
          
          If leng < 4 
              ;MeshVertexPosition(x, y, z)
              red = (x+Cos(15*leng))*255
              green = (y+Sin(1-leng)*Cos(5*leng))*255
              blue = (z+Sin(0.75*leng))*255
              If red < 0 : red = 0 : EndIf
              If green < 0 : green = 0 : EndIf
              If blue < 0 : blue = 0 : EndIf
              If red > 255 : red = red-255 : EndIf
              If green > 255 : green = green-255 : EndIf
              If blue > 255 : blue = blue-255 : EndIf
              
              ;MeshVertexColor(RGBA(red,green,blue,0))
              ;MeshVertexColor(RGB(red,green,blue))
              ;;=======================================
              ;rd=MP_Red(Point( x, y ))
              ;gr=MP_Green(Point( x, y ))
              ;bl=MP_Blue(Point( x, y ))
              ;pixColor = Point( x, y )
              i+1
              ;Debug x
              ;Debug y
              ;Debug z
              ;Debug i
              MP_SetPrimitives(Entity, i,  x, y, z,  MP_ARGB(0,red,green,blue))
                           
          EndIf
          
        Next 
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
;MP_MeshSetAlpha(Entity,2)


MP_PositionCamera(camera, 0, 0, 10)
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_Z) 
    xx.f + 0.1
    zz.f + 0.1
  ElseIf MP_KeyDown(#PB_Key_X) 
    xx.f - 0.1
    zz.f - 0.1
  EndIf 
      
    MP_PositionEntity(Entity, xx, 0, zz)
    MP_TurnEntity(Entity,0,1,0) 
   
  MP_RenderWorld()
   
  MP_Flip ()

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

Re: MP3D Engine Alpha 31

Post by mpz »

Hello,

@IdeasVacuum , i am sorry but i dont know exactl ywhat you mean with orthographic view mode ?!? is it a 3d view without z-Buffer ?!?!

@applePi

Greate Code !!!!

I am working on some new Primitives function. Now you can make parent kid with mesh and primitives. I solved a z-Buffer Bug

To 1) You have activated the MP_InitShadow() ! With these function i have 6 fps, without them i have 60 fps!! This means realtime view. Please deactivate the following lines

;MP_InitShadow()
;sphere = MP_CreateSphere(30)
;MP_PositionCamera(camera, 0, 5, 10)
;MP_CameraLookAt(camera,0,0,0)

It is a problem with the shadow function and primitives. i will check this and work on a new shadow function...

To 2) thicker points, i will have a look on it. Which function do you use for thicker points in Ogre ?!? What does this mean?

P.S: i change it from 2 Millions to 4 Millions points i have also 60 fps too. But with over 4 Millions Points it is not possible to create a primitives buffer...

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: MP3D Engine Alpha 31

Post by IdeasVacuum »

Hi mpz - I think that is maybe a no then? :mrgreen:

PB's default view mode: Perspective
Image

Alternative view mode (used in Engineering): Orthographic
Image
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply