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