コード例 #1
0
ファイル: Object.cs プロジェクト: damian-666/ReignSDK
        public Object(BinaryReader reader, Model model)
        {
            Model      = model;
            Name       = reader.ReadString();
            parentName = reader.ReadString();

            // transform
            Position = reader.ReadVector3();
            Scale    = reader.ReadVector3();
            Rotation = reader.ReadVector3();

            // animation
            armatureObjectName = reader.ReadString();
            string actionName = reader.ReadString();

            foreach (var action in model.Actions)
            {
                if (actionName == action.Name)
                {
                    DefaultAction = action;
                    break;
                }
            }

            // bone groups
            BoneGroups = new ObjectBoneGroup[reader.ReadInt32()];
            for (int i = 0; i != BoneGroups.Length; ++i)
            {
                BoneGroups[i] = new ObjectBoneGroup(reader);
            }
        }
コード例 #2
0
ファイル: Object.cs プロジェクト: damian-666/ReignSDK
        public static void Write(BinaryWriter writer, SoftwareObject softwareObject)
        {
            string typeName = "";
            var    type     = softwareObject.GetType();

            if (softwareObject.GetType() == typeof(SoftwareObjectMesh))
            {
                typeName = "MESH";
            }
            else if (softwareObject.GetType() == typeof(SoftwareObjectArmature))
            {
                typeName = "ARMATURE";
            }
            else
            {
                Debug.ThrowError("Object", "Unsuported SoftwareObject type: " + softwareObject.GetType());
            }
            writer.Write(typeName);

            // name
            writer.Write(softwareObject.Name);
            writer.Write((softwareObject.Parent != null) ? softwareObject.Parent.Name : "");

            // transform
            writer.WriteVector(softwareObject.Position);
            writer.WriteVector(softwareObject.Scale);
            writer.WriteVector(softwareObject.Rotation);

            // animation
            writer.Write((softwareObject.ArmatureObject != null) ? softwareObject.ArmatureObject.Name : "");
            writer.Write((softwareObject.DefaultAction != null) ? softwareObject.DefaultAction.Name : "");

            // bone groups
            writer.Write(softwareObject.BoneGroups.Count);
            foreach (var bonegroup in softwareObject.BoneGroups)
            {
                ObjectBoneGroup.Write(writer, bonegroup);
            }

            // types
            if (typeName == "MESH")
            {
                ObjectMesh.Write(writer, (SoftwareObjectMesh)softwareObject);
            }
            else if (typeName == "ARMATURE")
            {
                ObjectArmature.Write(writer, (SoftwareObjectArmature)softwareObject);
            }
        }