i = 60;
search = true;
break;
case 60:
// Position
objectupdate.Position = new Vector3(block.ObjectData, pos);
pos += 12;
// Velocity
objectupdate.Velocity = new Vector3(block.ObjectData, pos);
pos += 12;
// Acceleration
objectupdate.Acceleration = new Vector3(block.ObjectData, pos);
pos += 12;
// Rotation (theta)
objectupdate.Rotation = new Quaternion(block.ObjectData, pos, true);
pos += 12;
// Angular velocity (omega)
objectupdate.AngularVelocity = new Vector3(block.ObjectData, pos);
pos += 12;
break;
case 48:
// Collision normal for avatar
objectupdate.CollisionPlane = new Vector4(block.ObjectData, pos);
pos += 16;
//Keep on decoding
i = 32;
search = true;
break;
case 32:
// The data is an array of unsigned shorts
//TODO need to handle Little Endian Data
// Position
objectupdate.Position = new Vector3(
Utils.UInt16ToFloat(block.ObjectData, pos, -0.5f * 256.0f, 1.5f * 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 2, -0.5f * 256.0f, 1.5f * 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 3.0f * 256.0f));
pos += 6;
// Velocity
objectupdate.Velocity = new Vector3(
Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
pos += 6;
// Acceleration
objectupdate.Acceleration = new Vector3(
Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
pos += 6;
// Rotation (theta)
objectupdate.Rotation = new Quaternion(
Utils.UInt16ToFloat(block.ObjectData, pos, -1.0f, 1.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 2, -1.0f, 1.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 4, -1.0f, 1.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 6, -1.0f, 1.0f));
pos += 8;
// Angular velocity (omega)
objectupdate.AngularVelocity = new Vector3(
Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
pos += 6;
break;
case 16:
// The data is an array of single bytes (8-bit numbers)
//TODO need to handle Little Endian Data
// Position
objectupdate.Position = new Vector3(
Utils.byteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
pos += 3;
// Velocity
objectupdate.Velocity = new Vector3(
Utils.byteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
pos += 3;
// Accleration
objectupdate.Acceleration = new Vector3(
Utils.byteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
pos += 3;
// Rotation
objectupdate.Rotation = new Quaternion(
Utils.byteToFloat(block.ObjectData, pos, -1.0f, 1.0f),
Utils.byteToFloat(block.ObjectData, pos + 1, -1.0f, 1.0f),
Utils.byteToFloat(block.ObjectData, pos + 2, -1.0f, 1.0f),
Utils.byteToFloat(block.ObjectData, pos + 3, -1.0f, 1.0f));
pos += 4;
// Angular Velocity
objectupdate.AngularVelocity = new Vector3(
Utils.byteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
Utils.byteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
pos += 3;