Пример #1
0
        /// <summary>
        /// Replace the geometries in the scene with the ones contained in the given Assimp scene.
        /// </summary>
        /// <param name="scene"></param>
        public void ReplaceGeometries(Assimp.Scene scene)
        {
            var skinToBoneMatrices = ComputeSkinToBoneMatrices(scene);

            GeometryList.Clear();
            Atomics.Clear();

            for (var i = 0; i < scene.Meshes.Count; i++)
            {
                var assimpMesh = scene.Meshes[i];

                var rootNode = FindMeshRootNode(scene.RootNode, i) ?? scene.RootNode;
                TransformMeshVertices(assimpMesh, rootNode);

                var geometryNode = new RwGeometryNode(this, assimpMesh, scene.Materials[assimpMesh.MaterialIndex], FrameList, skinToBoneMatrices, out bool singleWeight);
                GeometryList.Add(geometryNode);

                var atomicNode = new RwAtomicNode(this, 0, i, 5);
                if (singleWeight)
                {
                    if (assimpMesh.Bones.Count != 0)
                    {
                        atomicNode.FrameIndex = FrameList.GetFrameIndexByName(assimpMesh.Bones[0].Name);
                    }
                    else if (rootNode != null)
                    {
                        atomicNode.FrameIndex = FrameList.GetFrameIndexByName(rootNode.Name);
                    }
                }

                Atomics.Add(atomicNode);
            }

            mStructNode = new RwClumpStructNode(this);
        }
Пример #2
0
 public RwClumpNode(RwNode parent)
     : base(RwNodeId.RwClumpNode, parent)
 {
     Atomics            = new List <RwAtomicNode>();
     FrameList          = new RwFrameListNode(this);
     GeometryList       = new RwGeometryListNode(this);
     mExtensionNodeNode = new RwExtensionNode(this);
     mStructNode        = new RwClumpStructNode(this);
 }
Пример #3
0
        /// <summary>
        /// Constructor only to be called in <see cref="RwNodeFactory"/>.
        /// </summary>
        internal RwClumpNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStructNode  = RwNodeFactory.GetNode <RwClumpStructNode>(this, reader);
            FrameList    = RwNodeFactory.GetNode <RwFrameListNode>(this, reader);
            GeometryList = RwNodeFactory.GetNode <RwGeometryListNode>(this, reader);
            Atomics      = new List <RwAtomicNode>(mStructNode.AtomicCount);

            for (int i = 0; i < mStructNode.AtomicCount; i++)
            {
                Atomics.Add(RwNodeFactory.GetNode <RwAtomicNode>(this, reader));
            }

            if (RwNodeFactory.PeekNode(reader) == RwNodeId.RwExtensionNode)
            {
                mExtensionNodeNode = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);
            }
            else
            {
                mExtensionNodeNode = new RwExtensionNode(this);
            }
        }
Пример #4
0
        public RwClumpNode(Stream stream, bool leaveOpen = false)
            : base(RwNodeId.RwClumpNode)
        {
            var node = (RwClumpNode)RwNode.Load(stream, leaveOpen);

            mStructNode        = node.mStructNode;
            mStructNode.Parent = this;

            FrameList        = node.FrameList;
            FrameList.Parent = this;

            GeometryList        = node.GeometryList;
            GeometryList.Parent = this;

            Atomics = node.Atomics;
            foreach (var atomicNode in Atomics)
            {
                atomicNode.Parent = this;
            }

            mExtensionNodeNode        = node.mExtensionNodeNode;
            mExtensionNodeNode.Parent = this;
        }
Пример #5
0
        /// <summary>
        /// Inherited from <see cref="RwNode"/>. Writes the data beyond the header.
        /// </summary>
        /// <param name="writer">The <see cref="BinaryWriter"/> to write the data with.</param>
        protected internal override void WriteBody(BinaryWriter writer)
        {
            mStructNode = new RwClumpStructNode(this);
            mStructNode.Write(writer);
            FrameList.Write(writer);
            GeometryList.Write(writer);

            foreach (RwAtomicNode drawCall in Atomics)
            {
                drawCall.Write(writer);
            }

            if (HasAtomics)
            {
                mExtensionNodeNode.Write(writer);
            }

            var author = new RwStringNode("Model generated by Amicitia");

            author.Id     = RwNodeId.RmdAuthor;
            author.Parent = this;

            author.Write(writer);
        }