Page 36 of 71

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 8:15 pm
by mpz
Hello ApplePi,

what can i say...
Thanks for you good demos and great work. You ask for new physics commands and i have made them, You find the new beta libs in my forum

27) new function added: MP_LimitHingeAngle (Entity, Angle.f) ; limits the angle of a hinge
28) new function added: MP_LimitSliderDistance (Entity, mfMaxDistance.f,mfMinDistance.f) ; Limited the slider distance
http://www.morty-productions.de/gamedev ... hp?tid=160

You problem:
and if we use big stones it will last more than small stones.
something for Michael to solve. -> i will have a look on you example and hope i understand the problem...

the following examples has now the new commands MP_LimitHingeAngle and MP_LimitSliderDistance, i hope thi sshows the new commands good

Code: Select all

 MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
 SetWindowTitle(0, "press left right to rotate")

 camera = MP_CreateCamera()    ; Kamera erstellen

 MP_PositionCamera(camera, 0, 4, -5 )
 MP_CameraLookAt(camera,0,0,0)

 light= MP_CreateLight(0)    ; Es werde Licht
 
 texture = MP_CreateTextureColor(256, 256, RGBA(0, 0, 255, 255))
 plane = MP_CreatePlane(10, 10)
 MP_EntitySetTexture(plane, texture)
 MP_PositionEntity (plane,0,-3,0)
 MP_RotateEntity(plane, 90, 0, 0)
 
 block1 = MP_CreateCube() ; just heavy blocks on the ground
 block2 = MP_CreateCube()
 MP_PositionEntity (block1,3.3,0,0)
 MP_PositionEntity (block2,-3.3,0,0)
 
 Global body = MP_CreateRectangle(0.5,2,0.5)
 MP_RotateEntity(body, 0, 0, 90 )
 
 Global Mesh = MP_CreateCylinder(10,1)
 MP_ResizeMesh(Mesh,0.25,0.25,4)
 MP_RotateEntity(Mesh, 0, 90, 0 )

 block3 = MP_CreateCube()  ; b;ocks attached to the cylinder
 block4 = MP_CreateCube()
 MP_ResizeMesh(block3,0.6,0.6,1)
 MP_PositionEntity (block3,0,0,2)
 MP_ChangeMeshCoord(block3 )
 MP_AddMesh(block3 , Mesh ) : MP_FreeEntity(block3)
 MP_ResizeMesh(block4,0.6,0.6,1)
 MP_PositionEntity (block4,0,0,-2)
 MP_ChangeMeshCoord(block4 )
 MP_AddMesh(block4 , Mesh ) : MP_FreeEntity(block4)
 
 MP_EntitySetNormals (Mesh)
 MP_MaterialDiffuseColor (Mesh,255,255,128,50)
 MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
 sliderX.f=0:sliderY.f=0:sliderZ.f=0
 hingX.f=0:hingY.f=0:hingZ.f=1
 
 MP_PositionEntity (Mesh,sliderX,sliderY,sliderZ)
 MP_PositionEntity (body,sliderX,sliderY,sliderZ)
 
 MP_PhysicInit()


 MP_EntityPhysicBody(Mesh , 4, 10)
 MP_EntityPhysicBody(body , 4, 10)
 NewMaterial = MP_CreatePhysicMaterial()
 ;MP_SetPhysicMaterialProperties(MaterialID1, Elasticity.f, staticFriction.f, kineticFriction.f [, MaterialID2])
 MP_SetPhysicMaterialProperties(NewMaterial,0,2,2)
 MP_SetPhysicMaterialtoMesh (body, NewMaterial)
 MP_SetPhysicMaterialtoMesh (Mesh, NewMaterial)
 
 MP_ConstraintCreateHinge (body,0,0,1,hingX,hingY,hingZ)
 
 MP_LimitHingeAngle (body, 90)
 
 
 ;MP_EntitySetGravity(Mesh, 0 , -1 ,0)
 MP_EntityPhysicBody(plane , 1, 1)
 MP_SetPhysicMaterialtoMesh (plane, NewMaterial)
 MP_EntityPhysicBody(Block1 , 2, 100)
 MP_EntityPhysicBody(Block2 , 2, 100)

 MP_ConstraintCreateSlider (Mesh,1,0,0 ,sliderX,sliderY,sliderZ, body) ; create a slider joint functions
 
 MP_LimitSliderDistance (Mesh, 0.1,-0.1)
 
 MP_AmbientSetLight (RGB(0,100,200))

 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   
   If MP_KeyDown(#PB_Key_Right)
     MP_MoveEntity(Mesh, 0, 0, 0.1)

     ;MP_EntityAddImpulse(body, 0, -2, 0 , 1.0,0, 0)
     
   ElseIf MP_KeyDown(#PB_Key_Left)
     MP_MoveEntity(Mesh, 0, 0, -0.1)
     ;MP_EntityAddImpulse(body, 0, -2, 0 , -1.0,0, 0)
   EndIf
   ;omega.f=0.01
     ;MP_EntitySetOmega(body, 0 , 0 ,-1)
     MP_PhysicUpdate()
     
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 8:22 pm
by Mythros
Hi, @mpz! EXCELLENT job as always! However, is there a way you can add Carmine 1.09 (OpenNI2) / Kinect support?

Also, is there a way to create a streaming AVI video attached to a 3D model's texture?

If so, that would be GREAT!

Thanks ALOT, Mpz!

Keep up the good work!

You've officially avoided the pumpkin once again :3

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 8:34 pm
by applePi
thanks Michael very much, i have tried the example and its great with the new addition since the MP_LimitSliderDistance and MP_LimitHingeAngle are necessary . i will do experiments tomorrow.
best regards

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 8:45 pm
by mpz
Hi Mythros,

question "add Carmine 1.09 (OpenNI2) / Kinect support", to include a library for a "Kinect"device is not the problem, but i dont have "Kinect" device and cant test this.

question "create a streaming AVI video attached to a 3D model's texture" -> Have ayou a streaming avi for testing? With "normal avi files it works" see the MP_Moviedemo.pb demo...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 9:49 pm
by Mythros
Hi, @mpz. I am 100% willing to test it until I can't test it anymore if you add full Carmine (OpenNI2) / Kinect support. :D

As for the AVI stream, I simply need a function which loads an AVI video (whether it be on the web or not), to a 3D texture.

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 9:51 pm
by dobro
in PB 5.20

after you have downloaded and installed this
http://www.flasharts.de/mpz/Install_MP3D_32_x86.exe

it seems that the examples do not work ...
it may be missing the user library?

the fonction : "MP_Graphics3D (640,480,0,3)" is not recognized :shock:

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 10:02 pm
by mpz
Hi Dobro,

please enzip the following file an copy this manually in the following folder and restart Purebasic:

1) load PB520 beta MP33
http://www.flasharts.de/mpz/mp33/pb520/MP3D_Library.zip

2) manually coping into this folder:
PureBasic\SubSystems\DX9\

3) restart PB

Yes i will make a new installer for PB520 in a few days...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 10:03 pm
by dobro
ok i test ....

hum ....

error message : the missing library 'Misc'

Image

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 10:12 pm
by Mythros
Hi, @mpz. I am 100% willing to test it until I can't test it anymore if you add full Carmine (OpenNI2) / Kinect support. :D

As for the AVI stream, I simply need a function which loads an AVI video (whether it be on the web or not), to a 3D texture.

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 11:53 pm
by mpz
Hi Mythros ,

mp3d has a movie to texture funktion. You open an avi file and then you can use a film as texture: MP_MovieToTexture ( Movie, Texture, Frame )...

But if you want to use a streaming Avi i must know what king of streaming avi you mean or you show me a demo file ...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Fri Nov 01, 2013 12:14 am
by Mythros
Just the ability to stream an on-website live avi file.

For instance,

I use the url, "http://mywebsite.com/files/videos/mylivestream.avi"

It then allows me to still texture the 3D object with the video texture still playing.

Re: MP3D Engine Alpha 32

Posted: Fri Nov 01, 2013 10:35 am
by applePi
here is the latest concise stones Gun which i have posted before. i think i know the reason of the stones gun behaviour, it is the collision system, since the collision system prohibit the existence of two objects at the same place and time (like the reality is) so the 3D engine will separate them violently, and if we put the stone at the opening of the gun it will be pushed with the collision power.
when the stone size are big there is more repulsive power try to change line 65 to this
stone=MP_CreateRectangle(1,1,1)
and you will have an extremly powerfull stones thrower.
if the stones size are too small the repuksive power are too small
the Gun here are a rectangle with a physics type static and not dynamic with 2 hing joints as before)

Image

Image

Code: Select all

 Declare dropStone()
 
 ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0)
MP_Graphics3D(RX,RY,0,1):MP_VSync(0)
 SetWindowTitle(0, "Push Space for boxes") 
 Global stone
 camera = MP_CreateCamera()    ; Kamera erstellen

 MP_PositionCamera(camera, 0, 4, -15 )
 MP_CameraLookAt(camera,0,0,0)

 light= MP_CreateLight(0)    ; Es werde Licht
 
 texture = MP_CreateTextureColor(256, 256, RGBA(50, 255, 100, 255))
 ;texture2 = MP_CreateTextureColor(256, 256, RGBA(100, 100, 255, 255))
 texture2 = MP_LoadTexture(#PB_Compiler_Home + "Examples/3D/Data/Textures\Wood.jpg",0) 
 Global plane = MP_CreateRectangle(20,20,1)
 MP_EntitySetTexture(plane, texture)
 MP_PositionEntity (plane,0,-3,0)
 MP_RotateEntity(plane, 90, 0, 0)
   
 torus = MP_CreateTorus(0.1, 1, 20)
 MP_ResizeMesh(torus,4,4,4)
 MP_RotateEntity(torus, 90, 0, 0 )
 MP_PositionEntity (torus,2,-3,0)
 MP_EntitySetTexture(torus, texture2)
 
 Global Gun = MP_CreateRectangle(2,1,1)
     
 MP_EntitySetNormals(torus)
 MP_MaterialDiffuseColor(torus,255,255,128,50)
 MP_MaterialSpecularColor(torus,255,255,255,155,5)

 MP_PositionEntity (Gun, -2, 2, 0)
 
 MP_PhysicInit()
 
 MP_EntityPhysicBody(Gun , 1, 100)
 MP_EntityPhysicBody(torus , 1, 0)
  
 MP_EntityPhysicBody(plane , 1, 1)
    
 MP_AmbientSetLight (RGB(0,100,200))

 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   If MP_KeyDown(#PB_Key_Space)
    dropStone()
  EndIf
     
     MP_PhysicUpdate()
     
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
 
 Procedure dropStone()
  stone=MP_CreateRectangle(0.3,0.3,0.3)
  MP_EntityPhysicBody(stone,2,2)
  MP_PositionEntity(stone,-1,2,0)
  ; Kill all meshs with y < -10   
     For n = 0 To MP_ListGetSize(1)-1
       TempMesh = MP_ListGetElement(1, n)
       If MP_EntityGetY(TempMesh) < -10
           MP_FreeEntity(TempMesh)
       EndIf
     Next  
  
EndProcedure
EDIT:
here is another version an artillery , this is done by also rotating the stones (the cubes) the same as the Gun so it will be pushed the correct way ,also we need to put them near the gun opening. the values here are experimental, but we can calculate it exactly from geometry
Image

Code: Select all

 Declare dropStone()
 
 ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0)
MP_Graphics3D(RX,RY,0,1):MP_VSync(0)
 SetWindowTitle(0, "Push Space for boxes") 
 Global stone
 camera = MP_CreateCamera()    ; Kamera erstellen

 MP_PositionCamera(camera, 0, 4, -15 )
 MP_CameraLookAt(camera,0,0,0)

 light= MP_CreateLight(0)    ; Es werde Licht
 
 texture = MP_CreateTextureColor(256, 256, RGBA(50, 255, 100, 255))
 ;texture2 = MP_CreateTextureColor(256, 256, RGBA(100, 100, 255, 255))
 texture2 = MP_LoadTexture(#PB_Compiler_Home + "Examples/3D/Data/Textures\Wood.jpg",0) 
 Global plane = MP_CreateRectangle(20,20,1)
 MP_EntitySetTexture(plane, texture)
 MP_PositionEntity (plane,0,-3,0)
 MP_RotateEntity(plane, 90, 0, 0)
   
 torus = MP_CreateTorus(0.1, 1, 20)
 MP_ResizeMesh(torus,4,4,4)
 MP_RotateEntity(torus, 90, 0, 0 )
 MP_PositionEntity (torus,2,-3,0)
 MP_EntitySetTexture(torus, texture2)
 
 Global Gun = MP_CreateRectangle(2,1,1)
     
 MP_EntitySetNormals(torus)
 MP_MaterialDiffuseColor(torus,255,255,128,50)
 MP_MaterialSpecularColor(torus,255,255,255,155,5)

 MP_PositionEntity (Gun, -6, -1, 0)
 MP_RotateEntity (Gun, 0, 0, 45)
 MP_PhysicInit()
 
 MP_EntityPhysicBody(Gun , 1, 100)
 MP_EntityPhysicBody(torus , 1, 0)
  
 MP_EntityPhysicBody(plane , 1, 1)
    
 MP_AmbientSetLight (RGB(0,100,200))

 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   If MP_KeyDown(#PB_Key_Space)
    dropStone()
  EndIf
     
     MP_PhysicUpdate()
     
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
 
 Procedure dropStone()
  stone=MP_CreateRectangle(0.3,0.3,0.3)
  MP_PositionEntity(stone,-5.3,-0.2,0)
  MP_RotateEntity (stone, 0, 0, 45)
  MP_EntityPhysicBody(stone,2,2)
  
  ; Kill all meshs with y < -10   
     For n = 0 To MP_ListGetSize(1)-1
       TempMesh = MP_ListGetElement(1, n)
       If MP_EntityGetY(TempMesh) < -10
           MP_FreeEntity(TempMesh)
       EndIf
     Next  
  
EndProcedure

Re: MP3D Engine Alpha 32

Posted: Fri Nov 01, 2013 11:49 am
by dobro
dobro wrote:ok i test ....

hum ....

error message : the missing library 'Misc'

Image
does not work if you put "MP3D_Library" in Subsystem\DX9\
but it works if you put "MP3D_Library" in PureLibraries\UserLibraries\ :)

change your install ..... ;)

an rename "MP3D Demos" in "MP3D_Demos"

Re: MP3D Engine Alpha 32

Posted: Fri Nov 01, 2013 12:11 pm
by applePi
Hi dobro
Michael in his reply just forgot to provide the exact path, which are mentioned correctly in page one in this subforum as
// Testversion for PB5.20 beta, please copy into the PureBasic5.20\SubSystems\dx9\purelibraries\userlibraries\ folder
http://www.flasharts.de/mpz/PB520/x86/MP3D_Library.zip //

Re: MP3D Engine Alpha 32

Posted: Fri Nov 01, 2013 10:58 pm
by N_Gnom
@mpz: any news about the support for more than one texture per .b3d mesh?(per surface)
and for each surface of course more than one lay.(for normal mapping and so on)

edit: i.e. texture/surface or texture/group.
i´ve tested now .b3d and .x and .x doesn´t works too.
i need the support of multiple textures for one mesh.

i.e. MP_GetSurfacesCount(mesh)
MP_SetSurfaceTexture(mesh, texture, countnumber)