Revision Difference
Kinect_developing#515839
<cat>Dev.Lua</cat>
Developing for the Kinect is easier than you'd think.
# Bone Points
The kinect provides us with a number of vectors representing specific bones. These are encoded into the usercommand (in the same way that mouse buttons and view angles are) and are available on the player object serverside, and in multiplayer - for prediction purposes - clientside.
To access these points you can call
```
ply:MotionSensorPos( point_id )
```
Note that these positions aren't in world coordinates - so you will have to multiply them to get them to a usable size.
To access specific bones you can use these enums:
```
SENSORBONE.HIP
SENSORBONE.SPINE
SENSORBONE.SHOULDER
SENSORBONE.HEAD
SENSORBONE.SHOULDER_LEFT
SENSORBONE.ELBOW_LEFT
SENSORBONE.WRIST_LEFT
SENSORBONE.HAND_LEFT
SENSORBONE.SHOULDER_RIGHT
SENSORBONE.ELBOW_RIGHT
SENSORBONE.WRIST_RIGHT
SENSORBONE.HAND_WRIGHT
SENSORBONE.HIP_LEFT
SENSORBONE.KNEE_LEFT
SENSORBONE.ANKLE_LEFT
SENSORBONE.FOOT_LEFT
SENSORBONE.HIP_RIGHT
SENSORBONE.KNEE_RIGHT
SENSORBONE.ANKLE_RIGHT
SENSORBONE.FOOT_RIGHT
```
# <page>motionsensor</page>
The <page>motionsensor</page> offers direct access to the sensor clientside, and a few utility functions sharedside.
## motionsensor.DebugBones
This table contains subtables of bone ids allowing you to iterate it and draw bones.
```
for k, v in pairs( motionsensor.DebugBones ) do
```⤶
⤶
```⤶
⤶
debugoverlay.Line( ply:MotionSensorPos( v[1] ), ply:MotionSensorPos( v[2] ), 0.5 )⤶
```⤶
⤶
⤶
```⤶
⤶
end⤶
⤶
debugoverlay.Line( ply:MotionSensorPos( v[1] ), ply:MotionSensorPos( v[2] ), 0.5 )
⤶
end⤶
```
## <page>motionsensor.IsAvailable</page>()
Clientside - will return true if we have detected that there's a kinect connected to the PC.
## <page>motionsensor.IsActive</page>()
Clientside - will return true if a kinect is connected - and active (ie - Start has been called).
## <page>motionsensor.Start</page>()
Clientside - this starts access to the kinect sensor. Note that this usually freezes the game for a couple of seconds.