internal RwHAnimFrameExtensionNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            int version = reader.ReadInt32();

            if (version != VERSION)
            {
                throw new NotImplementedException("Unexpected version for RWHierarchyAnimPlugin");
            }

            NameId = reader.ReadInt32();
            int numNodes = reader.ReadInt32();

            if (numNodes == 0)
            {
                return;
            }

            RwHAnimHierarchyFlags flags  = (RwHAnimHierarchyFlags)reader.ReadUInt32();
            int keyFrameSize             = reader.ReadInt32();
            List <RwHAnimNodeInfo> nodes = new List <RwHAnimNodeInfo>(numNodes);

            for (int i = 0; i < numNodes; i++)
            {
                nodes.Add(new RwHAnimNodeInfo(reader));
            }

            Hierarchy = new RwHAnimHierarchy(flags, nodes);
        }
Exemplo n.º 2
0
 internal RwClumpStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mAtomicCount = reader.ReadInt32();
     mLightCount  = reader.ReadInt32();
     mCameraCount = reader.ReadInt32();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializer only to be called by the <see cref="RwNodeFactory"/>.
        /// </summary>
        internal RwRasterDataStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            long start = reader.BaseStream.Position;

            if (RasterInfoStructNode.Format.HasFlagUnchecked(RwRasterFormats.HasHeaders))
            {
                mImageHeader = new PS2StandardImageHeader(reader);
            }

            if (PS2PixelFormatHelper.IsIndexedPixelFormat(RasterInfoStructNode.Tex0Register.TexturePixelFormat))
            {
                ReadIndices(reader);

                if (RasterInfoStructNode.Format.HasFlagUnchecked(RwRasterFormats.HasHeaders))
                {
                    mPaletteHeader = new PS2StandardImageHeader(reader);
                }

                ReadPalette(reader);
            }
            else
            {
                ReadPixels(reader);
            }

            long end = reader.BaseStream.Position;

            mMipMapData = reader.ReadBytes((int)((start + Size) - end));
        }
Exemplo n.º 4
0
        internal RwAtomicSectorHeader(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
        {
            MaterialIdBase = reader.ReadInt32();
            TriangleCount  = reader.ReadInt32();
            VertexCount    = reader.ReadInt32();
            Min            = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Max            = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Unused1        = reader.ReadInt32();
            Unused2        = reader.ReadInt32();

            var world = FindParent <RwWorld>(RwNodeId.RwWorldNode);

            if (world == null)
            {
                throw new System.Exception();
            }

            var format = world.Header.Format;

            Positions = reader.ReadVector3Array(VertexCount);

            if (format.HasFlag(RwWorldFormatFlags.Normals))
            {
                Normals = new Vector3[VertexCount];
                for (int i = 0; i < VertexCount; i++)
                {
                    Normals[i] = new Vector3(reader.ReadSByte() / 128f, reader.ReadSByte() / 128f, reader.ReadSByte() / 128f);
                    reader.BaseStream.Position += 1; // padding
                }
            }

            if (format.HasFlag(RwWorldFormatFlags.Prelit))
            {
                Colors = reader.ReadColorArray(VertexCount);
            }

            if (format.HasFlag(RwWorldFormatFlags.Textured))
            {
                TextureCoordinateChannels    = new Vector2[1][];
                TextureCoordinateChannels[0] = reader.ReadVector2Array(VertexCount);
            }
            else if (format.HasFlag(RwWorldFormatFlags.Textured2))
            {
                TextureCoordinateChannels    = new Vector2[2][];
                TextureCoordinateChannels[0] = reader.ReadVector2Array(VertexCount);
                TextureCoordinateChannels[1] = reader.ReadVector2Array(VertexCount);
            }

            Triangles = new RwTriangle[TriangleCount];
            for (int i = 0; i < Triangles.Length; i++)
            {
                var v1         = reader.ReadUInt16();
                var v2         = reader.ReadUInt16();
                var v3         = reader.ReadUInt16();
                var materialId = reader.ReadInt16();

                Triangles[i] = new RwTriangle(v1, v2, v3, materialId);
            }
        }
Exemplo n.º 5
0
 internal RwAtomicStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mFrameIndex    = reader.ReadInt32();
     mGeometryIndex = reader.ReadInt32();
     mFlag1         = reader.ReadInt32();
     mFlag2         = reader.ReadInt32();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor only to be called in <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RwTextureNativeNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mStructNode       = RwNodeFactory.GetNode <RwTextureNativeStructNode>(this, reader);
     mName             = RwNodeFactory.GetNode <RwStringNode>(this, reader);
     mMaskName         = RwNodeFactory.GetNode <RwStringNode>(this, reader);
     mRasterStructNode = RwNodeFactory.GetNode <RwRasterStructNode>(this, reader);
     mExtensionNode    = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);
 }
Exemplo n.º 7
0
 internal RwPlaneSectorHeader(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
 {
     SectorType         = reader.ReadInt32();
     Value              = reader.ReadSingle();
     LeftIsWorldSector  = reader.ReadInt32() == 1;
     RightIsWorldSector = reader.ReadInt32() == 1;
     LeftValue          = reader.ReadSingle();
     RightValue         = reader.ReadSingle();
 }
 internal RwMaterialListStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mMatCount      = reader.ReadInt32();
     mMatReferences = new int[mMatCount];
     for (int i = 0; i < mMatCount; i++)
     {
         mMatReferences[i] = reader.ReadInt32();
     }
 }
Exemplo n.º 9
0
 internal RwMaterialStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     Field00    = reader.ReadInt32();
     Color      = Color.FromArgb(reader.ReadInt32());
     Field08    = reader.ReadInt32();
     IsTextured = reader.ReadInt32() == 1;
     Ambient    = reader.ReadSingle();
     Specular   = reader.ReadSingle();
     Diffuse    = reader.ReadSingle();
 }
Exemplo n.º 10
0
        internal RwGeometryListNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStructNode   = RwNodeFactory.GetNode <RwGeometryListStructNode>(this, reader);
            mGeometryList = new List <RwGeometryNode>(mStructNode.GeometryCount);

            for (int i = 0; i < mStructNode.GeometryCount; i++)
            {
                mGeometryList.Add(RwNodeFactory.GetNode <RwGeometryNode>(this, reader));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializer only to be called in <see cref="RwNodeFactory"/>.
        /// </summary>
        internal RwUVAnimationDictionary(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStructNode   = RwNodeFactory.GetNode <RWUVAnimationDictionaryStructNode>(this, reader);
            _uvAnimations = new List <RwNode>(mStructNode.UvAnimationCount);

            for (int i = 0; i < mStructNode.UvAnimationCount; i++)
            {
                _uvAnimations.Add(RwNodeFactory.GetNode(this, reader));
            }
        }
Exemplo n.º 12
0
        internal RwPlaneSector(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
        {
            var endPosition = reader.BaseStream.Position + header.Size;

            Header = RwNodeFactory.GetNode <RwPlaneSectorHeader>(this, reader);

            while (reader.BaseStream.Position < endPosition)
            {
                RwNodeFactory.GetNode(this, reader);
            }
        }
Exemplo n.º 13
0
        internal RwMaterialListNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStructNode = RwNodeFactory.GetNode <RwMaterialListStructNode>(this, reader);
            mMaterials  = new List <RwMaterial>(mStructNode.MaterialCount);

            for (int i = 0; i < mStructNode.MaterialCount; i++)
            {
                mMaterials.Add(RwNodeFactory.GetNode <RwMaterial>(this, reader));
            }
        }
Exemplo n.º 14
0
        internal RwExtensionNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            Children = new List <RwNode>();

            long end = reader.BaseStream.Position + header.Size;

            while (reader.BaseStream.Position != end)
            {
                RwNodeFactory.GetNode(this, reader);
            }
        }
Exemplo n.º 15
0
        internal RwFrameListStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            int frameCount = reader.ReadInt32();

            FrameList = new List <RwFrame>(frameCount);

            for (int i = 0; i < frameCount; i++)
            {
                FrameList.Add(new RwFrame(reader, FrameList));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Constructor only to be called in <see cref="RwNodeFactory.GetNode(RwNode, BinaryReader)"/>.
        /// </summary>
        internal RwTextureDictionaryNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStructNode = RwNodeFactory.GetNode <RwTextureDictionaryStructNode>(this, reader);
            mTextures   = new List <RwTextureNativeNode>(mStructNode.TextureCount);

            for (int i = 0; i < mStructNode.TextureCount; i++)
            {
                mTextures.Add(RwNodeFactory.GetNode <RwTextureNativeNode>(this, reader));
            }

            mExtensionNode = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);
        }
Exemplo n.º 17
0
        // init with factory node info & binary reader
        internal RwMeshListNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mPrimitiveType = (RwPrimitiveType)reader.ReadUInt32();
            int numSplits = reader.ReadInt32();

            mPrimitiveCount = reader.ReadInt32();

            mMeshes = new RwMesh[numSplits];
            for (int i = 0; i < numSplits; i++)
            {
                mMeshes[i] = new RwMesh(reader);
            }
        }
Exemplo n.º 18
0
        internal RwFrameListNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
            : base(header)
        {
            mStruct         = RwNodeFactory.GetNode <RwFrameListStructNode>(this, reader);
            mExtensionNodes = new List <RwExtensionNode>(Count);

            for (int i = 0; i < Count; i++)
            {
                var extensionNode = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);

                mStruct.FrameList[i].HAnimFrameExtensionNode = extensionNode.FindChild <RwHAnimFrameExtensionNode>(RwNodeId.RwHAnimFrameExtensionNode);

                mExtensionNodes.Add(extensionNode);
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Initializer only to be called in <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RwRasterInfoStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     Width             = reader.ReadInt32();
     Height            = reader.ReadInt32();
     Depth             = reader.ReadInt32();
     Format            = (RwRasterFormats)reader.ReadUInt32();
     Tex0Register      = new Tex0Register(reader);
     Tex1Register      = new Tex1Register(reader);
     MipTBP1Register   = new MipTbpRegister(reader);
     MipTBP2Register   = new MipTbpRegister(reader);
     TexelDataLength   = reader.ReadUInt32();
     PaletteDataLength = reader.ReadUInt32();
     GpuAlignedLength  = reader.ReadUInt32();
     uint skyMipMapValue = reader.ReadUInt32();
 }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
0
 internal RwSkyMipMapValueNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     Value = reader.ReadInt32();
 }
 internal RWUVAnimationDictionaryStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     UvAnimationCount = reader.ReadInt32();
 }
Exemplo n.º 23
0
 internal RwWorldHeader(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
 {
     ReadBody(reader);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializer only to be called in <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RwStringNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     Value = reader.ReadCString((int)Size);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Initializer only to be called in <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RmdNodeLinkListNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     Read(reader);
 }
Exemplo n.º 26
0
 internal RwAtomicSector(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
 {
     Header    = RwNodeFactory.GetNode <RwAtomicSectorHeader>(this, reader);
     Extension = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Initializer only to be called by <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RwRasterStructNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mRasterInfoStructNode = RwNodeFactory.GetNode <RwRasterInfoStructNode>(this, reader);
     mRasterDataStructNode = RwNodeFactory.GetNode <RwRasterDataStructNode>(this, reader);
 }
Exemplo n.º 28
0
        // TODO:
        //
        // 1. Figure out how the bone remap indices work
        // They seem to be tied to the used bone indices somehow
        // Maybe building up an hierarchy as the same indices appear multiple times
        // Indices that aren't in the used bone indices are set to 0xFF
        //
        // 2. Figure out the BoneRLE
        // First byte is the hierarchy index of the affected bone
        // Second byte seems to be something like how many bones it shares weights with on the same material split?
        //
        // 3. Figure out the inverse matrices
        // I can currently just copy and paste the one from the original file
        // But knowing how to calculate it would be a lot easier

        internal RwSkinNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader, RwGeometryNode rwGeometryNode)
            : base(header)
        {
            int numVertices = rwGeometryNode.VertexCount;

            BoneCount               = reader.ReadByte();
            UsedBoneCount           = reader.ReadByte();
            MaxWeightCountPerVertex = reader.ReadByte();
            reader.Seek(1, SeekOrigin.Current);

            UsedBoneIndices = reader.ReadBytes(UsedBoneCount);

            VertexBoneIndices = new byte[numVertices][];
            for (int i = 0; i < numVertices; i++)
            {
                VertexBoneIndices[i] = reader.ReadBytes(4);
            }

            VertexBoneWeights = new float[numVertices][];
            for (int i = 0; i < numVertices; i++)
            {
                VertexBoneWeights[i] = reader.ReadFloatArray(4);
            }

            SkinToBoneMatrices = new Matrix4x4[BoneCount];
            for (int i = 0; i < BoneCount; i++)
            {
                Matrix4x4 mtx = Matrix4x4.Identity;

                mtx.M11 = reader.ReadSingle(); mtx.M12 = reader.ReadSingle(); mtx.M13 = reader.ReadSingle(); reader.BaseStream.Position += 4;
                mtx.M21 = reader.ReadSingle(); mtx.M22 = reader.ReadSingle(); mtx.M23 = reader.ReadSingle(); reader.BaseStream.Position += 4;
                mtx.M31 = reader.ReadSingle(); mtx.M32 = reader.ReadSingle(); mtx.M33 = reader.ReadSingle(); reader.BaseStream.Position += 4;
                mtx.M41 = reader.ReadSingle(); mtx.M42 = reader.ReadSingle(); mtx.M43 = reader.ReadSingle(); reader.BaseStream.Position += 4;

                SkinToBoneMatrices[i] = mtx;
            }

            BoneLimit = reader.ReadInt32();
            MeshCount = reader.ReadInt32();
            RleCount  = reader.ReadInt32();

            if (MeshCount < 1)
            {
                return;
            }

            MeshBoneRemapIndices = reader.ReadBytes(BoneCount);

            MeshBoneRleCount = new SkinSplitMeshRleCount[MeshCount];
            for (int i = 0; i < MeshCount; i++)
            {
                MeshBoneRleCount[i] = new SkinSplitMeshRleCount {
                    StartIndex = reader.ReadByte(), Count = reader.ReadByte()
                }
            }
            ;

            MeshBoneRle = new SkinSplitMeshBoneRle[RleCount];
            for (int i = 0; i < RleCount; i++)
            {
                MeshBoneRle[i] = new SkinSplitMeshBoneRle {
                    BoneIndex = reader.ReadByte(), SkinBoneIndexCount = reader.ReadByte()
                }
            }
            ;

            //PrintInfo();
        }
Exemplo n.º 29
0
 internal RwAnimationNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader) : base(header)
 {
     ReadBody(reader);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Initializer only to be called in <see cref="RwNodeFactory"/>.
 /// </summary>
 internal RwAtomicNode(RwNodeFactory.RwNodeHeader header, BinaryReader reader)
     : base(header)
 {
     mStructNode    = RwNodeFactory.GetNode <RwAtomicStructNode>(this, reader);
     mExtensionNode = RwNodeFactory.GetNode <RwExtensionNode>(this, reader);
 }