Page 1 of 1

2 issues about HingeJointMotor

Posted: Thu Nov 22, 2018 5:33 pm
by Psychophanta
(1) The first time the HingeJointMotorTarget() is reached it works as expected, but sucesive times it doesn't; it changes values as you can test with snippet. Is there a formal explanation of it, or is it a bug?
(2) Is it possible to perform hingemotor actions with mass=0.0 for the entitybodies?

Code: Select all

RX.u=1024:RY.u=768
InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/fonts", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,RX,RY,"tip",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,0,0,0,#PB_Screen_WaitSynchronization)
CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,3,#PB_Absolute)
LoadTexture(0,"terrain_detail.jpg")
LoadTexture(1,"Wood.jpg")
CreateMaterial(0,TextureID(0))
CreateMaterial(1,TextureID(1))
CreateCylinder(0,0.2,1)
CreateEntity(0,MeshID(0),MaterialID(0),0,0.51,0)
CreateEntity(1,MeshID(0),MaterialID(1),0,-0.51,0)
WorldGravity(0.0)
Global cuerpomasa.f=0.1,cuerpoElasticidad.f=0.711,cuerpoRozamientoDinamico.f=0.91
CreateEntityBody(0,#PB_Entity_CylinderBody,cuerpomasa,cuerpoElasticidad,cuerpoRozamientoDinamico):SetEntityAttribute(0,#PB_Entity_LinearSleeping,0.0):SetEntityAttribute(0,#PB_Entity_AngularSleeping,0.0)
CreateEntityBody(1,#PB_Entity_CylinderBody,cuerpomasa,cuerpoElasticidad,cuerpoRozamientoDinamico):SetEntityAttribute(0,#PB_Entity_LinearSleeping,0.0):SetEntityAttribute(0,#PB_Entity_AngularSleeping,0.0)

HingeJoint(0,EntityID(0),0,-0.5,0,0,1,0,EntityID(1),0,0.5,0,0,1,0):EnableHingeJointAngularMotor(0,#True,0,0.1)
CreateText3D(0,"Hello world","",0.141,RGBA(130,40,95,251)):Text3DAlignment(0,#PB_Text3D_HorizontallyCentered):MoveText3D(0,1.2,0.2,0)
CreateText3D(1,"Hello world2","",0.141,RGBA(130,40,95,251)):Text3DAlignment(1,#PB_Text3D_HorizontallyCentered):MoveText3D(1,1.2,-1,0)

Repeat
  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Right)
    HingeJointMotorTarget(0,-360,0.5); <- applies an angular speed: 'Angle' degrees per 'Velocity' seconds ('Velocity' parameter is not velocity, but time). NOTE the angular value is referred between the rotor (attached to EntityID(1)) respect the stator (attached to EntityID(0)).
  ElseIf KeyboardReleased(#PB_Key_Left)
    HingeJointMotorTarget(0,360,0.5); <- applies an angular speed: 'Angle' degrees per 'Velocity' seconds ('Velocity' parameter is not velocity, but time). NOTE the angular value is referred between the rotor (attached to EntityID(1)) respect the stator (attached to EntityID(0)).
  ElseIf KeyboardReleased(#PB_Key_Up)
    EnableHingeJointAngularMotor(0,#True,-6,1); <- 'TargetVelocity' is an angular speed, in radian/second (seg^-1), given to the stator (attached to EntityID(0)) respect its rotor (attached to EntityID(1)). 'MaxMotorImpulse' is just a torque value, and it is applied only until the stator reaches the 'TargetVelocity' angular speed respect its rotor.
  ElseIf KeyboardReleased(#PB_Key_Down)
    EnableHingeJointAngularMotor(0,#True,6,0.1); <- 'TargetVelocity' is an angular speed, in radian/second (seg^-1), given to the stator (attached to EntityID(0)) respect its rotor (attached to EntityID(1)). 'MaxMotorImpulse' is just a torque value, and it is applied only until the stator reaches the 'TargetVelocity' angular speed respect its rotor.
  EndIf
  Text3DCaption(0,StrF(GetEntityAttribute(0,#PB_Entity_AngularVelocityY)*30/#PI,4)+" RPM")
  Text3DCaption(1,StrF(GetEntityAttribute(1,#PB_Entity_AngularVelocityY)*30/#PI,4)+" RPM")
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)

Re: 2 issues about HingeJointMotor

Posted: Thu Nov 22, 2018 9:05 pm
by Comtois
(2) Is it possible to perform hingemotor actions with mass=0.0 for the entitybodies?
If the mass is zero, the engine considers the body is static