public ConstantCurve(AnimatedComponent component, float value) { this.AnimatedComponent = component; this.Value = value; this.CurveValues = new float[1] { value }; }
public TestOldMan(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); mHealth = new HealthComponent(this, 100.0f); }
public TestNess(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); //switch (mPlayerNumber) //{ // case 0: // // Player 0 means no human control. // break; // case 1: // mInput.PlayerIndex = PlayerIndex.One; // break; // case 2: // mInput.PlayerIndex = PlayerIndex.Two; // break; // case 3: // mInput.PlayerIndex = PlayerIndex.Three; // break; // case 4: // mInput.PlayerIndex = PlayerIndex.Four; // break; //} mHealth = new HealthComponent(this, 100.0f); }
public LinearCurve(AnimatedComponent component) { this.AnimatedComponent = component; this.Values = new List <LinearCurveValue>(); this.CurveValues = this.Values; }
private static Curves.LinearCurve CreateUncompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { var result = new Curves.LinearCurve(component); System.Diagnostics.Trace.WriteLine("Found UncompressedLinearCurve but we don't parse them properly yet :("); reader.BaseStream.Position += 6 * count; return result; }
private static Curves.ConstantCurve CreateConstantCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { if (count != 1) { throw new InvalidOperationException("Unexpected count " + count + " for ConstantCurve"); } var val = reader.ReadSingle(Endianness.BigEndian); var result = new Curves.ConstantCurve(component, val); return result; }
private static Curves.LinearCurve CreateCompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { var result = new Curves.LinearCurve(component); bool flag = (count & 0x8000) != 0; int numValues = count & 0x7FFF; float offset = reader.ReadSingle(Endianness.BigEndian); float scale = reader.ReadSingle(Endianness.BigEndian); var lengths = reader.ReadBytes(numValues); for (var i = 0; i < numValues; i++) { var length = lengths[i]; if (length == 0) { length = 1; } var indices = reader.ReadBytes(length); if (flag) { for (var j = 0; j < length; j++) { ushort sval = reader.ReadUInt16(Endianness.BigEndian); bool isNeg = (sval & 0x8000) != 0; float val = (sval & 0x7FFF) / 32767.0f; if (isNeg) { val = -val; } val = val * scale + offset; Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue() { Time = (float)(indices[j] + 256*i), Value = val }; result.Values.Add(curveVal); } } else { for (var j = 0; j < length; j++) { byte sval = reader.ReadByte(); bool isNeg = (sval & 0x80) != 0; float val = (sval & 0x7F) / 127.0f; if (isNeg) { val = -val; } val = val * scale + offset; Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue() { Time = (float)(indices[j] + 256 * i), Value = val }; result.Values.Add(curveVal); } } } // Align reader position to 4-byte boundary reader.BaseStream.Position = (reader.BaseStream.Position + 3) & 0x7FFFFFFFFFFFFFFC; return result; }
private static Curves.ConstantCurve CreateConstantCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { if (count != 1) { throw new InvalidOperationException("Unexpected count " + count + " for ConstantCurve"); } var val = reader.ReadSingle(Endianness.BigEndian); var result = new Curves.ConstantCurve(component, val); return(result); }
public static void LoadCurves(BinaryReaderEx reader, SpuBinary spuBinary) { var numBones = spuBinary.NumBones; foreach (var section in spuBinary.Sections) { var bones = CreateBoneArray(numBones); foreach (var chunk in section.Chunks) { reader.BaseStream.Position = spuBinary.SpuBasePosition + chunk.Offset; for (var i = 0; i < chunk.NumChildren; i++) { var boneId = reader.ReadInt16(Endianness.BigEndian); var type = reader.ReadInt16(Endianness.BigEndian); var count = reader.ReadInt16(Endianness.BigEndian); reader.ReadInt16(); // Skip 2 unused bytes if ((type == 0 && chunk.Flag != 1) || (type != 0 && chunk.Flag == 1)) { throw new InvalidOperationException(String.Format("Flag/Type mismatch? Flag = {0} Type = {1}", chunk.Flag, type)); } AnimatedComponent component = DetermineAnimatedComponent(type); Curves.CurveBase curve; switch (type) { case 0x00: curve = CreateQuaternionCurve(reader, count); break; case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: curve = CreateCompressedLinearCurve(reader, component, count); break; case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: case 0x10: curve = CreateConstantCurve(reader, component, count); break; case 0x11: case 0x12: case 0x13: curve = CreateUncompressedLinearCurve(reader, component, count); break; default: throw new InvalidOperationException("Unknown curve type " + type); } if (curve.CurveValues.Count == 0) { throw new InvalidOperationException("No Curve Values!?"); } AddCurveToBone(bones, boneId, curve); } } for (var i = 0; i < numBones; i++) { var bone = bones[i]; if (bone == null) { continue; } var boneNode = new AnimatedBoneNode(); boneNode.Bone = bone; boneNode.Parent = section; section.Children.Add(boneNode); } } }
private static Curves.LinearCurve CreateCompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { var result = new Curves.LinearCurve(component); bool flag = (count & 0x8000) != 0; int numValues = count & 0x7FFF; float offset = reader.ReadSingle(Endianness.BigEndian); float scale = reader.ReadSingle(Endianness.BigEndian); var lengths = reader.ReadBytes(numValues); for (var i = 0; i < numValues; i++) { var length = lengths[i]; if (length == 0) { length = 1; } var indices = reader.ReadBytes(length); if (flag) { for (var j = 0; j < length; j++) { ushort sval = reader.ReadUInt16(Endianness.BigEndian); bool isNeg = (sval & 0x8000) != 0; float val = (sval & 0x7FFF) / 32767.0f; if (isNeg) { val = -val; } val = val * scale + offset; Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue() { Time = (float)(indices[j] + 256 * i), Value = val }; result.Values.Add(curveVal); } } else { for (var j = 0; j < length; j++) { byte sval = reader.ReadByte(); bool isNeg = (sval & 0x80) != 0; float val = (sval & 0x7F) / 127.0f; if (isNeg) { val = -val; } val = val * scale + offset; Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue() { Time = (float)(indices[j] + 256 * i), Value = val }; result.Values.Add(curveVal); } } } // Align reader position to 4-byte boundary reader.BaseStream.Position = (reader.BaseStream.Position + 3) & 0x7FFFFFFFFFFFFFFC; return(result); }
private static Curves.LinearCurve CreateUncompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count) { var result = new Curves.LinearCurve(component); System.Diagnostics.Trace.WriteLine("Found UncompressedLinearCurve but we don't parse them properly yet :("); reader.BaseStream.Position += 6 * count; return(result); }