Пример #1
0
        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);
            }
        }
Пример #2
0
        internal void linkObjects(RMX_Object o)
        {
            // find parent
            if (!string.IsNullOrEmpty(o.Parent))
            {
                foreach (var parent in Model.Objects)
                {
                    if (o.Parent == parent.Name)
                    {
                        Parent = parent;
                        break;
                    }
                }
                if (Parent == null)
                {
                    Debug.ThrowError("SoftwareObject", "Failed to find Parent: " + o.Parent);
                }
            }

            // find armature object
            if (o.ArmatureObject != null)
            {
                foreach (var action in Model.Objects)
                {
                    if (o.ArmatureObject.Name == action.Name)
                    {
                        ArmatureObject = (SoftwareObjectArmature)action;
                        break;
                    }
                }
                if (ArmatureObject == null)
                {
                    Debug.ThrowError("SoftwareObject", "Failed to find ArmatureObject: " + o.ArmatureObject.Name);
                }
            }
        }
Пример #3
0
        internal void linkObjects(RMX_Object o)
        {
            // find parent
            if (!string.IsNullOrEmpty(o.Parent))
            {
                foreach (var parent in Model.Objects)
                {
                    if (o.Parent == parent.Name)
                    {
                        Parent = parent;
                        break;
                    }
                }
                if (Parent == null) Debug.ThrowError("SoftwareObject", "Failed to find Parent: " + o.Parent);
            }

            // find armature object
            if (o.ArmatureObject != null)
            {
                foreach (var action in Model.Objects)
                {
                    if (o.ArmatureObject.Name == action.Name)
                    {
                        ArmatureObject = (SoftwareObjectArmature)action;
                        break;
                    }
                }
                if (ArmatureObject == null) Debug.ThrowError("SoftwareObject", "Failed to find ArmatureObject: " + o.ArmatureObject.Name);
            }
        }