Exemplo n.º 1
0
        public static void AddBrushesToMAP(MainForm _MainForm,
                                           MainForm.EConvOption econvOption,
                                           List <XVector> _Vertices,
                                           List <XFace> _Faces,
                                           List <XBrush> _Brushes,
                                           string format,
                                           ref string _MAPText,
                                           string _VisibleTextureName,
                                           string _HiddenTextureName,
                                           double _Scalar
                                           )
        {
            _MainForm.UpdateProgress("Adding Brushes to MAP...");
            int BrushCount = 0;

            switch (econvOption)
            {
            case MainForm.EConvOption.Extrusion:
                using (List <XBrush> .Enumerator enumerator = _Brushes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        _MainForm.UpdateProgress(string.Format("Adding Brush {0:n0} to MAP...", BrushCount++));
                        foreach (XFace xface in enumerator.Current.Faces)
                        {
                            XVector        _B    = XVector.Multiply(xface.Normal, _Scalar);
                            List <XVector> list3 = new List <XVector>();
                            List <XVector> list4 = new List <XVector>();
                            foreach (int index in xface.VertIdx)
                            {
                                XVector _A = new XVector(_Vertices[index]);
                                list3.Add(_A);
                                list4.Add(XVector.Add(_A, _B));
                            }
                            _MAPText += "{\n";
                            XVector xvector1 = list3[0];
                            XVector xvector2 = list3[1];
                            XVector xvector3 = list3[2];
                            _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector1.x.ToString(format, new CultureInfo("en-US")), (object)xvector1.y.ToString(format, new CultureInfo("en-US")), (object)xvector1.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector3.x.ToString(format, new CultureInfo("en-US")), (object)xvector3.y.ToString(format, new CultureInfo("en-US")), (object)xvector3.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector2.x.ToString(format, new CultureInfo("en-US")), (object)xvector2.y.ToString(format, new CultureInfo("en-US")), (object)xvector2.z.ToString(format, new CultureInfo("en-US")), (object)_VisibleTextureName);
                            XVector xvector4 = list4[2];
                            XVector xvector5 = list4[1];
                            XVector xvector6 = list4[0];
                            _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector4.x.ToString(format, new CultureInfo("en-US")), (object)xvector4.y.ToString(format, new CultureInfo("en-US")), (object)xvector4.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector6.x.ToString(format, new CultureInfo("en-US")), (object)xvector6.y.ToString(format, new CultureInfo("en-US")), (object)xvector6.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector5.x.ToString(format, new CultureInfo("en-US")), (object)xvector5.y.ToString(format, new CultureInfo("en-US")), (object)xvector5.z.ToString(format, new CultureInfo("en-US")), (object)_HiddenTextureName);
                            for (int index = 0; index < list3.Count; ++index)
                            {
                                XVector xvector7 = list3[index];
                                XVector xvector8 = list3[(index + 1) % list3.Count];
                                XVector xvector9 = list4[index];
                                _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector7.x.ToString(format, new CultureInfo("en-US")), (object)xvector7.y.ToString(format, new CultureInfo("en-US")), (object)xvector7.z.ToString(format, new CultureInfo("en-US")));
                                _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector8.x.ToString(format, new CultureInfo("en-US")), (object)xvector8.y.ToString(format, new CultureInfo("en-US")), (object)xvector8.z.ToString(format, new CultureInfo("en-US")));
                                _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector9.x.ToString(format, new CultureInfo("en-US")), (object)xvector9.y.ToString(format, new CultureInfo("en-US")), (object)xvector9.z.ToString(format, new CultureInfo("en-US")), (object)_HiddenTextureName);
                            }
                            _MAPText += "}\n";
                        }
                    }
                    break;
                }

            case MainForm.EConvOption.Spikes:
                using (List <XBrush> .Enumerator enumerator = _Brushes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        _MainForm.UpdateProgress(string.Format("Adding Brush {0:n0} to MAP...", BrushCount++));
                        foreach (XFace xface in enumerator.Current.Faces)
                        {
                            XVector        _B1   = XVector.Multiply(xface.Normal, _Scalar);
                            List <XVector> list3 = new List <XVector>();
                            foreach (int index in xface.VertIdx)
                            {
                                XVector xvector = new XVector(_Vertices[index]);
                                list3.Add(xvector);
                            }
                            _MAPText += "{\n";
                            XVector xvector1 = list3[0];
                            XVector xvector2 = list3[1];
                            XVector xvector3 = list3[2];
                            _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector1.x.ToString(format, new CultureInfo("en-US")), (object)xvector1.y.ToString(format, new CultureInfo("en-US")), (object)xvector1.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector3.x.ToString(format, new CultureInfo("en-US")), (object)xvector3.y.ToString(format, new CultureInfo("en-US")), (object)xvector3.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector2.x.ToString(format, new CultureInfo("en-US")), (object)xvector2.y.ToString(format, new CultureInfo("en-US")), (object)xvector2.z.ToString(format, new CultureInfo("en-US")), (object)_VisibleTextureName);
                            XVector xvector4 = new XVector();
                            foreach (int index in xface.VertIdx)
                            {
                                XVector _B2 = new XVector(_Vertices[index]);
                                xvector4 = XVector.Add(xvector4, _B2);
                            }
                            XVector xvector5 = XVector.Add(XVector.Divide(xvector4, (double)xface.VertIdx.Count), _B1);
                            for (int index = 0; index < list3.Count; ++index)
                            {
                                XVector xvector6 = list3[index];
                                XVector xvector7 = list3[(index + 1) % list3.Count];
                                _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector5.x.ToString(format, new CultureInfo("en-US")), (object)xvector5.y.ToString(format, new CultureInfo("en-US")), (object)xvector5.z.ToString(format, new CultureInfo("en-US")));
                                _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector6.x.ToString(format, new CultureInfo("en-US")), (object)xvector6.y.ToString(format, new CultureInfo("en-US")), (object)xvector6.z.ToString(format, new CultureInfo("en-US")));
                                _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector7.x.ToString(format, new CultureInfo("en-US")), (object)xvector7.y.ToString(format, new CultureInfo("en-US")), (object)xvector7.z.ToString(format, new CultureInfo("en-US")), (object)_HiddenTextureName);
                            }
                            _MAPText += "}\n";
                        }
                    }
                    break;
                }

            default:
                using (List <XBrush> .Enumerator enumerator = _Brushes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        XBrush current = enumerator.Current;
                        _MAPText += "{\n";
                        _MainForm.UpdateProgress(string.Format("Adding Brush {0:n0} to MAP...", BrushCount++));
                        foreach (XFace xface in current.Faces)
                        {
                            XVector xvector1 = _Vertices[xface.VertIdx[0]];
                            XVector xvector2 = _Vertices[xface.VertIdx[2]];
                            XVector xvector3 = _Vertices[xface.VertIdx[1]];
                            _MAPText += string.Format("\t( {0} {1} {2} ) ", (object)xvector1.x.ToString(format, new CultureInfo("en-US")), (object)xvector1.y.ToString(format, new CultureInfo("en-US")), (object)xvector1.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) ", (object)xvector2.x.ToString(format, new CultureInfo("en-US")), (object)xvector2.y.ToString(format, new CultureInfo("en-US")), (object)xvector2.z.ToString(format, new CultureInfo("en-US")));
                            _MAPText += string.Format("( {0} {1} {2} ) {3} 0 0 0 1 1\n", (object)xvector3.x.ToString(format, new CultureInfo("en-US")), (object)xvector3.y.ToString(format, new CultureInfo("en-US")), (object)xvector3.z.ToString(format, new CultureInfo("en-US")), (object)_VisibleTextureName);
                        }
                        _MAPText += "}\n";
                    }
                    break;
                }
            }
        }