module Box3D.SphericalJoint
( create
, enableConeLimit
, isConeLimitEnabled
, getConeLimit
, setConeLimit
, getConeAngle
, enableTwistLimit
, isTwistLimitEnabled
, getLowerTwistLimit
, getUpperTwistLimit
, setTwistLimits
, getTwistAngle
, enableSpring
, isSpringEnabled
, setSpringHertz
, getSpringHertz
, setSpringDampingRatio
, getSpringDampingRatio
, setTargetRotation
, getTargetRotation
, getTargetRotationInto
, enableMotor
, isMotorEnabled
, setMotorVelocity
, getMotorVelocity
, getMotorVelocityInto
, getMotorTorque
, getMotorTorqueInto
, setMaxMotorTorque
, getMaxMotorTorque
)
where
import Foreign
import Foreign.C.Types (CBool(..))
import Box3D.Id (JointId(..), WorldId(..))
import Box3D.MathTypes (Quat, Vec3)
import Box3D.Types (SphericalJointDef)
foreign import ccall unsafe "b3CreateSphericalJoint"
c_b3CreateSphericalJoint :: WorldId -> Ptr SphericalJointDef -> IO JointId
foreign import ccall unsafe "b3SphericalJoint_EnableConeLimit"
c_b3SphericalJoint_EnableConeLimit :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b3SphericalJoint_IsConeLimitEnabled"
c_b3SphericalJoint_IsConeLimitEnabled :: JointId -> IO CBool
foreign import ccall unsafe "b3SphericalJoint_GetConeLimit"
c_b3SphericalJoint_GetConeLimit :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_SetConeLimit"
c_b3SphericalJoint_SetConeLimit :: JointId -> Float -> IO ()
foreign import ccall unsafe "b3SphericalJoint_GetConeAngle"
c_b3SphericalJoint_GetConeAngle :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_EnableTwistLimit"
c_b3SphericalJoint_EnableTwistLimit :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b3SphericalJoint_IsTwistLimitEnabled"
c_b3SphericalJoint_IsTwistLimitEnabled :: JointId -> IO CBool
foreign import ccall unsafe "b3SphericalJoint_GetLowerTwistLimit"
c_b3SphericalJoint_GetLowerTwistLimit :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_GetUpperTwistLimit"
c_b3SphericalJoint_GetUpperTwistLimit :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_SetTwistLimits"
c_b3SphericalJoint_SetTwistLimits :: JointId -> Float -> Float -> IO ()
foreign import ccall unsafe "b3SphericalJoint_GetTwistAngle"
c_b3SphericalJoint_GetTwistAngle :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_EnableSpring"
c_b3SphericalJoint_EnableSpring :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b3SphericalJoint_IsSpringEnabled"
c_b3SphericalJoint_IsSpringEnabled :: JointId -> IO CBool
foreign import ccall unsafe "b3SphericalJoint_SetSpringHertz"
c_b3SphericalJoint_SetSpringHertz :: JointId -> Float -> IO ()
foreign import ccall unsafe "b3SphericalJoint_GetSpringHertz"
c_b3SphericalJoint_GetSpringHertz :: JointId -> IO Float
foreign import ccall unsafe "b3SphericalJoint_SetSpringDampingRatio"
c_b3SphericalJoint_SetSpringDampingRatio :: JointId -> Float -> IO ()
foreign import ccall unsafe "b3SphericalJoint_GetSpringDampingRatio"
c_b3SphericalJoint_GetSpringDampingRatio :: JointId -> IO Float
foreign import ccall unsafe "hsg_b3SphericalJoint_SetTargetRotation"
c_b3SphericalJoint_SetTargetRotation :: JointId -> Ptr Quat -> IO ()
foreign import ccall unsafe "hsg_b3SphericalJoint_GetTargetRotation"
c_b3SphericalJoint_GetTargetRotation :: JointId -> Ptr Quat -> IO ()
foreign import ccall unsafe "b3SphericalJoint_EnableMotor"
c_b3SphericalJoint_EnableMotor :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b3SphericalJoint_IsMotorEnabled"
c_b3SphericalJoint_IsMotorEnabled :: JointId -> IO CBool
foreign import ccall unsafe "hsg_b3SphericalJoint_SetMotorVelocity"
c_b3SphericalJoint_SetMotorVelocity :: JointId -> Ptr Vec3 -> IO ()
foreign import ccall unsafe "hsg_b3SphericalJoint_GetMotorVelocity"
c_b3SphericalJoint_GetMotorVelocity :: JointId -> Ptr Vec3 -> IO ()
foreign import ccall unsafe "hsg_b3SphericalJoint_GetMotorTorque"
c_b3SphericalJoint_GetMotorTorque :: JointId -> Ptr Vec3 -> IO ()
foreign import ccall unsafe "b3SphericalJoint_SetMaxMotorTorque"
c_b3SphericalJoint_SetMaxMotorTorque :: JointId -> Float -> IO ()
foreign import ccall unsafe "b3SphericalJoint_GetMaxMotorTorque"
c_b3SphericalJoint_GetMaxMotorTorque :: JointId -> IO Float
create
:: WorldId
-> SphericalJointDef
-> IO JointId
create :: WorldId -> SphericalJointDef -> IO JointId
create WorldId
a0 SphericalJointDef
a1 =
SphericalJointDef
-> (Ptr SphericalJointDef -> IO JointId) -> IO JointId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with SphericalJointDef
a1 ((Ptr SphericalJointDef -> IO JointId) -> IO JointId)
-> (Ptr SphericalJointDef -> IO JointId) -> IO JointId
forall a b. (a -> b) -> a -> b
$ \Ptr SphericalJointDef
p1 ->
WorldId -> Ptr SphericalJointDef -> IO JointId
c_b3CreateSphericalJoint WorldId
a0 Ptr SphericalJointDef
p1
enableConeLimit
:: JointId
-> Bool
-> IO ()
enableConeLimit :: JointId -> Bool -> IO ()
enableConeLimit JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b3SphericalJoint_EnableConeLimit JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
isConeLimitEnabled
:: JointId
-> IO Bool
isConeLimitEnabled :: JointId -> IO Bool
isConeLimitEnabled JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b3SphericalJoint_IsConeLimitEnabled JointId
a0)
getConeLimit
:: JointId
-> IO Float
getConeLimit :: JointId -> IO Float
getConeLimit JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetConeLimit JointId
a0
setConeLimit
:: JointId
-> Float
-> IO ()
setConeLimit :: JointId -> Float -> IO ()
setConeLimit JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b3SphericalJoint_SetConeLimit JointId
a0 Float
a1
getConeAngle
:: JointId
-> IO Float
getConeAngle :: JointId -> IO Float
getConeAngle JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetConeAngle JointId
a0
enableTwistLimit
:: JointId
-> Bool
-> IO ()
enableTwistLimit :: JointId -> Bool -> IO ()
enableTwistLimit JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b3SphericalJoint_EnableTwistLimit JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
isTwistLimitEnabled
:: JointId
-> IO Bool
isTwistLimitEnabled :: JointId -> IO Bool
isTwistLimitEnabled JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b3SphericalJoint_IsTwistLimitEnabled JointId
a0)
getLowerTwistLimit
:: JointId
-> IO Float
getLowerTwistLimit :: JointId -> IO Float
getLowerTwistLimit JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetLowerTwistLimit JointId
a0
getUpperTwistLimit
:: JointId
-> IO Float
getUpperTwistLimit :: JointId -> IO Float
getUpperTwistLimit JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetUpperTwistLimit JointId
a0
setTwistLimits
:: JointId
-> Float
-> Float
-> IO ()
setTwistLimits :: JointId -> Float -> Float -> IO ()
setTwistLimits JointId
a0 Float
a1 Float
a2 =
JointId -> Float -> Float -> IO ()
c_b3SphericalJoint_SetTwistLimits JointId
a0 Float
a1 Float
a2
getTwistAngle
:: JointId
-> IO Float
getTwistAngle :: JointId -> IO Float
getTwistAngle JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetTwistAngle JointId
a0
enableSpring
:: JointId
-> Bool
-> IO ()
enableSpring :: JointId -> Bool -> IO ()
enableSpring JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b3SphericalJoint_EnableSpring JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
isSpringEnabled
:: JointId
-> IO Bool
isSpringEnabled :: JointId -> IO Bool
isSpringEnabled JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b3SphericalJoint_IsSpringEnabled JointId
a0)
setSpringHertz
:: JointId
-> Float
-> IO ()
setSpringHertz :: JointId -> Float -> IO ()
setSpringHertz JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b3SphericalJoint_SetSpringHertz JointId
a0 Float
a1
getSpringHertz
:: JointId
-> IO Float
getSpringHertz :: JointId -> IO Float
getSpringHertz JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetSpringHertz JointId
a0
setSpringDampingRatio
:: JointId
-> Float
-> IO ()
setSpringDampingRatio :: JointId -> Float -> IO ()
setSpringDampingRatio JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b3SphericalJoint_SetSpringDampingRatio JointId
a0 Float
a1
getSpringDampingRatio
:: JointId
-> IO Float
getSpringDampingRatio :: JointId -> IO Float
getSpringDampingRatio JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetSpringDampingRatio JointId
a0
setTargetRotation
:: JointId
-> Quat
-> IO ()
setTargetRotation :: JointId -> Quat -> IO ()
setTargetRotation JointId
a0 Quat
a1 =
Quat -> (Ptr Quat -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Quat
a1 ((Ptr Quat -> IO ()) -> IO ()) -> (Ptr Quat -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Quat
p1 ->
JointId -> Ptr Quat -> IO ()
c_b3SphericalJoint_SetTargetRotation JointId
a0 Ptr Quat
p1
getTargetRotation
:: JointId
-> IO Quat
getTargetRotation :: JointId -> IO Quat
getTargetRotation JointId
a0 =
(Ptr Quat -> IO Quat) -> IO Quat
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Quat -> IO Quat) -> IO Quat)
-> (Ptr Quat -> IO Quat) -> IO Quat
forall a b. (a -> b) -> a -> b
$ \Ptr Quat
pOut -> JointId -> Ptr Quat -> IO ()
c_b3SphericalJoint_GetTargetRotation JointId
a0 Ptr Quat
pOut IO () -> IO Quat -> IO Quat
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Quat -> IO Quat
forall a. Storable a => Ptr a -> IO a
peek Ptr Quat
pOut
getTargetRotationInto
:: JointId
-> Ptr Quat
-> IO ()
getTargetRotationInto :: JointId -> Ptr Quat -> IO ()
getTargetRotationInto JointId
a0 Ptr Quat
out =
JointId -> Ptr Quat -> IO ()
c_b3SphericalJoint_GetTargetRotation JointId
a0 Ptr Quat
out
enableMotor
:: JointId
-> Bool
-> IO ()
enableMotor :: JointId -> Bool -> IO ()
enableMotor JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b3SphericalJoint_EnableMotor JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
isMotorEnabled
:: JointId
-> IO Bool
isMotorEnabled :: JointId -> IO Bool
isMotorEnabled JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b3SphericalJoint_IsMotorEnabled JointId
a0)
setMotorVelocity
:: JointId
-> Vec3
-> IO ()
setMotorVelocity :: JointId -> Vec3 -> IO ()
setMotorVelocity JointId
a0 Vec3
a1 =
Vec3 -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a1 ((Ptr Vec3 -> IO ()) -> IO ()) -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p1 ->
JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_SetMotorVelocity JointId
a0 Ptr Vec3
p1
getMotorVelocity
:: JointId
-> IO Vec3
getMotorVelocity :: JointId -> IO Vec3
getMotorVelocity JointId
a0 =
(Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Vec3 -> IO Vec3) -> IO Vec3)
-> (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
pOut -> JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorVelocity JointId
a0 Ptr Vec3
pOut IO () -> IO Vec3 -> IO Vec3
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Vec3 -> IO Vec3
forall a. Storable a => Ptr a -> IO a
peek Ptr Vec3
pOut
getMotorVelocityInto
:: JointId
-> Ptr Vec3
-> IO ()
getMotorVelocityInto :: JointId -> Ptr Vec3 -> IO ()
getMotorVelocityInto JointId
a0 Ptr Vec3
out =
JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorVelocity JointId
a0 Ptr Vec3
out
getMotorTorque
:: JointId
-> IO Vec3
getMotorTorque :: JointId -> IO Vec3
getMotorTorque JointId
a0 =
(Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Vec3 -> IO Vec3) -> IO Vec3)
-> (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
pOut -> JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorTorque JointId
a0 Ptr Vec3
pOut IO () -> IO Vec3 -> IO Vec3
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Vec3 -> IO Vec3
forall a. Storable a => Ptr a -> IO a
peek Ptr Vec3
pOut
getMotorTorqueInto
:: JointId
-> Ptr Vec3
-> IO ()
getMotorTorqueInto :: JointId -> Ptr Vec3 -> IO ()
getMotorTorqueInto JointId
a0 Ptr Vec3
out =
JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorTorque JointId
a0 Ptr Vec3
out
setMaxMotorTorque
:: JointId
-> Float
-> IO ()
setMaxMotorTorque :: JointId -> Float -> IO ()
setMaxMotorTorque JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b3SphericalJoint_SetMaxMotorTorque JointId
a0 Float
a1
getMaxMotorTorque
:: JointId
-> IO Float
getMaxMotorTorque :: JointId -> IO Float
getMaxMotorTorque JointId
a0 =
JointId -> IO Float
c_b3SphericalJoint_GetMaxMotorTorque JointId
a0