Hi michael, i haven't noticed your question, my answer No, it is not possible, look my request here http://purebasic.fr/english/viewtopic.php?f=3&t=55916 to add dynamic compound object. in Bullet engine which PB depends on they said: compound shape , "Multiple convex shapes can be combined into a composite or compound shape, using the btCompoundShape This is a concave shape made out of convex sub parts, called child shapes. Each child shape has its own local offset transform, relative to the btCompoundShape. ." Bullet user manual but it is not implemented in PB version of Ogre/Bullet.Question: Is it possible to make these kind of Physical object in PB -Ogre ? Or has Ogre only a hull version?
your engine have this feature as it is demonstrated by the gears and the pendulum examples which are posted first here
http://purebasic.fr/english/viewtopic.p ... &start=510
and corrected by you (to work with latest lib) here:
http://purebasic.fr/english/viewtopic.p ... 25#p458129
, and the example at the bottom of my post here.
now i suggest to add joint with motor feature, this is in newton engine here:
https://github.com/MADEAPPS/newton-dyna ... 93&q=motor
i see several references to the motor such as "CUSTOM_JOINTS_API void EnableMotor_0(bool state); or SetMotorAcceleration etc
there is a motor in PB Ogre/bullet engine:
EnableHingeJointAngularMotor(#Joint, Enable, TargetVelocity, MaxMotorImpulse)
HingeJointMotorTarget(#Joint, Angle, Velocity)
i have provided example in http://www.forums.purebasic.com/english ... 36&t=54556
to move a slope with a joint which have motor very slowly. there are also in the PB official examples CarPhysic.pb demo, and PinBall.pb demo
the reason i ask this for MP3D, is that i am trying to simulate Geneva drive https://www.youtube.com/watch?v=OZiPxV-_oaY
which convert continuous rotation to intermittent rotation
i have made a partially geneva drive example which success sometimes for a few rotations since i can't restrict sphere from not accelerating to high speed, i need a motor for it so it moves in regular speed not by MP_EntityAddImpulse alone over the hinge joint but also with motor own specification such as TargetVelocity, MaxMotorImpulse etc).

code need the latest mp3d lib to replace the older one: http://purebasic.fr/english/viewtopic.p ... 70#p465650
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex_
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
Structure MyTris
v1.l : v2.l : v3.l ; vertices coordinates
EndStructure
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, "tests")
camera = MP_CreateCamera() ; Kamera erstellen
light= MP_CreateLight(2) ; Es werde Licht
MP_PositionEntity(light, -10, 10, 0)
MP_AmbientSetLight (RGB(0,100,200))
cam0 = MP_CreateCamera()
;MP_PositionEntity(cam0, 0, 10, -3)
;MP_PositionEntity(cam0, 0, 1, -6)
MP_PositionEntity(cam0, 0, 3, -7)
MP_EntityLookAt(cam0, 0, 0, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 255, 255, 0))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
sphere = MP_CreateSphere(16)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Triscount = MP_CountTriangles(sphere)
Dim Vert.MyVertex_ (vertexcount)
Dim Tris.MyTris (Triscount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
For n = 0 To vertexcount-1
If Vert(n)\y < 0
For m = 0 To Triscount-1
If Tris(m)\v1 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v2 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v3 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
Next
EndIf
Next
MP_SetMeshData (sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate , @Vert(), vertexcount)
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
MP_PositionEntity (sphere, 0, 1, 0)
;mp_wireframe(1)
MP_EntitySetTexture(sphere, tex1)
MP_RotateMesh(sphere , -90 , 0, 180)
MP_ResizeMesh(sphere,1,1,1)
hand = MP_CreateCylinder(5,0.2)
MP_ResizeMesh(hand,0.2,0.2,0.8)
MP_RotateMesh(hand , 90 , 0, 0)
;MP_TranslateMesh(hand,0.1, -0.3, -1.3 )
MP_TranslateMesh(hand,0.1, -0.3, -0.8 )
MP_AddMesh(hand , sphere ) : MP_FreeEntity(hand)
MP_PositionEntity(sphere, 0, 0.5, -0.8)
;;0000000000000000000000000000000000000000000000000000000000000000000000
Mesh = MP_CreateCylinder(10,0.2)
MP_ResizeMesh(Mesh,0.5,0.5,0.2)
MP_RotateMesh(Mesh , 90 , 0, 0)
MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
;;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Mesh2 = MP_CreateRectangle (2,0.5,0.1)
MP_TranslateMesh(Mesh2,0.0,0.2,-0.2)
MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
Mesh2 = MP_CreateRectangle (2,0.5,0.1)
MP_TranslateMesh(Mesh2,0.0,0.2,0.2)
MP_RotateMesh(Mesh2 , 0 , 90, 0)
MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
Mesh2 = MP_CreateRectangle (2,0.5,0.1)
MP_TranslateMesh(Mesh2,0.0,0.2,-0.2)
MP_RotateMesh(Mesh2 , 0 , 90, 0)
MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
Mesh2 = MP_CreateRectangle (2,0.5,0.1)
MP_TranslateMesh(Mesh2,0.0,0.2,0.2)
MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
;MP_RotateMesh(Mesh , 90 , 0, 0)
MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
MP_EntitySetTexture(Mesh, tex0)
MP_PositionEntity(Mesh, 0, 0, -2)
MP_RotateEntity(sphere, 0, -90, 0 )
MP_RotateEntity(Mesh, 0, 38, 0 )
;;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
MP_PhysicInit()
MP_EntityPhysicBody(sphere , 5, 10)
MP_EntityPhysicBody(Mesh , 5, 10)
MP_ConstraintCreateHinge (sphere,0,1,0, 0,0,0)
MP_ConstraintCreateHinge (Mesh,0,1,0, 0.0,0.0,0)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_PhysicUpdate()
MP_EntityAddImpulse(sphere, 1, 0, 0 , 0, 0, 2.7)
;MP_TurnEntity (sphere, 0, 1, 0)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
we use hinge joint
we EnableHingeJointAngularMotor for that specific hinge joint
we apply force with ApplyEntityImpulse
here the force will be subjected to the limits specified in the EnableHingeJointAngularMotor(#Joint, Enable, TargetVelocity, MaxMotorImpulse)
here is an example, press z to speed the wheel rotation. press x to decrease the wheel rotation
note that we can't make gears here but only wheels
Code: Select all
Enumeration
#MESH = 100
#LIGHT
#camera
#mainwin
#plane
#node
#wheel
#wheel2
EndEnumeration
Global width=20, length=20
Global zcam.f, xcam.f, ycam.f, rotate.b, camRo.f, camZ = 20
ExamineDesktops()
If OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "Z for speed , X to slow down the wheel, arrows to Camera rotate/zoom. W for wire/solid frame", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-6, 0, 0, 0)
InitKeyboard()
SetFrameRate(60)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
CreateLight(#LIGHT,RGB(22,222,0),0,-4,0,#PB_Light_Directional )
LightLookAt(#LIGHT, 0, 4, -5)
CreateCamera(#camera, 0, 0, 100, 100)
MoveCamera(#camera, 0, 2, 20)
CameraLookAt(#camera, 0, 2, 0)
EndIf
;SkyDome("clouds.jpg", 100) ;for blue color background
CreateMaterial(2, LoadTexture(2, "Geebee2.bmp"))
CreateSphere(3, 0.5)
CreateEntity(3, MeshID(3), MaterialID(2), -6, 6, 2)
CreateSphere(4, 0.5)
CreateEntity(4, MeshID(4), MaterialID(2), 1, 4, 0)
EntityPhysicBody(3, #PB_Entity_StaticBody)
EntityPhysicBody(4, #PB_Entity_StaticBody)
CreateMaterial(0, LoadTexture(0, "terrain_texture.jpg"))
DisableMaterialLighting(0, #True)
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateCylinder(#wheel,2,1)
NormalizeMesh(#wheel)
CreateEntity(#wheel, MeshID(#wheel), MaterialID(0), -6.7, 4, -1)
CreateEntity(#wheel, MeshID(#wheel), MaterialID(0), -6.7, 4, -1)
RotateEntity(#wheel,0,90,0)
EntityPhysicBody(#wheel, #PB_Entity_CylinderBody , 1.0)
EntityLinearFactor(#wheel, 0, 1, 0)
HingeJoint(1,EntityID(3),0,0,-0.2, 0,0,1, EntityID(#wheel),0,0,0, 0,1,0)
EnableHingeJointAngularMotor(1, #True, 2, 50)
;;;;;;;;;;;;;;
CreateCylinder(#wheel2,2,1)
NormalizeMesh(#wheel2)
CreateEntity(#wheel2, MeshID(#wheel2), MaterialID(0), -0.5, 4, -7)
ScaleEntity(#wheel2,3,2,3)
EntityPhysicBody(#wheel2, #PB_Entity_CylinderBody , 1.0)
HingeJoint(2,EntityID(4),0,0,-0.2, 0,0,1, EntityID(#wheel2),0,0,0, 0,1,0)
EnableHingeJointAngularMotor(2, #False, 2, 50) ; note that it is false
speed.f=2
;SetEntityAttribute(1, #PB_Entity_Friction , 10)
CreateMesh(#plane,#PB_Mesh_TriangleList ,#PB_Mesh_Static)
t=0
CreateNode(#node, 0,2,-3)
AttachNodeObject(#node, CameraID(#camera))
;WorldGravity(0)
;WorldDebug(#PB_World_DebugBody)
Repeat
Event = WindowEvent()
If stopFlag=1
x + rotx
y + roty
z + rotz
EndIf
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Z )
ApplyEntityImpulse(#wheel, 10, 10, 10, 3,3,3)
speed=speed+0.1
If speed > 30: speed = 25:EndIf
EnableHingeJointAngularMotor(1, #True, speed, 50)
ElseIf KeyboardPushed(#PB_Key_X)
speed=speed-0.1
;If speed <0: speed=0:EndIf
EnableHingeJointAngularMotor(1, #True, speed, 50)
EndIf
If KeyboardReleased(#PB_Key_W) ; display wire frame for the material
If wireFrame=0
MaterialShadingMode(0, #PB_Material_Wireframe)
wireFrame ! 1
ElseIf wireFrame=1
MaterialShadingMode(0, #PB_Material_Solid)
wireFrame ! 1
EndIf
EndIf
If KeyboardReleased(#PB_Key_Left)
rotate ! 1
camRo = -0.4
ElseIf KeyboardReleased(#PB_Key_Right)
rotate ! 1
camRo = 0.4
EndIf
If KeyboardPushed(#PB_Key_Down)
camZ=camZ+1
MoveCamera(#camera, 0, 2, camZ,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_Up)
camZ=camZ-1
MoveCamera(#camera, 0, 2, camZ,#PB_Absolute)
EndIf
If rotate
RotateNode(#node, 0, camRo, 0, #PB_Relative)
Else
RotateNode(#node, 0, 0, 0, #PB_Relative)
EndIf
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow