-- Produced by boxnd-gen; edit the generator, not this file.

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 a spherical joint
See also b3SphericalJointDef for details.

Binds @b3CreateSphericalJoint@.
-}
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

{- | Enable\/disable the spherical joint cone limit

Binds @b3SphericalJoint_EnableConeLimit@.
-}
enableConeLimit
  :: JointId
  -> Bool
  -- ^ @enableLimit@
  -> 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)

{- | Is the spherical joint cone limit enabled?

Binds @b3SphericalJoint_IsConeLimitEnabled@.
-}
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)

{- | Get the spherical joint cone limit in radians

Binds @b3SphericalJoint_GetConeLimit@.
-}
getConeLimit
  :: JointId
  -> IO Float
getConeLimit :: JointId -> IO Float
getConeLimit JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetConeLimit JointId
a0

{- | Set the spherical joint limits in radians

Binds @b3SphericalJoint_SetConeLimit@.
-}
setConeLimit
  :: JointId
  -> Float
  -- ^ @angleRadians@
  -> IO ()
setConeLimit :: JointId -> Float -> IO ()
setConeLimit JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b3SphericalJoint_SetConeLimit JointId
a0 Float
a1

{- | Get the spherical joint current cone angle in radians.

Binds @b3SphericalJoint_GetConeAngle@.
-}
getConeAngle
  :: JointId
  -> IO Float
getConeAngle :: JointId -> IO Float
getConeAngle JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetConeAngle JointId
a0

{- | Enable\/disable the spherical joint limit

Binds @b3SphericalJoint_EnableTwistLimit@.
-}
enableTwistLimit
  :: JointId
  -> Bool
  -- ^ @enableLimit@
  -> 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)

{- | Is the spherical joint limit enabled?

Binds @b3SphericalJoint_IsTwistLimitEnabled@.
-}
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)

{- | Get the spherical joint lower limit in radians

Binds @b3SphericalJoint_GetLowerTwistLimit@.
-}
getLowerTwistLimit
  :: JointId
  -> IO Float
getLowerTwistLimit :: JointId -> IO Float
getLowerTwistLimit JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetLowerTwistLimit JointId
a0

{- | Get the spherical joint upper limit in radians

Binds @b3SphericalJoint_GetUpperTwistLimit@.
-}
getUpperTwistLimit
  :: JointId
  -> IO Float
getUpperTwistLimit :: JointId -> IO Float
getUpperTwistLimit JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetUpperTwistLimit JointId
a0

{- | Set the spherical joint limits in radians

Binds @b3SphericalJoint_SetTwistLimits@.
-}
setTwistLimits
  :: JointId
  -> Float
  -- ^ @lowerLimitRadians@
  -> Float
  -- ^ @upperLimitRadians@
  -> 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

{- | Get the spherical joint current twist angle in radians.

Binds @b3SphericalJoint_GetTwistAngle@.
-}
getTwistAngle
  :: JointId
  -> IO Float
getTwistAngle :: JointId -> IO Float
getTwistAngle JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetTwistAngle JointId
a0

{- | Enable\/disable the spherical joint spring

Binds @b3SphericalJoint_EnableSpring@.
-}
enableSpring
  :: JointId
  -> Bool
  -- ^ @enableSpring@
  -> 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)

{- | Is the spherical angular spring enabled?

Binds @b3SphericalJoint_IsSpringEnabled@.
-}
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)

{- | Set the spherical joint spring stiffness in Hertz

Binds @b3SphericalJoint_SetSpringHertz@.
-}
setSpringHertz
  :: JointId
  -> Float
  -- ^ @hertz@
  -> IO ()
setSpringHertz :: JointId -> Float -> IO ()
setSpringHertz JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b3SphericalJoint_SetSpringHertz JointId
a0 Float
a1

{- | Get the spherical joint spring stiffness in Hertz

Binds @b3SphericalJoint_GetSpringHertz@.
-}
getSpringHertz
  :: JointId
  -> IO Float
getSpringHertz :: JointId -> IO Float
getSpringHertz JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetSpringHertz JointId
a0

{- | Set the spherical joint spring damping ratio, non-dimensional

Binds @b3SphericalJoint_SetSpringDampingRatio@.
-}
setSpringDampingRatio
  :: JointId
  -> Float
  -- ^ @dampingRatio@
  -> IO ()
setSpringDampingRatio :: JointId -> Float -> IO ()
setSpringDampingRatio JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b3SphericalJoint_SetSpringDampingRatio JointId
a0 Float
a1

{- | Get the spherical joint spring damping ratio, non-dimensional

Binds @b3SphericalJoint_GetSpringDampingRatio@.
-}
getSpringDampingRatio
  :: JointId
  -> IO Float
getSpringDampingRatio :: JointId -> IO Float
getSpringDampingRatio JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetSpringDampingRatio JointId
a0

{- | Set the spherical joint spring target rotation

Binds @b3SphericalJoint_SetTargetRotation@.
-}
setTargetRotation
  :: JointId
  -> Quat
  -- ^ @targetRotation@
  -> 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

{- | Get the spherical joint spring target rotation

Binds @b3SphericalJoint_GetTargetRotation@.
-}
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

-- | Like 'getTargetRotation', but the result is written into a caller-supplied buffer.
getTargetRotationInto
  :: JointId
  -> Ptr Quat
  -- ^ Result buffer.
  -> IO ()
getTargetRotationInto :: JointId -> Ptr Quat -> IO ()
getTargetRotationInto JointId
a0 Ptr Quat
out =
  JointId -> Ptr Quat -> IO ()
c_b3SphericalJoint_GetTargetRotation JointId
a0 Ptr Quat
out

{- | Enable\/disable a spherical joint motor

Binds @b3SphericalJoint_EnableMotor@.
-}
enableMotor
  :: JointId
  -> Bool
  -- ^ @enableMotor@
  -> 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)

{- | Is the spherical joint motor enabled?

Binds @b3SphericalJoint_IsMotorEnabled@.
-}
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)

{- | Set the spherical joint motor velocity in radians per second

Binds @b3SphericalJoint_SetMotorVelocity@.
-}
setMotorVelocity
  :: JointId
  -> Vec3
  -- ^ @motorVelocity@
  -> 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

{- | Get the spherical joint motor velocity in radians per second

Binds @b3SphericalJoint_GetMotorVelocity@.
-}
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

-- | Like 'getMotorVelocity', but the result is written into a caller-supplied buffer.
getMotorVelocityInto
  :: JointId
  -> Ptr Vec3
  -- ^ Result buffer.
  -> IO ()
getMotorVelocityInto :: JointId -> Ptr Vec3 -> IO ()
getMotorVelocityInto JointId
a0 Ptr Vec3
out =
  JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorVelocity JointId
a0 Ptr Vec3
out

{- | Get the spherical joint current motor torque, usually in newton-meters

Binds @b3SphericalJoint_GetMotorTorque@.
-}
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

-- | Like 'getMotorTorque', but the result is written into a caller-supplied buffer.
getMotorTorqueInto
  :: JointId
  -> Ptr Vec3
  -- ^ Result buffer.
  -> IO ()
getMotorTorqueInto :: JointId -> Ptr Vec3 -> IO ()
getMotorTorqueInto JointId
a0 Ptr Vec3
out =
  JointId -> Ptr Vec3 -> IO ()
c_b3SphericalJoint_GetMotorTorque JointId
a0 Ptr Vec3
out

{- | Set the spherical joint maximum motor torque, usually in newton-meters

Binds @b3SphericalJoint_SetMaxMotorTorque@.
-}
setMaxMotorTorque
  :: JointId
  -> Float
  -- ^ @torque@
  -> IO ()
setMaxMotorTorque :: JointId -> Float -> IO ()
setMaxMotorTorque JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b3SphericalJoint_SetMaxMotorTorque JointId
a0 Float
a1

{- | Get the spherical joint maximum motor torque, usually in newton-meters

Binds @b3SphericalJoint_GetMaxMotorTorque@.
-}
getMaxMotorTorque
  :: JointId
  -> IO Float
getMaxMotorTorque :: JointId -> IO Float
getMaxMotorTorque JointId
a0 =
  JointId -> IO Float
c_b3SphericalJoint_GetMaxMotorTorque JointId
a0