Page 35 of 71

Re: MP3D Engine Alpha 32

Posted: Thu Oct 24, 2013 11:58 am
by mpz
Hi,

i have made a normal beta version for 5.11 and one for 5.20 in my forum. For special cases a x86 unicode an threadsave lib but ONLY for pb 5.11.

You can install the version MP32 and then you use the 5.20 lib from my forum and copy it manually in the dx9 folder. A new installer for PB5.20 is coming soon...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Thu Oct 24, 2013 12:45 pm
by Sveinung
mpz wrote:A new installer for PB5.20 is coming soon...
Thank you....again :D

Sveinung

Re: MP3D Engine Alpha 32

Posted: Thu Oct 24, 2013 6:10 pm
by Mythros
Hi, mpz. Yes, I'm using version 5.11.

I just checked the version.

Re: MP3D Engine Alpha 32

Posted: Tue Oct 29, 2013 9:04 pm
by applePi
another tutorial (or a toy) about the constraint Hinge, it is using the Michael example but refashioned to enhance the user sensing of what the hinge is and what its position can affect the object behaviour
in this example tutorial you can move the Hinge joint left and right, and you can rotate the Hinge to see how this will affect the rectangle which are under the influence of Gravity, also you can drop 2 Cubes (stones) try dropping them while the hinge are horizontal
Image
to run this code you need the latest experimental Library file from http://www.morty-productions.de/gamedev ... hp?tid=160 to replace the file in C:\PureBasic\SubSystems\DX9\purelibraries\userlibraries which exist from the installation file in page 1 in this forum

Code: Select all

;// Project Title: MP 3D Engine Beispielprogramme
 ;// Dateiname: MP_Physik_ConstraintCreatHinge.pb
 ;// Erstellt am: 11.8.2011
 ;// Update am  : 
 ;// Author: Michael Paulwitz
 ;// 
 ;// Info: 
 ;// Physic with Hinge
 ;// Physik mit Rad
 ;//
 ;//
 ;////////////////////////////////////////////////////////////////
 ;MP_Physik_ConstraintCreatHinge tutorial
 ExamineDesktops()
 Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
 MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
 SetWindowTitle(0, "Press left/Right move pivot _ Up/Down rotate pivot _ space drop stone") 
 Declare HingePosition(disp.f)
 Declare dropStone()
 
 camera = MP_CreateCamera()    ; Kamera erstellen
 MP_PositionCamera(camera, 0, 5, -5 )
 MP_CameraLookAt(camera,0,0,0)

 light= MP_CreateLight(2)    ; Es werde Licht
 MP_LightSetColor(light, RGB(255,128,50))
 MP_PositionEntity(light, -6 , 10, -5)
   
 MP_AmbientSetLight (RGB(0,100,200))
 Global.f hingX=0,hingY=0,hingZ=0, disp.f
 Global piv = MP_CreateCylinder(10,1)
 Global.f length = 6, angle = 0, rot = 5, dirX = 1, dirZ = 1
 Global stone
 MP_ResizeMesh(piv,0.4,0.4,0.4)
 Global Mesh = MP_CreateRectangle (length,0.05,0.5)
 MP_PositionEntity (Mesh,0,0,0)
 MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position
 HingePosition(0)
 
 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   If MP_KeyHit(#PB_Key_Right)
     disp.f = 0.5 ; disp :the displacement og the Hinge to the right
     rot = 0 ; we don't want to change the pivot angle when we move pivot left or right
     HingePosition(disp)
    
   ElseIf MP_KeyHit(#PB_Key_Left)
     disp = -0.5 ; disp :the displacement of the Hinge to the left
     rot = 0 
     HingePosition(disp)
   EndIf  
      
   If MP_KeyHit(#PB_Key_Up)
     rot = 5 ; the increment of angle
     disp = 0
     HingePosition(disp)
     ElseIf MP_KeyHit(#PB_Key_Down) 
       rot = -5  ;the decrement of angle
       disp = 0
       HingePosition(disp)
   EndIf  
     
   If MP_KeyHit(#PB_Key_Space)
     dropStone()
   
   EndIf
    
     MP_Drawtext(10,20,"Length of rect="+StrF(length,2)+" /   Hinge relative X Position = "+StrF(HingX,2) + "   Y = 0  " + "  Z = 0")
     MP_Drawtext(10,40,"Angle= "+StrF(angle,2))
     MP_PhysicUpdate()
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
 

 Procedure HingePosition(disp.f )
     hingX + disp
     MP_FreeEntity(Mesh): MP_FreeEntity(piv)
     piv = MP_CreateCylinder(10,1)
     MP_ResizeMesh(piv,0.4,0.4,0.4)
     MP_RotateEntity(piv , 0 , angle, 0)
     angle + rot     
     Mesh = MP_CreateRectangle (length,0.05,0.5)
     MP_PositionEntity (Mesh,0,0,0)
     MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position relative to the Mesh
     MP_ChangeMeshCoord(piv)
     MP_AddMesh(piv , Mesh ) : MP_FreeEntity(piv)
     MP_PhysicInit()
     MP_EntityPhysicBody(Mesh , 4, 10)
     
     ;http://www.mathwarehouse.com/vectors/images/main/how-To-solve.gif
     dirX = 1*Sin(Radian(angle)) ; the X component of the pivot vector
     dirZ = 1*Cos(Radian(angle)) ; the Z component of the pivot vector
     
     MP_ConstraintCreateHinge (Mesh,dirX,0,dirZ,hingX,hingY,hingZ)
     
     MP_EntitySetNormals (Mesh)
     MP_MaterialDiffuseColor (Mesh,255,255,128,50)
     MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
   EndProcedure
   
   Procedure dropStone()
   stone = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone, 2, 1)
   ;MP_EntitySetGravity(stone, 0 , -1 ,0)
   MP_PositionEntity (stone,-2.5,1,0)  
   stone2 = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone2, 2, 1)
   ;MP_EntitySetGravity(stone2, 0 , -1 ,0)
   MP_PositionEntity (stone2,1,1,0)  
    
   EndProcedure
   
   

Re: MP3D Engine Alpha 32

Posted: Wed Oct 30, 2013 11:07 pm
by Psychophanta
Nice one applePi.
Now, what is the problem with this example? Why do the "stones" bound on air? :o

Code: Select all

Define .d
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,"Press left/Right move pivot _ Up/Down rotate pivot _ space drop stone")
Global.i camera,light,Mesh,Mesh2,piv,stone,stone2
camera=MP_CreateCamera()
MP_PositionCamera(camera,0,5,-10)
MP_CameraLookAt(camera,0,0,0)
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(219,118,50))
MP_PositionEntity(light,-6,10,-5)
MP_AmbientSetLight(RGB(0,100,200))
Global hingX,hingY,hingZ
Global length=6,angle,dirX,dirZ

Procedure HingePosition(disp=0,rot=0)
  MP_FreeEntity(Mesh):MP_FreeEntity(Mesh2):MP_FreeEntity(piv)
  piv=MP_CreateCylinder(6,1)
  MP_ResizeMesh(piv,0.1,0.1,5)
  angle+rot
  MP_RotateEntity(piv,0,Degree(angle),0)
  Mesh=MP_CreateRectangle(length,0.05,2.5)
  MP_PositionEntity(Mesh,0,0,0)
  Mesh2=MP_CreateRectangle(0.05,length,2.5)
  MP_PositionEntity(Mesh2,0,0,0)
  MP_AddMesh(Mesh2,Mesh):MP_FreeEntity(Mesh2)
  hingX+disp
  MP_PositionEntity(piv,hingX,hingY,hingZ); the pivot position relative to the Mesh
  MP_ChangeMeshCoord(piv)
  MP_AddMesh(piv,Mesh):MP_FreeEntity(piv)
  MP_EntityPhysicBody(Mesh,4,10)
  dirX=Sin(angle); the X component of the pivot vector
  dirZ=Cos(angle); the Z component of the pivot vector
  MP_ConstraintCreateHinge(Mesh,dirX,0,dirZ,hingX,hingY,hingZ)
  MP_EntitySetNormals(Mesh)
  MP_MaterialDiffuseColor(Mesh,255,255,128,50)
  MP_MaterialSpecularColor(Mesh,255,255,255,155,5)
EndProcedure
Procedure dropStone()
  stone=MP_CreateRectangle(0.3,0.3,0.3)
  MP_EntityPhysicBody(stone,2,1)
  ;MP_EntitySetGravity(stone,0,-1,0)
  MP_PositionEntity(stone,-2.5,4,0)
  stone2=MP_CreateRectangle(0.3,0.3,0.3)
  MP_EntityPhysicBody(stone2,2,1)
  ;MP_EntitySetGravity(stone2,0,-1,0)
  MP_PositionEntity(stone2,1,4,0)
EndProcedure
MP_PhysicInit()
HingePosition()
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
  If MP_KeyHit(#PB_Key_Right)
    disp=0.5 ; disp:the displacement og the Hinge to the right
    rot=0 ; we don't want to change the pivot angle when we move pivot left or right
    HingePosition(disp)
  ElseIf MP_KeyHit(#PB_Key_Left)
    disp=-0.5 ; disp:the displacement of the Hinge to the left
    rot=0
    HingePosition(disp)
  ElseIf MP_KeyHit(#PB_Key_Up)
    rot=0.05 ; the increment of angle
    disp=0
    HingePosition(disp,rot)
  ElseIf MP_KeyHit(#PB_Key_Down)
    rot=-0.05  ;the decrement of angle
    disp=0
    HingePosition(disp,rot)
  EndIf 
  If MP_KeyDown(#PB_Key_Space)
    dropStone()
  EndIf
  MP_Drawtext(10,20,"Length of rect="+StrF(length,2)+" /   Hinge relative X Position="+StrF(HingX,2)+"   Y=0  "+"  Z=0")
  MP_Drawtext(10,40,"Angle="+StrF(Degree(angle),2))
  MP_PhysicUpdate()
  MP_RenderWorld()
  MP_Flip()
Wend
MP_PhysicEnd()

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 7:28 am
by applePi
Hi Psychophanta
if you means this situation:
Image
in which the stones can't go between the two plates because in line 32 MP_EntityPhysicBody(Mesh,4,10) you have used type 4, and types from 2 to 4 deals with convex physics, (type 1 for static which can be convex or concave) the new experimental type 5 which are used in Gears example enable us to use concave physics to some extent (for the meshes made step by step by MP_AddMesh)
so change it to MP_EntityPhysicBody(Mesh,5,10) and the stones will go everywhere. your idea of many stones makes me wonder if we can use huge number of tiny stones to simulate a physics water fountain but i am worry about the memory if we not free the huge number of entities, look Michael MP_GearsTest.pb example here http://www.morty-productions.de/gamedev ... 160&page=2 there he have used MP_FreeEntity
i will see if we can simulate water fountain this way to (some limit) to drive something. but note that it is better to use cubes and not spheres as stones because spheres needs more processing power ie costly.

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 11:34 am
by Psychophanta
Thanks buddy :)

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 12:19 pm
by applePi
here is what appears as water pumped from a nozzle, the stones (cubes) are attached to the parent (body) by a slider joint (i'm still don't understand the subject, and indeed don't understand fully this example )
MP_ConstraintCreateSlider (stone,0,0,1 ,sliderX+1,sliderY,sliderZ, body)
press space to pump the stones as water and fill the big Pot (torus).
but after a 1 minute it appears that water are exhausted ie the power of the stones, of course because the huge number of cubes .
i'm still on the subject but here the example
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, -5 )
 MP_CameraLookAt(camera,0,0,0)

 light= MP_CreateLight(0)    ; Es werde Licht
 
 texture = MP_CreateTextureColor(256, 256, RGBA(0, 0, 255, 255))
 texture2 = MP_CreateTextureColor(256, 256, RGBA(100, 100, 255, 250))
 plane = MP_CreatePlane(10, 10)
 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 body = MP_CreateRectangle(0.5,2,0.5)
 MP_RotateEntity(body, 0, 0, 90 )
 
 
  
 MP_EntitySetNormals(torus)
  MP_MaterialDiffuseColor(torus,255,255,128,50)
  MP_MaterialSpecularColor(torus,255,255,255,155,5)
 
 hingX.f=0:hingY.f=0:hingZ.f=1
  
 MP_PositionEntity (body,-2,2,0)
 
 MP_PhysicInit()
 
 MP_EntityPhysicBody(body , 4, 10)
 MP_EntityPhysicBody(torus , 1, 0)
 NewMaterial = MP_CreatePhysicMaterial() 
 ;MP_SetPhysicMaterialProperties(MaterialID1, Elasticity.f, staticFriction.f, kineticFriction.f [, MaterialID2])
 MP_SetPhysicMaterialProperties(NewMaterial,0,2,2)
 MP_SetPhysicMaterialtoMesh (body, NewMaterial)
  
 MP_ConstraintCreateHinge (body,0,0,1,hingX,hingY,hingZ)
 MP_ConstraintCreateHinge (body,0,0,1,hingX+1,hingY,hingZ)
 
 MP_EntityPhysicBody(plane , 1, 1)
 MP_SetPhysicMaterialtoMesh (plane, NewMaterial)
 
 MP_ConstraintCreateSlider (stone,0,0,1 ,sliderX+1,sliderY,sliderZ, body) ; create a slider joint functions
 
 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,1)
 
  MP_PositionEntity(stone,-1,2,0)
  
EndProcedure
Slider Joint:
the slider joint i have not found example for it yet, so i guessed this example depending on the Hinge example. we should not use the usual MP_MoveEntity in the physics , but here it will not harm so use Left right to rotate the block and allowing the cyclinder to slide. there should be more functions for the slider joint, May be Michael will implement the others such as NewtonSliderGetJointPosit and its sisters. big thanks
Image

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_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_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()

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 12:51 pm
by Psychophanta
Nice!
But my example (with the '5' as parameter as you said) does not work well, some 'stones' surpass the tables! :(

EDIT: By the way: in your last examples the plane (red floor) does not appear here!

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 2:49 pm
by applePi
Psychophanta write: "some 'stones' surpass the tables!"
i have noticed this problem in many engines , the objects are not solid enough, so in many cases the object will penetrate or going through the other. the half solution is to use a few stones or to make it fall in low gravity
and in your example change the thickness of the plates from 0.05 to 0.5
line 23 to 25
Mesh=MP_CreateRectangle(length,0.5,2.5)
MP_PositionEntity(Mesh,0,0,0)
Mesh2=MP_CreateRectangle(0.5,length,2.5)

to see it more clearly change the Mesh weight ,line 32
MP_EntityPhysicBody(Mesh,5,1000)

so your example will look like this:

Code: Select all

Define .d
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,"Press left/Right move pivot _ Up/Down rotate pivot _ space drop stone")
Global.i camera,light,Mesh,Mesh2,piv,stone,stone2
camera=MP_CreateCamera()
MP_PositionCamera(camera,0,5,-10)
MP_CameraLookAt(camera,0,0,0)
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(219,118,50))
MP_PositionEntity(light,-6,10,-5)
MP_AmbientSetLight(RGB(0,100,200))
Global hingX,hingY,hingZ
Global length=6,angle,dirX,dirZ

Procedure HingePosition(disp=0,rot=0)
  MP_FreeEntity(Mesh):MP_FreeEntity(Mesh2):MP_FreeEntity(piv)
  piv=MP_CreateCylinder(6,1)
  MP_ResizeMesh(piv,0.1,0.1,5)
  angle+rot
  MP_RotateEntity(piv,0,Degree(angle),0)
  Mesh=MP_CreateRectangle(length,0.5,2.5)
MP_PositionEntity(Mesh,0,0,0)
Mesh2=MP_CreateRectangle(0.5,length,2.5)
  MP_PositionEntity(Mesh2,0,0,0)
  MP_AddMesh(Mesh2,Mesh):MP_FreeEntity(Mesh2)
  hingX+disp
  MP_PositionEntity(piv,hingX,hingY,hingZ); the pivot position relative to the Mesh
  MP_ChangeMeshCoord(piv)
  MP_AddMesh(piv,Mesh):MP_FreeEntity(piv)
  MP_EntityPhysicBody(Mesh,5,1000)
  dirX=Sin(angle); the X component of the pivot vector
  dirZ=Cos(angle); the Z component of the pivot vector
  MP_ConstraintCreateHinge(Mesh,dirX,0,dirZ,hingX,hingY,hingZ)
  MP_EntitySetNormals(Mesh)
  MP_MaterialDiffuseColor(Mesh,255,255,128,50)
  MP_MaterialSpecularColor(Mesh,255,255,255,155,5)
EndProcedure
Procedure dropStone()
  stone=MP_CreateRectangle(0.3,0.3,0.3)
  MP_EntityPhysicBody(stone,2,1)
  ;MP_EntitySetGravity(stone,0,-1,0)
  MP_PositionEntity(stone,-2.5,4,0)
  stone2=MP_CreateRectangle(0.3,0.3,0.3)
  MP_EntityPhysicBody(stone2,2,1)
  ;MP_EntitySetGravity(stone2,0,-1,0)
  MP_PositionEntity(stone2,1,4,0)
EndProcedure
MP_PhysicInit()
HingePosition()
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
  If MP_KeyHit(#PB_Key_Right)
    disp=0.5 ; disp:the displacement og the Hinge to the right
    rot=0 ; we don't want to change the pivot angle when we move pivot left or right
    HingePosition(disp)
  ElseIf MP_KeyHit(#PB_Key_Left)
    disp=-0.5 ; disp:the displacement of the Hinge to the left
    rot=0
    HingePosition(disp)
  ElseIf MP_KeyHit(#PB_Key_Up)
    rot=0.05 ; the increment of angle
    disp=0
    HingePosition(disp,rot)
  ElseIf MP_KeyHit(#PB_Key_Down)
    rot=-0.05  ;the decrement of angle
    disp=0
    HingePosition(disp,rot)
  EndIf 
  If MP_KeyDown(#PB_Key_Space)
    dropStone()
  EndIf
  MP_Drawtext(10,20,"Length of rect="+StrF(length,2)+" /   Hinge relative X Position="+StrF(HingX,2)+"   Y=0  "+"  Z=0")
  MP_Drawtext(10,40,"Angle="+StrF(Degree(angle),2))
  MP_PhysicUpdate()
  MP_RenderWorld()
  MP_Flip()
Wend
MP_PhysicEnd()
i think there is a relation between the sizes stones and plates to prevent going through.
regarding the plane appearance change the texture color in line 15 until you see it. or assign to it textue2 (the torus texture if it works), or texture it by a picture. the graphics cards behaves differently.

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 3:06 pm
by Psychophanta
Thanks,
applePi wrote: regarding the plane appearance change the texture color in line 15 until you see it. or assign to it textue2 (the torus texture if it works), or texture it by a picture. the graphics cards behaves differently.
Well, the problem is not only that it does not appear, but that the stones fall down to infinite, i.e. the plane does not exist

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 3:46 pm
by applePi
could it be because i have used mass zero to the plane ?
so just a suggestion: in the water (stones) gun here
http://www.purebasic.fr/english/viewtop ... 10#p429500
line 53
change it to
MP_EntityPhysicBody(plane , 1, 1)
i have edited it
or replace the plane with a big but thin rectangle and assign to it the property for static ie "1" so it will not fall down
MP_EntityPhysicBody(rectangle , 1, 1)

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 4:26 pm
by Psychophanta
Look like it is a bug because this doesn't display te plane here:

Code: Select all

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")
camera=MP_CreateCamera()
MP_PositionCamera(camera,1,4,-5)
MP_CameraLookAt(camera,0,0,0)
light=MP_CreateLight(0)
MP_AmbientSetLight(RGB(0,100,200))

plane=MP_CreatePlane(5,5)
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow
  MP_RenderWorld()
  MP_Flip()
Wend

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 4:48 pm
by applePi
it is displayed in my computer like this:
Image
and when we rotate it around X away by adding
MP_RotateEntity(plane,-90,0,0)
it is desplayed like this
Image

i am using 640 X 480 resolution, and my Graphics card are Geforce GT 520
it is may be an issue of how a graphics card interpret DirectX functions, they are not the same

Re: MP3D Engine Alpha 32

Posted: Thu Oct 31, 2013 8:01 pm
by applePi
it seems the stones gun have nothing to do with the slider joint, i have disappointed, and it seems the stones power and direction are gained 1- from collision when we put the stone inside the gun block in a correct place (near the gun muzzle 2- the power of gravity.
still i want to rotate the gun at different angles freely and direct it to throw the stones . at the beginning of the program run you will have 2 threads of stones, the following picture show near the end
Image

if you deleted the plane, then you can continue throwing stones forever.
add the plane again and there is a limit. and if we use big stones it will last more than small stones.
something for Michael to solve.

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") 
 
 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(0, 0, 255, 255))
 texture2 = MP_CreateTextureColor(256, 256, RGBA(100, 100, 255, 250))
 
 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 body = MP_CreateRectangle(1.0,2,1.0)
 MP_RotateEntity(body, 0, 0, 120 )
 ;Global block = MP_CreateRectangle(0.5,2,0.5)
 ;MP_RotateEntity(block, 0, 0, 90 )
 ;MP_PositionEntity(block,-1,0.1,0)
 
  
 MP_EntitySetNormals(torus)
  MP_MaterialDiffuseColor(torus,255,255,128,50)
  MP_MaterialSpecularColor(torus,255,255,255,155,5)
 
 hingX.f=0:hingY.f=0:hingZ.f=1
  
 MP_PositionEntity (body,-2,1.5,0)
 
 MP_PhysicInit()
 
 MP_EntityPhysicBody(body , 4, 10)
 MP_EntityPhysicBody(torus , 1, 1)
 NewMaterial = MP_CreatePhysicMaterial() 
 ;MP_SetPhysicMaterialProperties(MaterialID1, Elasticity.f, staticFriction.f, kineticFriction.f [, MaterialID2])
 MP_SetPhysicMaterialProperties(NewMaterial,0,2,2)
 MP_SetPhysicMaterialtoMesh (body, NewMaterial)
  
 MP_ConstraintCreateHinge (body,0,0,1,hingX,hingY,hingZ)
 MP_ConstraintCreateHinge (body,0,0,1,hingX+1,hingY,hingZ)
 
 MP_EntityPhysicBody(plane , 1, 1)
 MP_SetPhysicMaterialtoMesh (plane, NewMaterial)
 Global Mesh4
  
 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()
  Mesh4 = MP_CreateRectangle(0.3,0.3,0.3)
      MP_EntityPhysicBody(Mesh4, 2, 3)
      MP_PositionEntity (Mesh4,-1,2.0,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