SerahToolkit_SharpGL.BattleStage.Process C# (CSharp) Method

Process() public method

public Process ( bool generateTexture = false, bool bUpdating = false ) : void
generateTexture bool
bUpdating bool
return void
        public void Process(bool generateTexture = false, bool bUpdating = false)
        {
            Console.WriteLine("BS: Searching for objects...");
            SearchObjects();
            Console.WriteLine("BS: Reading texture metadata:");
            ResolveTex();
            if (!bUpdating)
            {
                Console.WriteLine($"BS: Setting up MTL");
                SetupMtl();
                _st = new StageTexture(_tim, _width, _height);
                byte[] textureByte = new byte[_stage.Length - _textureDataInt];
                byte[] clutByte = new byte[_stage.Length - (_textureDataInt - _tim)];
                Buffer.BlockCopy(_stage, _textureDataInt, textureByte, 0, textureByte.Length);
                Buffer.BlockCopy(_stage, _tim, clutByte, 0, _textureDataInt - _tim);
                Console.WriteLine($"BS: TextureWorker initialized");
                string pathOfd;
                if (generateTexture)
                {
                    for (int i = _cluTsize - 1; i > 0; i--)
                    {
                        Console.WriteLine($"BS: TextureWorker generating palette and texture");
                        _st.CreatePalettedTex(i, clutByte);
                        _st.CopyTextureBuffer(textureByte);
                        _bmp = _st.GetBmp();
                        pathOfd = Path.GetDirectoryName(_pathh);
                        _bmp.Save(pathOfd + @"\" + Path.GetFileNameWithoutExtension(_pathh) + @"_" + i + ".png", ImageFormat.Png);
                    }
                }
                Console.WriteLine($"BS: TextureWorker generating palette and texture");
                _st.CreatePalettedTex(0, clutByte);
                _st.CopyTextureBuffer(textureByte);
                _bmp = _st.GetBmp();
                pathOfd = Path.GetDirectoryName(_pathh);
                Console.WriteLine($"BS: TextureWorker saving texture");
                _bmp.Save(pathOfd + @"\" + Path.GetFileNameWithoutExtension(_pathh) + ".png", ImageFormat.Png);
                foreach (int off in _itemOffsets)
                {
                    _verts = BitConverter.ToUInt16(_stage, off + 4);
                    _absolutePolygon = off + 6 + (_verts * 6);
                    _triangles = BitConverter.ToUInt16(_stage, _absolutePolygon + 4 + (_absolutePolygon % 4));
                    _quads = BitConverter.ToUInt16(_stage, _absolutePolygon + 6 + (_absolutePolygon % 4));
                    Console.WriteLine($"BS: Offset: {off}, \n\tVertices: {_verts}\n\tTriangles: {_triangles}\n\tQuads: {_quads}");
                    if (_triangles != 0 && _quads != 0)  
                    {
                        Process_Step(true, off);
                        Process_Step(false, off);
                    }
                    else
                        if (_triangles != 0)
                        Process_Step(true, off);
                    else
                            if (_quads != 0)
                        Process_Step(false, off);
                }
            }
            else
            {
                foreach (int off in _itemOffsets)
                {
                    Console.WriteLine($"BS: Updating for BS_Verts editor");
                    _verts = BitConverter.ToUInt16(_stage, off + 4);
                    _absolutePolygon = off + 6 + (_verts * 6);
                    _triangles = BitConverter.ToUInt16(_stage, _absolutePolygon + 4 + (_absolutePolygon % 4));
                    _quads = BitConverter.ToUInt16(_stage, _absolutePolygon + 6 + (_absolutePolygon % 4));

                    if (_triangles != 0 && _quads != 0) 
                    {
                        Process_Step(true, off);
                        Process_Step(false, off);
                    }
                    else
                        if (_triangles != 0)
                        Process_Step(true, off);
                    else
                            if (_quads != 0)
                        Process_Step(false, off);
                }
            }
        }

Usage Example

 public void BSVertEditor_Update(string ofd)
 {
     BattleStage bs = new BattleStage(ofd);
     listBox1.Items.Clear();
     bs.Process(false, true);
     BS_UpdateObjects(bs.GetArrayOfObjects(), ofd);
     Render3D();
 }
All Usage Examples Of SerahToolkit_SharpGL.BattleStage::Process