Page 19 of 71

Re: MP3D Engine Alpha 31

Posted: Sun Feb 10, 2013 5:42 pm
by applePi
about pivoting only, i think in the sense it is used in Blitz3D , it is used in MP3D in the form of MP_MeshSetParent(Entity, Parent ).
in the example below the big cube are turning and the smaller will follow it, if we move the big cube up the smaller will follow it, if we press z the big will rotate slightly and the smaller will rotate the same. but scaling the parent does not scale the child, while it do this in Blitz3D, but rotating turning moving and may be more are the success relations between the parent and the follower in MP3D. yes in Blitz3D we can define pivot = CreatePivot() , then earth = CreateSphere(16,pivot)
and put the pivot inside the sun, and whatever it does the earth will follow. in my opinion it is the same as parenting at least from the amateur viewpoint.
the following code to demonstrate this idea are from MP_PlanetMond.pb example , i have caricatured it too much for the purpose of demo.
if you want the smaller cube to rotate around it self just uncomment line 48

Code: Select all

;example MP_PlanetMond.pb experiments version
MP_Graphics3D (640,480,0,3) 
SetWindowTitle(0, "press z to rotate parent, press arrows to move parent") ; Setzt einen Fensternamen

camera=MP_CreateCamera()
light=MP_CreateLight(1) 

Mesh  = MP_CreateCube() 
Mesh2 = MP_CreateCube()


If CreateImage(0, 255, 255) 
   MP_CreateImageColored(0,0,RGB($00,$F0,$00),RGB($00,$F0,$00),RGB($00,$00,$FF),RGB($00,$00,$ff)) ; 
   MP_EntitySetTexture (mesh, MP_ImageToTexture(0))
   MP_CreateImageColored(0,0,RGB($F0,$00,$00),RGB($F0,$00,$00),RGB($00,$FF,$FF),RGB($00,$FF,$FF)) ; 
   MP_EntitySetTexture (mesh2, MP_ImageToTexture(0))
   MP_CreateImageColored(0,0,RGB($00,$00,$F0),RGB($00,$00,$F0),RGB($FF,$00,$00),RGB($FF,$00,$00)) ; 
   MP_EntitySetTexture (mesh3, MP_ImageToTexture(0))
   FreeImage(0)
EndIf

MP_PositionEntity (Mesh,0,0,4) 
MP_RotateEntity(Mesh, 40, 40, 0) 

MP_PositionEntity (Mesh2,0,0,1) 
MP_ScaleEntity (Mesh2, 0.2, 0.2, 0.2 ) 

MP_MeshSetParent(Mesh2,Mesh)

y.f=0:x.f=0: rot.f=40
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow

    If MP_KeyDown(#PB_Key_Up) 
      y + 0.02
     ElseIf MP_KeyDown(#PB_Key_Down) 
       y - 0.02
     ElseIf MP_KeyDown(#PB_Key_Right)
       x=x+0.02
     ElseIf MP_KeyDown(#PB_Key_Left)
       x=x-0.02
     ElseIf MP_KeyDown(#PB_Key_Z)
       rot+1
       MP_RotateEntity(Mesh, 40, rot, 0)  
       ;MP_ScaleMesh(Mesh, 1, 0.9, 1) ; does not scale Mesh2
    EndIf 
    
    MP_PositionEntity (Mesh,x,y,4)
    MP_TurnEntity (Mesh,0.5,0,0) 
    ;MP_TurnEntity (Mesh2,2,0,0) 
    
    MP_RenderWorld() 
    MP_Flip ()

Wend

Re: MP3D Engine Alpha 31

Posted: Sun Feb 10, 2013 9:28 pm
by mpz
Hello,

thanks for your all good help and answers for questions.

to AndyLy » Sat Feb 09, 2013 7:58 am
Hi Mpz!
MP_Close() crashes if I use MP_CopyEntity() in code.
* Thanks for the information, i solved it. I am working on the "dark smoke" particle and will create a new lib when it is done :)

to Psychophanta
you have over 17 camera commands and i dont understand exactly what you mean with pivots. Do you mean the camera View.D3DMATRIX or do you mean the CameraPoint.D3DXVector3, LookAt.D3DXVector3 and UpVector.D3DXVector3. The mp3d was a little work from me to add to the greate purebasic engine an easy using 3d engine like blitz3d. It is not commerzial and it is not a professional 3d engine. So for what do you need these pivots? Have you a little example an i think i find a solution in MP3D.

if you mean the Parent and child funktion applePi gives you a good example...

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Sun Feb 10, 2013 10:27 pm
by AndyLy
Hi, mpz, I started to modeling town for my game and returned to MP3D. So, I wait for the new version.
Image

Re: MP3D Engine Alpha 31

Posted: Sun Feb 10, 2013 10:43 pm
by mpz
Hi AndyLy,

nice screen!

I send you an email with the first "dark particle" example and the solution for the MP_CopyEntity" bug for testing...

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 1:28 am
by AndyLy
I send you an email with the first "dark particle" example
Yes, I received a letter. Look picture. :)
Image

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 9:43 am
by Psychophanta
Many thanks ApplePI and MPZ for your answers.
@ApplePi,
yes, MP_MeshSetParent(Mesh2,Mesh) is what i meant with "pivot", so one of my points is solved :)

@MPZ,
For the pivot AplePi gave the solution. The example he posted is enough to show it.
For the unit vectors for camera direction, i need the three unit vectors LookAt.D3DXVector3, UpVector.D3DXVector3 and RightVector.D3DXVector3 (only 2 of them would be enough, as the other one would be the cross product of both).
How can i access to them?

Apart of all it, how to make lines3D? i am not able to find it in the manual.

Thanks a lot!

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 2:28 pm
by AndyLy
Psychophanta, why do you need 3d line? If you want to make something like a laser beam, I want it too.
If find out how - write here, please.

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 3:25 pm
by applePi
the MP_Primitives.pb in the "MP3D Demos\Mesh" folder can be considered a demo for Line 3D, look the help about MP_CreatePrimitives() , once the Line 3D established as an Entity we can apply to it rotation, moving else. we can move this Line in Z direction using MP_EntitySetZ (Entity, z) in the real time.

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 5:34 pm
by Psychophanta
applePi wrote:the MP_Primitives.pb in the "MP3D Demos\Mesh" folder can be considered a demo for Line 3D, look the help about MP_CreatePrimitives() , once the Line 3D established as an Entity we can apply to it rotation, moving else. we can move this Line in Z direction using MP_EntitySetZ (Entity, z) in the real time.
Awesome!
It is much more versatile way than DM3D.
Now i just need the unit vectors of the camera view and to test how quick is the lib.

@AndyLy
I use lines mostly for drawing arrows as vectors.

maximum number of points in POINTLIST in MP_CreatePrimitives

Posted: Mon Feb 11, 2013 8:41 pm
by applePi
first i hope the Psychophanta question about the vectors of the camera will not be hidden by me or AndyLy posts.
while looking at the line 3d capability i have noticed a point 3D graphics, and really it is great to have a cloud of many points in 3D. but it seems that it is limited to 999 points. and if we want 1000 points it will not be displayed. so is it a limitation, and if it is not a limitation i wish to increase the number to thousands of points.
below is the program to show the case for 999 points, replace it with 1000 and you will not see anything.
Edit: @Psychophanta, you may find the example "MP_Mesh_Create.pb" in Mesh folder useful for drawing arrows , all the day and i was trying to remember where that example which have arrows on it, and after closing my computer i remember it.

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 (999, 1) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity, 200)
For i=0 To 999
  MP_SetPrimitives(Entity, i,  Random(200,0), Random(200,0), Random(200,0),  $FFFFFFFF)
Next

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

    MP_TurnEntity (Entity,1,1,0) ; dreh den Würfel
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 10:48 pm
by mpz
Hi to all,

to Psychophanta
i dont want to make new commands to read the camera vectors. So i think for now it is possible to use a pointer an the camera structures to get them. For my opinion you have enough mp_camera_commands, but do what you want and need, i help you ;)

Code: Select all

Structure D3DMATRIX
    _11.f : _12.f : _13.f : _14.f
    _21.f : _22.f : _23.f : _24.f
    _31.f : _32.f : _33.f : _34.f
    _41.f : _42.f : _43.f : _44.f
EndStructure

Structure D3DXVECTOR3
    x.f
    y.f
    z.f
EndStructure

Structure Grad
    XGrad.f 
    YGrad.f 
    ZGrad.f 
EndStructure

Structure Camera ; here it is the camera structure 
    kind.i                  ; kind = 4 = camera (meshs and other entitys have other numbers   
    World.D3DMATRIX         ; MP3D WorldMatrix
    fovy.f                  ; Field of view in the y direction
    zn.f                    ; Z-value of the near view-plane
    zf.f                    ; Z-value of the far view-plane
    View.D3DMATRIX          ; view matrix
    ViewI.D3DMATRIX         ; inverse view matrix needed for shader
    CameraPoint.D3DXVector3 ; position in 3d room
    LookAt.D3DXVector3      ; look at in 3d room
    UpVector.D3DXVector3    ; where is the sky n 3d room
    CameraGrad.Grad         ; x,y,z-directions in grad
    active.b                ; not used for now
EndStructure 


*test.camera = MP_CreateCamera()

;*test\CameraPoint\x = 0 ; x Position of camera
;*test\CameraPoint\y = 0 ; y Position of camera
;*test\CameraPoint\z = 0 ; z Position of camera
      
;*test\LookAt\x = 0;0.0
;*test\LookAt\y = 0;0.0
;*test\LookAt\z = 1;0.0
      
;*test\UpVector\x = 0;x ;0.0
;*test\UpVector\y = 1;y ;1.0
;*test\UpVector\z = 0;z ;0.0
    
;D3DXMatrixLookAtLH(*test\View, *test\CameraPoint, *test\LookAt, *test\UpVector) ; Create the View Matr
to applePi

Yes i limmited the VertexCount of one primitive to 1000. If you want i can make more points in one primitves, but all need dx9 grafikcard ram and so i thought 1000 is very very big :oops:

In your code you can use two primitves for example and then you have 2000 points. But if you need more, i can make more VertexCounts in the next lib. How many do you need? 8)

Code with 2000 Vertexcounts

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 (999, 1) ; 6 Vertexe und LINELIST (einzelne Linien)
Entity2 = MP_CreatePrimitives (999, 1) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity, 200)
MP_EntitySetZ (Entity2, 200)

For i=0 To 999
  MP_SetPrimitives(Entity, i,  Random(200), Random(200), Random(200),  $FFFFFFFF)
Next
For i=0 To 999
  MP_SetPrimitives(Entity2, i,  Random(200), Random(200), Random(200),  $FFFFFFFF)
Next

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

    MP_TurnEntity (Entity,1,1,0) ; dreh den Würfel
    MP_TurnEntity (Entity2,1,1,0) ; dreh den Würfel
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend
Greetings Michael

Re: maximum number of points in POINTLIST in MP_CreatePrimit

Posted: Mon Feb 11, 2013 11:05 pm
by Psychophanta
applePi wrote:@Psychophanta, you may find the example "MP_Mesh_Create.pb" in Mesh folder useful for drawing arrows , all the day and i was trying to remember where that example which have arrows on it, and after closing my computer i remember it.
Eheh!, nice idea, thanks!

@mpz,
of course, please don't make more commands, in opposit: you should remove some of them, as i wrote above in other post.
mpz wrote:Hi to all,

to Psychophanta
i dont want to make new commands to read the camera vectors. So i think for now it is possible to use a pointer an the camera structures to get them. For my opinion you have enough mp_camera_commands, but do what you want and need, i help you ;)

Code: Select all

Structure D3DMATRIX
    _11.f : _12.f : _13.f : _14.f
    _21.f : _22.f : _23.f : _24.f
    _31.f : _32.f : _33.f : _34.f
    _41.f : _42.f : _43.f : _44.f
EndStructure

Structure D3DXVECTOR3
    x.f
    y.f
    z.f
EndStructure

Structure Grad
    XGrad.f 
    YGrad.f 
    ZGrad.f 
EndStructure

Structure Camera ; here it is the camera structure 
    kind.i                  ; kind = 4 = camera (meshs and other entitys have other numbers   
    World.D3DMATRIX         ; MP3D WorldMatrix
    fovy.f                  ; Field of view in the y direction
    zn.f                    ; Z-value of the near view-plane
    zf.f                    ; Z-value of the far view-plane
    View.D3DMATRIX          ; view matrix
    ViewI.D3DMATRIX         ; inverse view matrix needed for shader
    CameraPoint.D3DXVector3 ; position in 3d room
    LookAt.D3DXVector3      ; look at in 3d room
    UpVector.D3DXVector3    ; where is the sky n 3d room
    CameraGrad.Grad         ; x,y,z-directions in grad
    active.b                ; not used for now
EndStructure 


*test.camera = MP_CreateCamera()

;*test\CameraPoint\x = 0 ; x Position of camera
;*test\CameraPoint\y = 0 ; x Position of camera
;*test\CameraPoint\z = 0 ; x Position of camera
      
;*test\LookAt\x = 0;0.0
;*test\LookAt\y = 0;0.0
;*test\LookAt\z = 1;0.0
      
;*test\UpVector\x = 0;x ;0.0
;*test\UpVector\y = 1;y ;1.0
;*test\UpVector\z = 0;z ;0.0
    
;D3DXMatrixLookAtLH(*test\View, *test\CameraPoint, *test\LookAt, *test\UpVector) ; Create the View Matr
Please, please, please:
write in the manual about these structures and other interesting info and stuff, because It would be extremely useful to use it directly sometimes, avoiding using functions instead.

Re: MP3D Engine Alpha 31

Posted: Mon Feb 11, 2013 11:39 pm
by mpz
Hi Psychophanta,

i think about that informations for the help file. My strcutures are not very proffessional and look sometimes a little bit crasy and i have changed some of them if i needed more functionality. I have also created a "fast" Structure to change mesh/animmesh/primitives/particleemitter with one one structure. I will make an infromation in the help file for that in the next lib version...

I dont want to use structures and pointer, because it is easy to make a big bug and big crash with it in a 3d program. With the mp3d commands you can't crash the program. If the Entity doesn exist, nothing happens, but if you use pointers, "halleluja sag i" :lol:

* * *
pot = MP_CreateTeapot()
MP_PositionEntity (pott,-3,0,10) ; pott doesnt exist, nothing happens
* * *

*pot.mesh
*pott = MP_CreateTeapot()
*pot\position\_41 = 17 ; *pot is 0 and the crash will come

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Tue Feb 12, 2013 10:02 am
by applePi
Hi Michael
thanks for the solution of adding more Enitities for Points lists.
this can be of usage. but the example MeshManual2.pb from the PB ogre examples (C:\PureBasic\Examples\3D) have recently in pb v5.10 added the ability to display thousands of points (without limitation) i have just tried it with 100000 points and my graphics card are Geforce 210 on a slow celeron desktop. so it may be DX have also this feature. the usage may be not for games but for demonstrations such as plotting data in 3D in wich the data can be huge.
as an example, i will reproduced partly the example i have posted recently here http://www.purebasic.fr/english/viewtop ... 59#p402796
for reading image pixels then plotting it as 2D inside 3D so we can move or rotate it. here i will use this Picture .....
and because of the Point list limitation i have added 4 Entities for points Lists, and still can't draw all the picture but part of it. so this is make difficult to plot huge data in 3D. i know nothing about DirectX 3D. so you may look at this problem.
PS: i have tried your alpha version 32 and it is great, i like the new feature of displaying live movies on the faces of a rotating cube.
the code demo needs this Picture ..... to show the case, the image reading algorithm are from rashad code mentioned in the above link

Code: Select all

MP_Graphics3D (640,480,0,3)
SetWindowTitle(0, "Show Primitives") 

camera=MP_CreateCamera()

Entity = MP_CreatePrimitives (999, 1) 
Entity2 = MP_CreatePrimitives (999, 1)
Entity3 = MP_CreatePrimitives (999, 1)
Entity4 = MP_CreatePrimitives (999, 1)

;MP_EntitySetZ (Entity, 200)
Define image_id.i

; load image
image_id = LoadImage( #PB_Any, "einstein2.bmp" )
Dim image_pixel_data.b( ImageWidth(image_id), ImageHeight(image_id) )

StartDrawing( ImageOutput( image_id ) )

For y = 0 To ImageHeight(image_id) - 1
  For x = 0 To ImageWidth(image_id) - 1
    If Point( x, y )<> 16777215
      i+1
      ImagePart = Int(i/999)
      Select ImagePart
        Case 0 
          i1+1
        MP_SetPrimitives(Entity, i1,  x, y, 0,  RGB(255,255,0))
      Case 1
        i2+1
          MP_SetPrimitives(Entity2, i2,  x, y, 0,  RGB(255,255,0))
        Case 2
          i3+1
          MP_SetPrimitives(Entity3, i3,  x, y, 0,  RGB(255,255,0))
        Case 3
          i4+1
          MP_SetPrimitives(Entity4, i4,  x, y, 0,  RGB(255,255,0))
       EndSelect
      
      
    EndIf
    Next x
  Next y
   
StopDrawing()
MP_PositionEntity(Entity, 0, 30, 300)
MP_RotateEntity(Entity,0,135,0)

MP_PositionEntity(Entity2, 0, 30, 300)
MP_RotateEntity(Entity2,0,135,0)

MP_PositionEntity(Entity3, 0, 30, 300)
MP_RotateEntity(Entity3,0,135,0)

MP_PositionEntity(Entity4, 0, 30, 300)
MP_RotateEntity(Entity4,0,135,0)


While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
    
  MP_TurnEntity (Entity,0,1,1) 
  MP_TurnEntity (Entity2,0,1,1)
  MP_TurnEntity (Entity3,0,1,1)
  MP_TurnEntity (Entity4,0,1,1)
  MP_RenderWorld() 
  MP_Flip () 

Wend
  

Re: MP3D Engine Alpha 31

Posted: Tue Feb 12, 2013 10:19 am
by mpz
Hi applePi,

nice Demo, thanks...

Okay okay i will disable the limit of VertexCounts completly (and hope nobody use millions of VertexCounts to crahs the program :lol: ). I update the "alpha version 32" in the forum in the next days.

P.S. But ther are some bugs and some missing features so it is only beta state...

P.S.P.S perhaps i find a way to save the primitives as directx mesh. This could be a nice feature

Greetings Michael