예제 #1
0
        /// <summary>
        /// Writes the type and pointer for this material to a file.
        /// </summary>
        /// <param name="writer">The binary writer for this SegaNN file.</param>
        /// <param name="index">The number of this material in a linear list.</param>
        /// <param name="ObjectOffsets">The list of offsets this Object chunk uses.</param>
        public void WritePointer(BinaryWriterEx writer, int index, Dictionary <string, uint> ObjectOffsets)
        {
            // Write this material's type.
            writer.Write((uint)Type);

            // Add an offset to the BinaryWriter so we can fill it in in the NOF0 chunk.
            writer.AddOffset($"Material{index}", 0);

            // Write the value in ObjectOffsets of the main data for this material.
            writer.Write(ObjectOffsets[$"Material{index}"] - writer.Offset);
        }
예제 #2
0
        /// <summary>
        /// Write the Ninja Camera to a file.
        /// </summary>
        /// <param name="writer">The binary writer for this SegaNN file.</param>
        public void Write(BinaryWriterEx writer)
        {
            // Write NXCA header.
            writer.Write("NXCA");
            writer.Write("SIZE"); // Temporary entry, is filled in later once we know this chunk's size.
            long HeaderSizePosition = writer.BaseStream.Position;

            writer.AddOffset("dataOffset");
            writer.FixPadding(0x10);

            // Write camera data.
            uint CameraPosition = (uint)writer.BaseStream.Position;

            writer.Write(UnknownUInt32_1);
            writer.Write(UnknownUInt32_2);
            writer.Write(UnknownVector3_1);
            writer.Write(UnknownVector3_2);
            writer.Write(UnknownFloat_1);
            writer.Write(UnknownFloat_2);
            writer.Write(UnknownFloat_3);
            writer.Write(UnknownFloat_4);

            // Write chunk data.
            writer.FillOffset("dataOffset", true);
            writer.Write((uint)Type);
            writer.AddOffset($"CameraData", 0);
            writer.Write(CameraPosition - 0x20);

            // Alignment.
            writer.FixPadding(0x10);

            // Write chunk size.
            long ChunkEndPosition = writer.BaseStream.Position;
            uint ChunkSize        = (uint)(ChunkEndPosition - HeaderSizePosition);

            writer.BaseStream.Position = HeaderSizePosition - 4;
            writer.Write(ChunkSize);
            writer.BaseStream.Position = ChunkEndPosition;
        }
예제 #3
0
        /// <summary>
        /// Write this material to a file.
        /// </summary>
        /// <param name="writer">The binary writer for this SegaNN file.</param>
        /// <param name="index">The number of this material in a linear list.</param>
        /// <param name="ObjectOffsets">The list of offsets this Object chunk uses.</param>
        /// <param name="MaterialColours">The list of Material Colours this object chunk has.</param>
        /// <param name="MaterialLogics">The list of Material Logic Definitions this object chunk has.</param>
        /// <param name="TextureMaps">The list of Material Texture Map Descriptors this object chunk has.</param>
        public void Write
        (
            BinaryWriterEx writer,
            int index,
            Dictionary <string, uint> ObjectOffsets,
            List <NinjaMaterialColours> MaterialColours,
            List <NinjaMaterialLogic> MaterialLogics,
            List <NinjaTextureMap> TextureMaps
        )
        {
            // Add an entry for this material into the offset list so we know where it is.
            ObjectOffsets.Add($"Material{index}", (uint)writer.BaseStream.Position);

            // Write this material's flag and user defined data.
            writer.Write((uint)Flag);
            writer.Write(UserDefined);

            // Add an offset to fill in later with the NOF0 chunk.
            writer.AddOffset($"Material{index}ColourOffset", 0);

            // Loop through the material colours, if we find one with an offset matching ours, then write its position value.
            for (int i = 0; i < MaterialColours.Count; i++)
            {
                if (MaterialColourOffset == MaterialColours[i].Offset)
                {
                    writer.Write(ObjectOffsets[$"ColourOffset{i}"] - writer.Offset);
                }
            }

            // Add an offset to fill in later with the NOF0 chunk.
            writer.AddOffset($"Material{index}LogicOffset", 0);

            // Loop through the material logic definitions, if we find one with an offset matching ours, then write its position value.
            for (int i = 0; i < MaterialLogics.Count; i++)
            {
                if (MaterialLogicOffset == MaterialLogics[i].Offset)
                {
                    writer.Write(ObjectOffsets[$"LogicOffset{i}"] - writer.Offset);
                }
            }

            // Make sure we actually have textures, if not, write a 0 instead of an offset.
            if (MaterialTexMapDescriptionOffset != 0)
            {
                // Add an offset to fill in later with the NOF0 chunk.
                writer.AddOffset($"Material{index}TexDescOffset", 0);

                // Loop through the texture map Descriptors, if we find one with an offset matching ours, then write its position value.
                for (int i = 0; i < TextureMaps.Count; i++)
                {
                    if (MaterialTexMapDescriptionOffset == TextureMaps[i].Offset)
                    {
                        writer.Write(ObjectOffsets[$"TexDescOffset{i}"] - writer.Offset);
                    }
                }
            }
            else
            {
                writer.Write(0);
            }

            // Write the reserved data.
            writer.Write(Reserved0);
            writer.Write(Reserved1);
            writer.Write(Reserved2);
        }