Example #1
0
 /// <summary>
 /// Initialize a new instance of <see cref="RWRaster"/> using a width, height, palette, pixel indices and pixel format.
 /// </summary>
 /// <param name="width">Width of the texture.</param>
 /// <param name="height">Height of the texture.</param>
 /// <param name="palette">Palette colors of the texture.</param>
 /// <param name="indices">Per-pixel palette color indices of the texture.</param>
 /// <param name="pixelFormat">PS2 pixel format of the given data.</param>
 /// <param name="parent">Parent of this <see cref="RWRaster"/> node. Value is null if not specified.</param>
 public RWRaster(int width, int height, Color[] palette, byte[] indices, 
     PS2.Graphics.PS2PixelFormat pixelFormat, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     Info = new RWRasterInfo(width, height, pixelFormat);
     Data = new RWRasterData(palette, indices, pixelFormat);
 }
 public RWTextureReferenceStruct(RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     FilterMode = PS2FilterMode.Linear;
     HorizontalAdressingMode = PS2AddressingMode.Wrap;
     VerticalAdressingMode = PS2AddressingMode.Wrap;
     HasMipMaps = false;
 }
Example #3
0
 /// <summary>
 /// Initializes a RenderWare material instance with default properties.
 /// </summary>
 public RWMaterial(RWNode parent = null)
     : base(RWNodeType.Material, parent)
 {
     _struct = new RWMaterialStruct(this);
     _struct.IsTextured = false;
     _textureReference = null;
     _extension = new RWExtension(this);
 }
 // Constructors
 public RWTextureNativeStruct(RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     _platformID = RWPlatformID.PS2;
     FilterMode = PS2FilterMode.Linear;
     HorizontalAddressingMode = PS2AddressingMode.Wrap;
     VerticalAddressingMode = PS2AddressingMode.Wrap;
 }
Example #5
0
 public RWDrawCallStruct(int frameIndex, int geometryIndex, int flag1, int flag2, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     _frameIndex = frameIndex;
     _geometryIndex = geometryIndex;
     _flag1 = flag1;
     _flag2 = flag2;
 }
Example #6
0
 /// <summary>
 /// Initialize RenderWare material data with default properties.
 /// </summary>
 public RWMaterialStruct(RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     Color = Color.White;
     IsTextured = true;
     Ambient = 1.0f;
     Specular = 1.0f;
     Diffuse = 1.0f;
 }
Example #7
0
        /// <summary>
        /// Initialize a new <see cref="RMDAnimationSet"/> instance using a <see cref="List{T}"/> of RenderWare nodes.
        /// </summary>
        /// <param name="animationNodes"><see cref="List{T}"/> of <see cref="RWNode"/> to initialize the animation node set with.</param>
        /// <param name="parent">The parent of the new <see cref="RMDAnimationSet"/>. Value is null if not specified.</param>
        public RMDAnimationSet(List<RWNode> animationNodes, RWNode parent = null)
            : base(RWNodeType.RMDAnimationSet, parent)
        {
            _animationNodes = animationNodes;

            for (int i = 0; i < _animationNodes.Count; i++)
            {
                _animationNodes[i].Parent = this;
            }
        }
 public RWTextureNativeStruct(
     RWPlatformID rwPlatformID, PS2FilterMode filterMode, 
     PS2AddressingMode horizontalAddrMode, PS2AddressingMode verticalAddrMode,
     RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     _platformID = rwPlatformID;
     FilterMode = filterMode;
     HorizontalAddressingMode = horizontalAddrMode;
     VerticalAddressingMode = verticalAddrMode;
 }
 public RWTextureReferenceStruct(
     PS2FilterMode filterMode, 
     PS2AddressingMode horizontalAddrMode, PS2AddressingMode verticalAddrMode, 
     bool hasMipMaps,
     RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     FilterMode = filterMode;
     HorizontalAdressingMode = horizontalAddrMode;
     VerticalAdressingMode = verticalAddrMode;
     HasMipMaps = hasMipMaps;
 }
Example #10
0
 public RWExtension(RWNode parent = null)
     : base(RWNodeType.Extension, parent)
 {
     Children = new List<RWNode>();
 }
        /// <summary>
        /// Initialize a new <see cref="RWMeshMaterialSplitData"/> using a <see cref="RWMesh"/> and the primitive type for the split data.
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="primType"></param>
        public RWMeshMaterialSplitData(RWMesh mesh, RWPrimitiveType primType = RWPrimitiveType.TriangleStrip, RWNode parent = null)
            : base(RWNodeType.MeshMaterialSplitList, parent)
        {
            // set type and prim count
            _primType = primType;
            _numPrimitives = mesh.TriangleCount;

            // pass 1: order the triangles by ascending material id
            var sortedTriangles = mesh.Triangles.OrderBy(tri => tri.MatID).ToArray();

            // pass 2: split the indices
            List<ushort>[] matSplitsIndices = new List<ushort>[mesh.MaterialCount];
            List<ushort> curMatSplitIndices = null;
            int curMatIdx = -1;
            for (int i = 0; i < sortedTriangles.Length; i++)
            {
                var tri = sortedTriangles[i];

                if (tri.MatID > curMatIdx)
                {
                    if (curMatIdx != -1)
                        matSplitsIndices[curMatIdx] = curMatSplitIndices;

                    curMatIdx = tri.MatID;
                    curMatSplitIndices = new List<ushort>();
                }

                curMatSplitIndices.Add(tri.A);
                curMatSplitIndices.Add(tri.B);
                curMatSplitIndices.Add(tri.C);
            }

            matSplitsIndices[curMatIdx] = curMatSplitIndices;

            // pass 3: create the split data
            _splits = new RWMeshMaterialSplit[mesh.MaterialCount];
            for (int i = 0; i < _splits.Length; i++)
            {
                ushort[] matSplitIndices = matSplitsIndices[i].ToArray();

                if (primType == RWPrimitiveType.TriangleStrip)
                {
                    
                    ManagedNvTriStrip.PrimitiveGroup[] primitives = null;

                    if (ManagedNvTriStrip.NvTriStripUtility.Stripify(matSplitIndices, ref primitives))
                    {
                        matSplitIndices = primitives[0].Indices;
                    }
                    else
                    {
                        throw new System.Exception("Failed to generate strips.");
                    }
                    
                    /*
                    NvTriStripDotNet.PrimitiveGroup[] primitives;
                    var tristripper = new NvTriStripDotNet.NvTriStrip();
                    if (tristripper.GenerateStrips(matSplitIndices, out primitives))
                    {
                        matSplitIndices = primitives[0].indices.Cast<ushort>().ToArray();
                    }
                    */
                }

                _splits[i] = new RWMeshMaterialSplit(i, matSplitIndices);
            }
        }
Example #12
0
 /// <summary>
 /// Initialize a RenderWare string node with a string value.
 /// </summary>
 /// <param name="value">String value to initialize the string node with.</param>
 /// <param name="parent">Parent of the string node. Value is null if not specified.</param>
 public RWString(string value, RWNode parent = null)
     : base(RWNodeType.String, parent)
 {
     Value = value;
 }
Example #13
0
 /// <summary>
 /// Initialize a new instance of <see cref="RWRaster"/> using a bitmap to encode using the given pixel format.
 /// </summary>
 /// <param name="bitmap">Bitmap to encode to the specified pixel format.</param>
 /// <param name="pixelFormat">Pixel format to encode the bitmap to.</param>
 /// <param name="parent">Parent of this <see cref="RWRaster"/> node. Value is null if not specified.</param>
 public RWRaster(Bitmap bitmap, PS2.Graphics.PS2PixelFormat pixelFormat, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     Info = new RWRasterInfo(bitmap.Width, bitmap.Height, pixelFormat);
     Data = new RWRasterData(bitmap, pixelFormat);
 }
Example #14
0
 /// <summary>
 /// Initializes a RenderWare material instance with default properties and reference texture name set.
 /// </summary>
 /// <param name="textureName">Name of the texture to be referenced by the material.</param>
 public RWMaterial(string textureName, RWNode parent = null)
     : this(parent)
 {
     _struct.IsTextured = true;
     _textureReference = new RWTextureReference(textureName, this);
 }
Example #15
0
 /// <summary>
 /// Initialize a RenderWare node using the given RenderWare node type and parent node.
 /// </summary>
 protected RWNode(RWNodeType type, RWNode parent)
 {
     _type = type;
     _size = 0;
     _rawVersion = ExportVersion;
     Parent = parent;
 }
Example #16
0
 /// <summary>
 /// Initialize a RenderWare node using the given RenderWare node type.
 /// </summary>
 protected RWNode(RWNodeType type)
 {
     _type = type;
     _size = 0;
     _rawVersion = ExportVersion;
     _parent = null;
 }
 /// <summary>
 /// Initialize a RenderWare UV animation dictionary using a list of uv animations.
 /// </summary>
 /// <param name="uvAnimations">The list of uv animations to initialize the uv animation dictionary with.</param>
 /// <param name="parent">The parent of the uv animation dictionary node. Value is null if not specified.</param>
 public RWUVAnimationDictionary(IList<RWNode> uvAnimations, RWNode parent = null)
     : base(RWNodeType.UVAnimationDictionary, parent)
 {
     _uvAnimations = uvAnimations.ToList();
 }
 public RWUVAnimationDictionaryStruct(int uvAnimationCount, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     _numUVAnims = uvAnimationCount;
 }
 /// <summary>
 /// Initialize an empty RenderWare UV animation dictionary.
 /// </summary>
 /// <param name="parent">The parent of the uv animation dictionary node. Value is null if not specified.</param>
 public RWUVAnimationDictionary(RWNode parent = null)
     : base(RWNodeType.UVAnimationDictionary, parent)
 {
     _uvAnimations = new List<RWNode>();
 }
Example #20
0
 /// <summary>
 /// Initialize a texture reference instance with a referenced texture name.
 /// </summary>
 /// <param name="refTextureName">Name of the referenced texture.</param>
 /// <param name="parent">Parent of the texture reference node. Value is null if not specified.</param>
 public RWTextureReference(string refTextureName, RWNode parent = null)
     : base(RWNodeType.TextureReference, parent)
 {
     // Create a struct with default values
     _struct = new RWTextureReferenceStruct(this);
     _refTexName = new RWString(refTextureName, this);
     _refTexMaskName = new RWString(string.Empty, this);
     _extension = new RWExtension(new RWSkyMipMapValue());
     _extension.Parent = this;
 }
Example #21
0
 public RWMeshList(IList<RWMesh> geoList, RWNode parent = null)
     : base(RWNodeType.GeometryList, parent)
 {
     Meshes = geoList.ToList();
     _struct = new RWGeometryListStruct(this);
 }