/// <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; }
/****************************************************************************************/ /* TODO: add the skin plugin and mesh strip plugin here instead of the extension itself */ /****************************************************************************************/ #endregion /// <summary> /// Initializer only to be called <see cref="RWNodeFactory"/> /// </summary> internal RWMesh(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWMeshStruct>(this, reader); _materialList = RWNodeFactory.GetNode<RWMaterialList>(this, reader); _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Initializer only to be called in <see cref="RWNodeFactory.GetNode(RWNode, BinaryReader)"/> /// </summary> internal RWTextureReference(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWTextureReferenceStruct>(this, reader); _refTexName = RWNodeFactory.GetNode<RWString>(this, reader); _refTexMaskName = RWNodeFactory.GetNode<RWString>(this, reader); _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Constructor only to be called in <see cref="RWNodeFactory.GetNode(RWNode, BinaryReader)"/>. /// </summary> internal RWTextureDictionary(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWTextureDictionaryStruct>(this, reader); _textures = new List<RWTextureNative>(_struct.TextureCount); for (int i = 0; i < _struct.TextureCount; i++) { _textures.Add(RWNodeFactory.GetNode<RWTextureNative>(this, reader)); } _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Initialize a new <see cref="RWTextureDictionary"/> instance with an <see cref="IList{T}"/> of texture nodes. /// </summary> /// <param name="textures"><see cref="IList{T}"/>containing texture nodes to initialize the dictionary with.</param> public RWTextureDictionary(IList<RWTextureNative> textures) : base(RWNodeType.TextureDictionary) { Textures = textures.ToList(); _extension = new RWExtension(this); _struct = new RWTextureDictionaryStruct(this); }
/// <summary> /// Constructor only to be called in <see cref="RWNodeFactory"/>. /// </summary> internal RWTextureNative(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWTextureNativeStruct>(this, reader); _name = RWNodeFactory.GetNode<RWString>(this, reader); _maskName = RWNodeFactory.GetNode<RWString>(this, reader); _raster = RWNodeFactory.GetNode<RWRaster>(this, reader); _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Initialize a new empty <see cref="RWTextureDictionary"/> instance. /// </summary> public RWTextureDictionary() : base(RWNodeType.TextureDictionary) { _struct = new RWTextureDictionaryStruct(this); _textures = new List<RWTextureNative>(); _extension = new RWExtension(this); }
/// <summary> /// Initializes an <see cref="RWTextureNative"/> 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 RWTextureNative(string name, Bitmap bitmap, PS2PixelFormat pixelFormat) : base(RWNodeType.TextureNative) { 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); } _struct = new RWTextureNativeStruct(this); _name = new RWString(name, this); _maskName = new RWString(string.Empty, this); _raster = new RWRaster(bitmap, pixelFormat, this); _extension = new RWExtension(new RWSkyMipMapValue()); _extension.Parent = this; }
/// <summary> /// Initializes an <see cref="RWTextureNative"/> 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 RWTextureNative(string name, int width, int height, Color[] palette, byte[] indices, PS2PixelFormat pixelFormat) : base(RWNodeType.TextureNative) { 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); } _struct = new RWTextureNativeStruct(this); _name = new RWString(name, this); _maskName = new RWString(string.Empty, this); _raster = new RWRaster(width, height, palette, indices, pixelFormat, this); _extension = new RWExtension(new RWSkyMipMapValue()); _extension.Parent = this; }
/// <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); }
/// <summary> /// Initializes a RenderWare material using data from the <see cref="RWNodeFactory"/>. /// </summary> /// <param name="header"></param> /// <param name="reader"></param> internal RWMaterial(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWMaterialStruct>(this, reader); if (_struct.IsTextured) _textureReference = RWNodeFactory.GetNode<RWTextureReference>(this, reader); _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Initializer only to be called in <see cref="RWNodeFactory"/>. /// </summary> internal RWDrawCall(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _struct = RWNodeFactory.GetNode<RWDrawCallStruct>(this, reader); _extension = RWNodeFactory.GetNode<RWExtension>(this, reader); }
/// <summary> /// Initialize a new empty <see cref="RWDrawCall"/> instance. /// </summary> public RWDrawCall() : base(RWNodeType.DrawCall) { _struct = new RWDrawCallStruct(0, 0, 0, 0, this); _extension = new RWExtension(this); }
/// <summary> /// Constructor only to be called in <see cref="RWNodeFactory"/>. /// </summary> internal RWScene(RWNodeFactory.RWNodeInfo header, BinaryReader reader) : base(header) { _structNode = RWNodeFactory.GetNode<RWSceneStruct>(this, reader); _frameListNode = RWNodeFactory.GetNode<RWSceneNodeList>(this, reader); _meshListNode = RWNodeFactory.GetNode<RWMeshList>(this, reader); _drawCalls = new List<RWDrawCall>(_structNode.DrawCallCount); for (int i = 0; i < _structNode.DrawCallCount; i++) { _drawCalls.Add(RWNodeFactory.GetNode<RWDrawCall>(this, reader)); } if (DrawCallCount > 0) { _extensionNode = RWNodeFactory.GetNode<RWExtension>(this, reader); } }