Beispiel #1
0
		public AnimationChannel (string nodeName, AnimationBehavior preState, AnimationBehavior postState, PositionKey[] posKeys, RotationKey[] rotKeys, ScalingKey[] scaleKeys) {
			_nodeName = nodeName;
			_preState = preState;
			_postState = postState;
			_posKeys = posKeys;
			_rotKeys = rotKeys;
			_scaleKeys = scaleKeys;
		}
Beispiel #2
0
        unsafe Dictionary <string, Animation> ReadAnimations(BinaryReader reader)
        {
            var anims = new Dictionary <string, Animation>();

            var count = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var name      = reader.ReadString();
                var duration  = reader.ReadDouble();
                var rate      = reader.ReadDouble();
                var chanCount = reader.ReadInt32();
                var channels  = new AnimationChannel[chanCount];
                for (var j = 0; j < chanCount; j++)
                {
                    var nodeName  = reader.ReadString();
                    var preState  = (AnimationBehavior)reader.ReadInt32();
                    var postState = (AnimationBehavior)reader.ReadInt32();
                    var keyCount  = reader.ReadInt32();
                    var positions = new PositionKey[keyCount];
                    var sz        = keyCount * sizeof(PositionKey);
                    var buf       = new byte[sz];
                    reader.Read(buf, 0, sz);
                    fixed(byte *p = &buf[0])
                    {
                        var src = (PositionKey *)p;

                        fixed(PositionKey *dst = &positions[0])
                        {
                            for (var k = 0; k < keyCount; k++)
                            {
                                *(dst + k) = *(src + k);
                            }
                        }
                    }

                    keyCount = reader.ReadInt32();
                    var rotations = new RotationKey[keyCount];
                    sz = keyCount * sizeof(RotationKey);
                    if (buf.Length < sz)
                    {
                        buf = new byte[sz];
                    }
                    reader.Read(buf, 0, sz);
                    fixed(byte *p = &buf[0])
                    {
                        var src = (RotationKey *)p;

                        fixed(RotationKey *dst = &rotations[0])
                        {
                            for (var k = 0; k < keyCount; k++)
                            {
                                *(dst + k) = *(src + k);
                            }
                        }
                    }

                    keyCount = reader.ReadInt32();
                    var scales = new ScalingKey[keyCount];
                    sz = keyCount * sizeof(ScalingKey);
                    if (buf.Length < sz)
                    {
                        buf = new byte[sz];
                    }
                    reader.Read(buf, 0, sz);
                    fixed(byte *p = &buf[0])
                    {
                        var src = (ScalingKey *)p;

                        fixed(ScalingKey *dst = &scales[0])
                        {
                            for (var k = 0; k < keyCount; k++)
                            {
                                *(dst + k) = *(src + k);
                            }
                        }
                    }

                    channels[j] = new AnimationChannel(nodeName, preState, postState, positions, rotations, scales);
                }
                anims[name] = new Animation(name, duration, rate, channels);
            }

            return(anims);
        }
Beispiel #3
0
		unsafe Dictionary<string, Animation> ReadAnimations(BinaryReader reader) {
			var anims = new Dictionary<string, Animation>();

			var count = reader.ReadInt32();
			for (var i = 0; i < count; i++) {
				var name = reader.ReadString();
				var duration = reader.ReadDouble();
				var rate = reader.ReadDouble();
				var chanCount = reader.ReadInt32();
				var channels = new AnimationChannel[chanCount];
				for (var j = 0; j < chanCount; j++) {
					var nodeName = reader.ReadString();
					var preState = (AnimationBehavior)reader.ReadInt32();
					var postState = (AnimationBehavior)reader.ReadInt32();
					var keyCount = reader.ReadInt32();
					var positions = new PositionKey[keyCount];
					var sz = keyCount * sizeof(PositionKey);
					var buf = new byte[sz];
					reader.Read(buf, 0, sz);
					fixed(byte *p = &buf[0]) {
						var src = (PositionKey*)p;
						fixed(PositionKey* dst = &positions[0]) {
							for (var k = 0; k < keyCount; k++) {
								*(dst + k) = *(src + k);
							}
						}
					}
					keyCount = reader.ReadInt32();
					var rotations = new RotationKey[keyCount];
					sz = keyCount * sizeof(RotationKey);
					if (buf.Length < sz)
						buf = new byte[sz];
					reader.Read(buf, 0, sz);
					fixed(byte *p = &buf[0]) {
						var src = (RotationKey*)p;
						fixed(RotationKey *dst = &rotations[0]) {
							for (var k = 0; k < keyCount; k++) {
								*(dst + k) = *(src + k);
							}
						}
					}
					keyCount = reader.ReadInt32();
					var scales = new ScalingKey[keyCount];
					sz = keyCount * sizeof(ScalingKey);
					if (buf.Length < sz)
						buf = new byte[sz];
					reader.Read(buf, 0, sz);
					fixed(byte *p = &buf[0]) {
						var src = (ScalingKey*)p;
						fixed(ScalingKey *dst = &scales[0]) {
							for (var k = 0; k < keyCount; k++) {
								*(dst + k) = *(src + k);
							}
						}
					}
					channels[j] = new AnimationChannel(nodeName, preState, postState, positions, rotations, scales);
				}
				anims[name] = new Animation(name, duration, rate, channels);
			}

			return anims;
		}