Exemplo n.º 1
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.º 2
0
        /// <summary>
        /// Initializes an <see cref="RwTextureNativeNode"/> instance using a bitmap, name and a PS2 pixel format to encode to.
        /// </summary>
        /// <param name="name">Name of the texture used for material references.</param>
        /// <param name="bitmap">Source bitmap used to encode.</param>
        /// <param name="pixelFormat">PS2 Pixel format to encode the bitmap to.</param>
        public RwTextureNativeNode(string name, Bitmap bitmap, PS2PixelFormat pixelFormat)
            : base(RwNodeId.RwTextureNativeNode)
        {
            if (bitmap.Width % 2 != 0 || bitmap.Height % 2 != 0)
            {
                throw new ArgumentException(EXCEPTION_NOT_POW2);
            }

            if (bitmap.Width > 1024 || bitmap.Width > 1024)
            {
                throw new ArgumentException(EXCEPTION_DIMENSION_TOO_BIG);
            }

            mStructNode       = new RwTextureNativeStructNode(this);
            mName             = new RwStringNode(name, this);
            mMaskName         = new RwStringNode(string.Empty, this);
            mRasterStructNode = new RwRasterStructNode(bitmap, pixelFormat, this);
            mExtensionNode    = new RwExtensionNode(this, new RwSkyMipMapValueNode());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes an <see cref="RwTextureNativeNode"/> instance using a name, width, height, palette, indices and a PS2 pixel format to encode to.
        /// </summary>
        /// <param name="name">Name of the texture used for material references.</param>
        /// <param name="width">Width of the texture.</param>
        /// <param name="height">Height of the texture.</param>
        /// <param name="palette">Texture palette data.</param>
        /// <param name="indices">Texture pixel indices into the palette.</param>
        /// <param name="pixelFormat">PS2 Pixel format to encode the bitmap to.</param>
        public RwTextureNativeNode(string name, int width, int height, Color[] palette, byte[] indices, PS2PixelFormat pixelFormat)
            : base(RwNodeId.RwTextureNativeNode)
        {
            if (width % 2 != 0 || height % 2 != 0)
            {
                throw new ArgumentException(EXCEPTION_NOT_POW2);
            }

            if (width > 1024 || width > 1024)
            {
                throw new ArgumentException(EXCEPTION_DIMENSION_TOO_BIG);
            }

            mStructNode       = new RwTextureNativeStructNode(this);
            mName             = new RwStringNode(name, this);
            mMaskName         = new RwStringNode(string.Empty, this);
            mRasterStructNode = new RwRasterStructNode(width, height, palette, indices, pixelFormat, this);
            mExtensionNode    = new RwExtensionNode(this, new RwSkyMipMapValueNode());
        }
Exemplo n.º 4
0
        public RwTextureNativeNode(Stream stream, bool leaveOpen = false)
            : base(RwNodeId.RwTextureNativeNode)
        {
            var node = (RwTextureNativeNode)Load(stream, leaveOpen);

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

            mName        = node.mName;
            mName.Parent = this;

            mMaskName        = node.mMaskName;
            mMaskName.Parent = this;

            mRasterStructNode        = node.mRasterStructNode;
            mRasterStructNode.Parent = this;

            mExtensionNode        = node.mExtensionNode;
            mExtensionNode.Parent = this;
        }
Exemplo n.º 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);
        }