Esempio n. 1
0
        //public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        //{
        //    int[] index = null;
        //    base.Draw(out mp, out fmodel, out smodel);
        //    try
        //    {
        //        IDrawGroup group;
        //        if ((base._vtx.Length == 4) && (base._sections.Length == 4))
        //        {
        //            index = new int[] { 0, 1, 2, 3 };
        //            if (!PipeSection.SetConnectIndex(base._sections, base._vtx, out index))
        //            {
        //                return false;
        //            }
        //            if (!DrawGeometry.Compare(base._vtx[index[0]][0], base._vtx[index[1]][0], false))
        //            {
        //                return false;
        //            }
        //            object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
        //            int[] numArray2 = new int[3];
        //            numArray2[1] = 1;
        //            numArray2[2] = 2;
        //            if (base.NewEmptyModel(numArray2, base._renderType, renderInfo, out fmodel))
        //            {
        //                int[] numArray3 = new int[1];
        //                if (base.NewEmptyModel(numArray3, base._renderType, renderInfo, out smodel))
        //                {
        //                    goto Label_00DF;
        //                }
        //            }
        //        }
        //        return false;
        //    Label_00DF:
        //        group = null;
        //        group = fmodel.GetGroup(0);
        //        IDrawPrimitive primitive = group.GetPrimitive(0);
        //        group.GetPrimitive(1);
        //        group.GetPrimitive(2);
        //        IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
        //        base.DrawConBetween(new Vector[][] { base._vtx[index[0]], base._vtx[index[1]] }, new IPipeSection[] { base._sections[index[0]], base._sections[index[1]] }, ref fmodel);
        //        base.DrawConSingle(base._vtx[index[2]], base._sections[index[2]], ref fmodel);
        //        base.DrawConSingle(base._vtx[index[3]], base._sections[index[3]], ref fmodel);
        //        primitive2.Material.CullMode = gviCullFaceMode.gviCullNone;
        //        primitive2.VertexArray = primitive.VertexArray;
        //        primitive2.NormalArray = primitive.NormalArray;
        //        primitive2.TexcoordArray = primitive.TexcoordArray;
        //        primitive2.IndexArray = primitive.IndexArray;
        //        return true;
        //    }
        //    catch (Exception exception)
        //    {
        //        SystemLog.Instance.Log(exception.StackTrace);
        //        return false;
        //    }
        //}
        #endregion

        #region 单壁绘制--冯欣修改20131101
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            int[] index = null;
            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                IDrawGroup group;
                if ((base._vtx.Length == 4) && (base._sections.Length == 4))
                {
                    index = new int[] { 0, 1, 2, 3 };
                    if (!PipeSection.SetConnectIndex(base._sections, base._vtx, out index))
                    {
                        return(false);
                    }
                    if (!DrawGeometry.Compare(base._vtx[index[0]][0], base._vtx[index[1]][0], false))
                    {
                        return(false);
                    }
                    object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                    int[]  numArray2  = new int[1];
                    if (base.NewEmptyModel(numArray2, base._renderType, renderInfo, out fmodel))
                    {
                        int[] numArray3 = new int[1];
                        if (base.NewEmptyModel(numArray3, base._renderType, renderInfo, out smodel))
                        {
                            goto Label_00DF;
                        }
                    }
                }
                return(false);

Label_00DF:
                group = null;
                group = fmodel.GetGroup(0);
                IDrawPrimitive primitive  = group.GetPrimitive(0);
                IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
                base.DrawConBetween(new Vector[][] { base._vtx[index[0]], base._vtx[index[1]] }, new IPipeSection[] { base._sections[index[0]], base._sections[index[1]] }, ref fmodel);
                base.DrawConSingle(base._vtx[index[2]], base._sections[index[2]], ref fmodel);
                base.DrawConSingle(base._vtx[index[3]], base._sections[index[3]], ref fmodel);
                primitive2.Material.CullMode = gviCullFaceMode.gviCullNone;
                primitive2.VertexArray       = primitive.VertexArray;
                primitive2.NormalArray       = primitive.NormalArray;
                primitive2.TexcoordArray     = primitive.TexcoordArray;
                primitive2.IndexArray        = primitive.IndexArray;
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 2
0
        //public static GvitechModel MergeModels(GvitechModel[] arrModel, GvitechVector3[] arrOff)
        //{
        //    if (((arrModel == null) || (arrOff == null)) || (arrModel.Length != arrOff.Length))
        //    {
        //        return null;
        //    }
        //    int length = arrModel.Length;
        //    IModel[] modelArray = new IModel[length];
        //    IVector3[] vectorArray = new IVector3[length];
        //    for (int i = 0; i < length; i++)
        //    {
        //        modelArray[i] = ((arrModel[i] == null) || arrModel[i].IsNull) ? null : arrModel[i].Model;
        //        vectorArray[i] = ((arrOff[i] == null) || arrOff[i].IsNull) ? null : arrOff[i].Vector3;
        //    }
        //    return new GvitechModel(MergeModels(modelArray, vectorArray));
        //}
        public static IModel MergeModels(IModel[] arrModel, IVector3[] arrOff)
        {
            IModel model = null;

            try
            {
                IModel         model2    = null;
                IDrawGroup     drawGroup = null;
                IDrawPrimitive primitive = null;
                IVector3       vector    = null;
                model = resFactory.CreateModel();
                for (int i = 0; i < arrModel.Length; i++)
                {
                    if (((model2 = arrModel[i]) != null) && (model2.GroupCount != 0))
                    {
                        for (int j = 0; j < model2.GroupCount; j++)
                        {
                            drawGroup = model2.GetGroup(j);
                            if ((drawGroup != null) && (drawGroup.PrimitiveCount != 0))
                            {
                                for (int k = 0; k < drawGroup.PrimitiveCount; k++)
                                {
                                    if (((vector = arrOff[i]) != null) && (((arrOff[i].X != 0.0) || (arrOff[i].Y != 0.0)) || (arrOff[i].Z != 0.0)))
                                    {
                                        uint num;
                                        primitive = drawGroup.GetPrimitive(k);
                                        if ((primitive != null) && ((num = primitive.VertexArray.Length) != 0))
                                        {
                                            int num2 = (int)(num / 3);
                                            for (int m = 0; m < num2; m++)
                                            {
                                                primitive.VertexArray.Set(m * 3, primitive.VertexArray.Array[m * 3] + ((float)vector.X));
                                                primitive.VertexArray.Set((m * 3) + 1, primitive.VertexArray.Array[(m * 3) + 1] + ((float)vector.Y));
                                                primitive.VertexArray.Set((m * 3) + 2, primitive.VertexArray.Array[(m * 3) + 2] + ((float)vector.Z));
                                            }
                                        }
                                    }
                                }
                                model.AddGroup(drawGroup);
                            }
                        }
                    }
                }
                return(model);
            }
            catch (Exception exception)
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 原代码
        /// </summary>
        //public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        //{
        //    base.Draw(out mp, out fmodel, out smodel);
        //    try
        //    {
        //        IDrawGroup group;
        //        if ((base._vtx.Length == 1) && (base._sections.Length == 1))
        //        {
        //            object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
        //            int[] index = new int[3];
        //            index[1] = 1;
        //            index[2] = 2;
        //            if (base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
        //            {
        //                int[] numArray2 = new int[1];
        //                if (base.NewEmptyModel(numArray2, base._renderType, renderInfo, out smodel))
        //                {
        //                    goto Label_0086;
        //                }
        //            }
        //        }
        //        return false;
        //    Label_0086:
        //        group = null;
        //        group = fmodel.GetGroup(0);
        //        IDrawPrimitive primitive = group.GetPrimitive(0);
        //        group.GetPrimitive(1);
        //        group.GetPrimitive(2);
        //        IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
        //        base.DrawConSingle(base._vtx[0], base._sections[0], ref fmodel);
        //        primitive2.Material.CullMode = gviCullFaceMode.gviCullNone;
        //        primitive2.VertexArray = primitive.VertexArray;
        //        primitive2.NormalArray = primitive.NormalArray;
        //        primitive2.TexcoordArray = primitive.TexcoordArray;
        //        primitive2.IndexArray = primitive.IndexArray;
        //        return true;
        //    }
        //    catch (Exception exception)
        //    {
        //        SystemLog.Instance.Log(exception.StackTrace);
        //        return false;
        //    }
        //}
        /// <summary>
        /// 单面封口绘制 FX 2014.04.04
        /// </summary>
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                IDrawGroup group;
                if ((base._vtx.Length == 1) && (base._sections.Length == 1))
                {
                    object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                    int[]  index      = new int[2];
                    index[1] = 1;
                    // 调整封口处颜色 与管壁颜色一致
                    uint[] numArray1 = renderInfo as uint[];
                    if (numArray1.Length > 1)
                    {
                        for (int i = 1; i < numArray1.Length; i++)
                        {
                            numArray1[i] = numArray1[0];
                        }
                    }
                    if (base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
                    {
                        int[] numArray2 = new int[1];
                        if (base.NewEmptyModel(numArray2, base._renderType, renderInfo, out smodel))
                        {
                            goto Label_0086;
                        }
                    }
                }
                return(false);

Label_0086:
                group = null;
                group = fmodel.GetGroup(0);
                IDrawPrimitive primitive  = group.GetPrimitive(0);
                IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
                base.DrawConSingle1(base._vtx[0], base._sections[0], ref fmodel);
                primitive2.Material.CullMode = gviCullFaceMode.gviCullNone;
                primitive2.VertexArray       = primitive.VertexArray;
                primitive2.NormalArray       = primitive.NormalArray;
                primitive2.TexcoordArray     = primitive.TexcoordArray;
                primitive2.IndexArray        = primitive.IndexArray;
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 4
0
        public static void TestDrawTriMesh(IModelPoint mp, IModel model)
        {
            ISurfaceSymbol symbol = (SurfaceSymbol)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4D5F0624-50A1-43E2-A0EC-A9713CB25608")));

            symbol.Color = 0xff0000ff;
            ICurveSymbol symbol2 = (CurveSymbol)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("E02C69C4-828D-40D5-869D-DAEB189B7F6F")));

            symbol2.Color         = 0xffff0000;
            symbol.BoundarySymbol = symbol2;
            IMultiPolygon multiPolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;

            if (multiPolygon != null)
            {
                IPolygon geometry   = null;
                IPoint   pointValue = null;
                for (int i = 0; i < model.GroupCount; i++)
                {
                    IDrawGroup group = model.GetGroup(i);
                    for (int j = 0; j < group.PrimitiveCount; j++)
                    {
                        IDrawPrimitive primitive = group.GetPrimitive(j);
                        for (int k = 0; k < (primitive.IndexArray.Length / 3); k++)
                        {
                            geometry     = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                            pointValue   = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[k * 3] * 3];
                            pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[k * 3] * 3) + 1];
                            pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[k * 3] * 3) + 2];
                            geometry.ExteriorRing.AppendPoint(pointValue);
                            pointValue   = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[(k * 3) + 1] * 3];
                            pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 1] * 3) + 1];
                            pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 1] * 3) + 2];
                            geometry.ExteriorRing.AppendPoint(pointValue);
                            pointValue   = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[(k * 3) + 2] * 3];
                            pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 2] * 3) + 1];
                            pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 2] * 3) + 2];
                            geometry.ExteriorRing.AppendPoint(pointValue);
                            geometry.Close();
                            multiPolygon.AddGeometry(geometry);
                        }
                    }
                }
                IRenderMultiPolygon item = Ocx.ObjectManager.CreateRenderMultiPolygon(multiPolygon, symbol, Ocx.ProjectTree.RootID);
                item.MaxVisibleDistance = 5000000.0;
                tmpList.Add(item);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            try
            {
                ConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                ci.Database       = "../XXX.FDB";
                IDataSource      dataSouce  = new DataSourceFactory().OpenDataSource(ci);
                string[]         names      = (string[])dataSouce.GetFeatureDatasetNames();
                IFeatureDataSet  fds        = dataSouce.OpenFeatureDataset(names[0]);
                IResourceManager resManager = fds as IResourceManager;

                //没有锁时这句会报错
                IEnumResName myEnumNames = resManager.GetModelNames();
                while (myEnumNames.MoveNext())
                {
                    string modelName = myEnumNames.Current;
                    IModel myModel   = resManager.GetModel(modelName);
                    if (myModel != null)
                    {
                        for (int i = 0; i < myModel.GroupCount; i++)
                        {
                            IDrawGroup myGroup = myModel.GetGroup(i);
                            for (int j = 0; j < myGroup.PrimitiveCount; j++)
                            {
                                IDrawPrimitive myPv = myGroup.GetPrimitive(j);
                                IDrawMaterial  myDM = myPv.Material;
                                if (myDM != null)
                                {
                                    myDM.EnableLight = false;
                                }
                                myPv.Material = myDM;
                                myGroup.SetPrimitive(j, myPv);
                            }
                            myModel.SetGroup(i, myGroup);
                        }
                        resManager.UpdateModel(modelName, myModel);
                    }
                }

                //手动释放COM对象
                Marshal.ReleaseComObject(fds);
                MessageBox.Show("完成!");
            }
            catch { MessageBox.Show("必须插入加密锁!必须安装CityMaker Builder 7.1"); }
        }
Esempio n. 6
0
        private bool OpenOsgModel(string osgPath, out IModel fmodel, out IModel smodel, out IPropertySet images, out IMatrix mat)
        {
            fmodel = null;
            smodel = null;
            images = null;
            mat    = null;
            IResourceFactory resFactory = new ResourceFactoryClass();

            if ((resFactory == null) || !File.Exists(osgPath))
            {
                return(false);
            }
            Dictionary <string, string> dictionary = null;
            IDrawGroup     group     = null;
            IDrawPrimitive primitive = null;
            IPropertySet   set       = null;
            string         str       = "";
            IImage         property  = null;

            try
            {
                resFactory.CreateModelAndImageFromFileEx(osgPath, out images, out smodel, out fmodel, out mat);
                if ((images != null) && (images.Count > 0))
                {
                    set        = new PropertySetClass();
                    dictionary = new Dictionary <string, string>();
                    foreach (string str2 in images.GetAllKeys())
                    {
                        property = images.GetProperty(str2) as IImage;
                        IImage temp     = null;
                        string filePath = string.Format(string.Format(@"{0}\..\temp\{1}.png", Application.StartupPath, Guid.NewGuid().ToString()), new object[0]);
                        if (property.WriteFile(filePath))
                        {
                            temp = resFactory.CreateImageFromFile(filePath);
                        }
                        str = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        dictionary.Add(str2, str);
                        set.SetProperty(str, temp);
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                    images = set;
                }
                if ((fmodel != null) && (fmodel.GroupCount > 0))
                {
                    for (int i = 0; i < fmodel.GroupCount; i++)
                    {
                        group = fmodel.GetGroup(i);
                        if (group != null)
                        {
                            if (!string.IsNullOrEmpty(group.CompleteMapTextureName) && dictionary.ContainsKey(group.CompleteMapTextureName))
                            {
                                group.CompleteMapTextureName = dictionary[group.CompleteMapTextureName];
                            }
                            if (!string.IsNullOrEmpty(group.LightMapTextureName) && dictionary.ContainsKey(group.LightMapTextureName))
                            {
                                group.LightMapTextureName = dictionary[group.LightMapTextureName];
                            }
                            if (group.PrimitiveCount > 0)
                            {
                                for (int j = 0; j < group.PrimitiveCount; j++)
                                {
                                    primitive = group.GetPrimitive(j);
                                    if (((primitive != null) && (primitive.Material != null)) && (!string.IsNullOrEmpty(primitive.Material.TextureName) && dictionary.ContainsKey(primitive.Material.TextureName)))
                                    {
                                        primitive.Material.TextureName = dictionary[primitive.Material.TextureName];
                                    }
                                }
                            }
                        }
                    }
                }
                if ((smodel != null) && (smodel.GroupCount > 0))
                {
                    for (int k = 0; k < smodel.GroupCount; k++)
                    {
                        group = smodel.GetGroup(k);
                        if (group != null)
                        {
                            if (!string.IsNullOrEmpty(group.CompleteMapTextureName) && dictionary.ContainsKey(group.CompleteMapTextureName))
                            {
                                group.CompleteMapTextureName = dictionary[group.CompleteMapTextureName];
                            }
                            if (!string.IsNullOrEmpty(group.LightMapTextureName) && dictionary.ContainsKey(group.LightMapTextureName))
                            {
                                group.LightMapTextureName = dictionary[group.LightMapTextureName];
                            }
                            if (group.PrimitiveCount > 0)
                            {
                                for (int m = 0; m < group.PrimitiveCount; m++)
                                {
                                    primitive = group.GetPrimitive(m);
                                    if (((primitive != null) && (primitive.Material != null)) && (!string.IsNullOrEmpty(primitive.Material.TextureName) && dictionary.ContainsKey(primitive.Material.TextureName)))
                                    {
                                        primitive.Material.TextureName = dictionary[primitive.Material.TextureName];
                                    }
                                }
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 7
0
        void aaa(IFeatureClass fc, int index, IResourceManager resourceM)
        {
            //无条件查询,即全选
            IFdeCursor sourceCursor = fc.Update(null);
            IRowBuffer row          = null;

            //遍历feature
            while ((row = sourceCursor.NextRow()) != null)
            {
                //从feature中拿到几何属性
                IGeometry geom = (IGeometry)row.GetValue(index);
                //确定是模型
                if (geom.GeometryType == gviGeometryType.gviGeometryModelPoint)
                {
                    //转换为modelPoint
                    IModelPoint mp = (IModelPoint)geom;

                    //mp 的转换矩阵
                    IMatrix mx = mp.AsMatrix();

                    //获取模型实例
                    //注意:
                    //model可以被不同的modelPoint多次引用,需要修改模型时
                    //需要通过modelName判断一下,这个模型被修改过没有
                    IModel model = resourceM.GetModel(mp.ModelName);

                    //提取模型节点属性
                    if (model != null)
                    {
                        #region modelInside
                        //遍历DrawGroup
                        for (int dgrpi = 0; dgrpi < model.GroupCount; dgrpi++)
                        {
                            IDrawGroup dgrp = model.GetGroup(dgrpi);
                            if (dgrp != null)
                            {
                                //遍历DrawPrimitive
                                for (int dpri = 0; dpri < dgrp.PrimitiveCount; dpri++)
                                {
                                    IDrawPrimitive dpr = dgrp.GetPrimitive(dpri);
                                    if (dpr != null)
                                    {
                                        //获取顶点数组
                                        float[] verArray = dpr.VertexArray.Array;
                                        //创建新的顶点数组,替换原来的
                                        IFloatArray newArr = new FloatArray();

                                        //遍历数组,转为点,三个成员为一组,xyz
                                        for (int veri = 0; veri < verArray.Length; veri += 3)
                                        {
                                            Vector3 vec = new Vector3();
                                            vec.X = verArray[veri];
                                            vec.Y = verArray[veri + 1];
                                            vec.Z = verArray[veri + 2];

                                            //用矩阵转到决对坐标,并修改
                                            IVector3 refVec = mx.MultiplyVector(vec);

                                            //修改部份
                                            refVec.X = 3.3;
                                            refVec.Y = 4.4;
                                            refVec.Z = 5.5;

                                            //修改完,减掉mp中的位移,准备塞回modle
                                            newArr.Append((float)(refVec.X - mp.X));
                                            newArr.Append((float)(refVec.Y - mp.Y));
                                            newArr.Append((float)(refVec.Z - mp.Z));
                                        }
                                        //把新顶点数组塞入Primitive
                                        dpr.VertexArray = newArr;
                                        //再把Primitive更新到当前Group
                                        dgrp.SetPrimitive(dpri, dpr);
                                    }
                                }
                                //把组更新到当前model
                                model.SetGroup(dgrpi, dgrp);
                            }
                        }
                        //更新数据源
                        resourceM.UpdateModel(mp.ModelName, model);
                        resourceM.RebuildSimplifiedModel(mp.ModelName);//重建简模
                        //释放资源
                        model.Dispose();
                        model = null;
                        #endregion
                    }

                    //修改mp
                    mp.SetCoords(3.3, 4.4, 5.5, mp.M, mp.Id);
                    //塞回row
                    row.SetValue(index, mp);
                }
            }
        }
Esempio n. 8
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            int            index      = -1;
            IDrawPrimitive primitive  = null;
            IDoubleArray   vArray     = null;
            IUInt16Array   indexArray = null;
            IFloatArray    array3     = null;
            IDoubleArray   norms      = null;

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                int[]  numArray   = new int[2];
                numArray[1] = 1;
                if (!base.NewEmptyModel(numArray, base._renderType, renderInfo, out fmodel))
                {
                    return(false);
                }
                primitive = fmodel.GetGroup(0).GetPrimitive(0);
                if (DrawGeometry.ConvertPolygon(base._vtx, 0.0, 0, out vArray, out indexArray, out array3, out norms))
                {
                    for (index = 0; index < vArray.Length; index++)
                    {
                        primitive.VertexArray.Append((float)vArray.Array[index]);
                    }
                    for (index = 0; index < indexArray.Length; index++)
                    {
                        primitive.IndexArray.Append(indexArray.Array[index]);
                    }
                    double naN = double.NaN;
                    double ty  = double.NaN;
                    for (index = 0; index < (vArray.Length / 3); index++)
                    {
                        base.GetTexcoord(vArray.Array[index * 3], vArray.Array[(index * 3) + 1], out naN, out ty);
                        primitive.TexcoordArray.Append((float)naN);
                        primitive.TexcoordArray.Append((float)ty);
                    }
                    for (index = 0; index < norms.Length; index++)
                    {
                        primitive.NormalArray.Append((float)norms.Array[index]);
                    }
                }
                primitive = fmodel.GetGroup(0).GetPrimitive(1);
                if (DrawGeometry.ConvertPolygon(base._vtx, -this._depth, 1, out vArray, out indexArray, out array3, out norms))
                {
                    for (index = 0; index < vArray.Length; index++)
                    {
                        primitive.VertexArray.Append((float)vArray.Array[index]);
                    }
                    for (index = 0; index < indexArray.Length; index++)
                    {
                        primitive.IndexArray.Append(indexArray.Array[index]);
                    }
                    for (index = 0; index < (vArray.Length / 3); index++)
                    {
                        float num2 = (float)vArray.Array[index * 3];
                        primitive.TexcoordArray.Append(num2);
                        num2 = (float)vArray.Array[(index * 3) + 1];
                        primitive.TexcoordArray.Append(num2);
                    }
                    for (index = 0; index < norms.Length; index++)
                    {
                        primitive.NormalArray.Append((float)norms.Array[index]);
                    }
                }
                int           num5 = base._vtx.Length / 2;
                List <ushort> list = new List <ushort>();
                for (index = 0; index < num5; index++)
                {
                    primitive.VertexArray.Append((float)base._vtx[index * 2]);
                    primitive.VertexArray.Append((float)base._vtx[(index * 2) + 1]);
                    primitive.VertexArray.Append(0f);
                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                    primitive.VertexArray.Append((float)base._vtx[index * 2]);
                    primitive.VertexArray.Append((float)base._vtx[(index * 2) + 1]);
                    primitive.VertexArray.Append(-((float)this._depth));
                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                    primitive.TexcoordArray.Append((index * 4f) / ((float)(num5 - 1)));
                    primitive.TexcoordArray.Append(0f);
                    primitive.TexcoordArray.Append((index * 4f) / ((float)(num5 - 1)));
                    primitive.TexcoordArray.Append((float)this._depth);
                    primitive.NormalArray.Append((float)Math.Sin((6.2831853071795862 * index) / 24.0));
                    primitive.NormalArray.Append((float)Math.Cos((6.2831853071795862 * index) / 24.0));
                    primitive.NormalArray.Append(0f);
                    primitive.NormalArray.Append((float)Math.Sin((6.2831853071795862 * index) / 24.0));
                    primitive.NormalArray.Append((float)Math.Cos((6.2831853071795862 * index) / 24.0));
                    primitive.NormalArray.Append(0f);
                }
                for (index = 0; index < (num5 - 1); index++)
                {
                    primitive.IndexArray.Append(list[index * 2]);
                    primitive.IndexArray.Append(list[((index + 1) * 2) + 1]);
                    primitive.IndexArray.Append(list[(index * 2) + 1]);
                    primitive.IndexArray.Append(list[index * 2]);
                    primitive.IndexArray.Append(list[(index + 1) * 2]);
                    primitive.IndexArray.Append(list[((index + 1) * 2) + 1]);
                }
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 9
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                if (base._vtx == null)
                {
                    return(false);
                }
                if ((base._vtx.Length != 1) && (base._vtx.Length != 2))
                {
                    return(false);
                }
                object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                //int[] index = new int[3];
                //index[1] = 1;
                //index[2] = 2;
                int[] index = new int[2];
                index[1] = 1;
                if (!base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
                {
                    return(false);
                }
                IDrawGroup group = null;
                group = fmodel.GetGroup(0);
                IDrawPrimitive primitive = group.GetPrimitive(0);
                group.GetPrimitive(1);
                group.GetPrimitive(2);
                if (base._vtx.Length == 1)
                {
                    // 生成类似断头的管线20161111
                    IPipeSection[] dSections = new IPipeSection[] { base._sections[0], DrawGeometry.DefaultSection(base._sections[0].SecShape) };
                    base.DrawConSingle1(base._vtx[0], base._sections[0], ref fmodel);

                    // 原代码
                    //Vector[][] dVtxs = new Vector[][] { base._vtx[0], new Vector[] { base._vtx[0][0], new Vector(base._vtx[0][0].X, base._vtx[0][0].Y, 0.0) } };
                    //IPipeSection[] dSections = new IPipeSection[] { base._sections[0], DrawGeometry.DefaultSection(base._sections[0].SecShape) };
                    //base.DrawConBetween(dVtxs, dSections, ref fmodel);
                }
                else
                {
                    base.DrawConBetween(new Vector[][] { base._vtx[0], base._vtx[1] }, new IPipeSection[] { base._sections[0], base._sections[1] }, ref fmodel);
                    Vector[] dVtx = new Vector[] { base._vtx[0][0], new Vector(base._vtx[0][0].X, base._vtx[0][0].Y, 0.0) };
                    base.DrawConSingle(dVtx, DrawGeometry.DefaultSection(base._sections[0].SecShape), ref fmodel);
                }
                IDrawGroup drawGroup = null;
                if (this._bfModel.GroupCount > 0)
                {
                    for (int i = 0; i < this._bfModel.GroupCount; i++)
                    {
                        drawGroup = this._bfModel.GetGroup(i);
                        fmodel.AddGroup(drawGroup);
                    }
                }
                if (this._bsModel != null)
                {
                    int[] numArray2 = new int[1];
                    base.NewEmptyModel(numArray2, base._renderType, renderInfo, out smodel);
                    IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
                    primitive2.Material.CullMode = gviCullFaceMode.gviCullNone;
                    primitive2.VertexArray       = primitive.VertexArray;
                    primitive2.NormalArray       = primitive.NormalArray;
                    primitive2.TexcoordArray     = primitive.TexcoordArray;
                    primitive2.IndexArray        = primitive.IndexArray;
                    if (this._bsModel.GroupCount > 0)
                    {
                        for (int j = 0; j < this._bsModel.GroupCount; j++)
                        {
                            drawGroup = this._bsModel.GetGroup(j);
                            smodel.AddGroup(drawGroup);
                        }
                    }
                }
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 10
0
        //public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        //{
        //    Vector[] array = null;
        //    double[][] numArray = null;
        //    List<ushort> list = null;
        //    List<ushort> list2 = null;
        //    List<ushort> list3 = null;
        //    base.Draw(out mp, out fmodel, out smodel);
        //    try
        //    {
        //        int segCount;
        //        SecShape secShape;
        //        int num2;
        //        int num3;
        //        double[] numArray2;
        //        IDrawGroup group;
        //        if ((base._vtx.Length == 2) && (base._sections.Length == 2))
        //        {
        //            if (base._sections[0].SecShape != base._sections[1].SecShape)
        //            {
        //                return false;
        //            }
        //            if (!DrawGeometry.Compare(base._vtx[0][0], base._vtx[1][0], true))
        //            {
        //                return false;
        //            }
        //            segCount = base._sections[0].SegCount;
        //            secShape = base._sections[0].SecShape;
        //            list = new List<ushort>();
        //            list2 = new List<ushort>();
        //            list3 = new List<ushort>();
        //            List<Vector> vtxs = new List<Vector>();
        //            if ((base._vtx[0][0].Z - base._vtx[1][0].Z) > base._sections[0].Diameter)
        //            {
        //                for (num2 = base._vtx[0].Length - 1; num2 >= 0; num2--)
        //                {
        //                    vtxs.Add(base._vtx[0][num2]);
        //                }
        //                for (num2 = 0; num2 < base._vtx[0].Length; num2++)
        //                {
        //                    vtxs.Add(base._vtx[1][num2]);
        //                }
        //                vtxs = Maths.DisperseArc(vtxs, Math.Min(base._sections[0].Diameter, base._sections[1].Diameter));
        //            }
        //            else
        //            {
        //                num2 = base._vtx[0].Length - 1;
        //                while (num2 >= 0)
        //                {
        //                    vtxs.Add(base._vtx[0][num2]);
        //                    num2--;
        //                }
        //                for (num2 = 1; num2 < base._vtx[0].Length; num2++)
        //                {
        //                    vtxs.Add(base._vtx[1][num2]);
        //                }
        //                vtxs = Maths.DisperseArc(vtxs, Math.Min(base._sections[0].Diameter, base._sections[1].Diameter));
        //            }
        //            Vector vector7 = (base._vtx[0][base._vtx.Length - 1] - base._vtx[0][0]).UnitVector();
        //            Vector vector8 = (base._vtx[1][base._vtx.Length - 1] - base._vtx[1][0]).UnitVector();
        //            array = new Vector[vtxs.Count + 4];
        //            array[0] = vtxs[0] + ((Vector)((vector7 * base._sections[0].Diameter) / 2.0));
        //            array[1] = vtxs[0] + ((Vector)(vector7 * base._sections[0].Thick));
        //            vtxs.CopyTo(array, 2);
        //            array[array.Length - 2] = vtxs[vtxs.Count - 1] + ((Vector)(vector8 * base._sections[0].Thick));
        //            array[array.Length - 1] = vtxs[vtxs.Count - 1] + ((Vector)((vector8 * base._sections[1].Diameter) / 2.0));
        //            numArray2 = new double[array.Length];
        //            for (num2 = 0; num2 < array.Length; num2++)
        //            {
        //                if (num2 == 0)
        //                {
        //                    numArray2[num2] = 0.0;
        //                }
        //                else
        //                {
        //                    numArray2[num2] = (array[num2] - array[num2 - 1]).Length + numArray2[num2 - 1];
        //                }
        //            }
        //            double naN = double.NaN;
        //            numArray = new double[array.Length][];
        //            if (base._sections[0].Diameter != base._sections[1].Diameter)
        //            {
        //                double diameter = base._sections[0].Diameter;
        //                double num6 = base._sections[1].Diameter - base._sections[0].Diameter;
        //                for (num2 = 0; num2 < array.Length; num2++)
        //                {
        //                    switch (num2)
        //                    {
        //                        case 0:
        //                        case 1:
        //                            naN = (base._sections[0].Thick + base._sections[0].Diameter) / base._sections[0].Diameter;
        //                            numArray[num2] = base._sections[0].GetVtxs(naN, 0.0, base._sections[0].Thick);
        //                            break;

        //                        default:
        //                            if ((num2 == (array.Length - 2)) || (num2 == (array.Length - 1)))
        //                            {
        //                                naN = (base._sections[1].Thick + base._sections[1].Diameter) / base._sections[1].Diameter;
        //                                numArray[num2] = base._sections[1].GetVtxs(naN, 0.0, base._sections[1].Thick);
        //                            }
        //                            else
        //                            {
        //                                naN = (((numArray2[num2] - numArray2[2]) / (numArray2[numArray2.Length - 3] - numArray2[2])) * num6) / diameter;
        //                                numArray[num2] = base._sections[0].GetVtxs(naN + 1.0, 0.0, 0.0);
        //                            }
        //                            break;
        //                    }
        //                }
        //            }
        //            else
        //            {
        //                naN = (base._sections[0].Thick + base._sections[0].Diameter) / base._sections[0].Diameter;
        //                for (num2 = 0; num2 < array.Length; num2++)
        //                {
        //                    if (((num2 == 0) || (num2 == 1)) || ((num2 == (array.Length - 2)) || (num2 == (array.Length - 1))))
        //                    {
        //                        numArray[num2] = base._sections[0].GetVtxs(naN, 0.0, base._sections[0].Thick);
        //                    }
        //                    else
        //                    {
        //                        numArray[num2] = base._sections[0].GetVtxs();
        //                    }
        //                }
        //            }
        //            object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
        //            int[] index = new int[3];
        //            index[1] = 1;
        //            index[2] = 2;
        //            if (base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
        //            {
        //                int[] numArray4 = new int[1];
        //                if (base.NewEmptyModel(numArray4, base._renderType, renderInfo, out smodel))
        //                {
        //                    goto Label_05D6;
        //                }
        //            }
        //        }
        //        return false;
        //    Label_05D6:
        //        group = null;
        //        group = fmodel.GetGroup(0);
        //        IDrawPrimitive primitive = group.GetPrimitive(0);
        //        IDrawPrimitive primitive2 = group.GetPrimitive(1);
        //        IDrawPrimitive primitive3 = group.GetPrimitive(2);
        //        IDrawPrimitive primitive4 = smodel.GetGroup(0).GetPrimitive(0);
        //        for (num2 = 0; num2 < array.Length; num2++)
        //        {
        //            Vector vector;
        //            Vector vector2;
        //            Vector vector3;
        //            if (num2 == (array.Length - 1))
        //            {
        //                vector = (array[num2] - array[num2 - 1]).UnitVector();
        //            }
        //            else
        //            {
        //                vector = (array[num2 + 1] - array[num2]).UnitVector();
        //            }
        //            Maths.GenerateComplementBasis(vector, out vector2, out vector3);
        //            num3 = 0;
        //            while (num3 <= segCount)
        //            {
        //                Vector vector6 = (((numArray[num2][num3 * 4] - base._sections[0].OffsetX) * vector2) + ((numArray[num2][(num3 * 4) + 1] - base._sections[0].OffsetY) * vector3)).UnitVector();
        //                Vector vector4 = array[num2] + ((Vector)((numArray[num2][num3 * 4] * vector2) + (numArray[num2][(num3 * 4) + 1] * vector3)));
        //                Vector vector5 = array[num2] + ((Vector)((numArray[num2][(num3 * 4) + 2] * vector2) + (numArray[num2][(num3 * 4) + 3] * vector3)));
        //                if ((num2 == 0) || (num2 == (array.Length - 1)))
        //                {
        //                    primitive3.VertexArray.Append((float)vector4.X);
        //                    primitive3.VertexArray.Append((float)vector4.Y);
        //                    primitive3.VertexArray.Append((float)vector4.Z);
        //                    list3.Add((ushort)((primitive3.VertexArray.Length / 3) - 1));
        //                    primitive3.VertexArray.Append((float)vector5.X);
        //                    primitive3.VertexArray.Append((float)vector5.Y);
        //                    primitive3.VertexArray.Append((float)vector5.Z);
        //                    list3.Add((ushort)((primitive3.VertexArray.Length / 3) - 1));
        //                    if (base._renderType == RenderType.Texture)
        //                    {
        //                        primitive3.TexcoordArray.Append(num2 * 0.4f);
        //                        primitive3.TexcoordArray.Append(num3 * 0.4f);
        //                        primitive3.TexcoordArray.Append(num2 * 0.6f);
        //                        primitive3.TexcoordArray.Append(num3 * 0.6f);
        //                    }
        //                    primitive3.NormalArray.Append(-((float)vector.X));
        //                    primitive3.NormalArray.Append(-((float)vector.Y));
        //                    primitive3.NormalArray.Append(-((float)vector.Z));
        //                    primitive3.NormalArray.Append((float)vector.X);
        //                    primitive3.NormalArray.Append((float)vector.Y);
        //                    primitive3.NormalArray.Append((float)vector.Z);
        //                }
        //                if (secShape == SecShape.CircleRing)
        //                {
        //                    primitive.VertexArray.Append((float)vector4.X);
        //                    primitive.VertexArray.Append((float)vector4.Y);
        //                    primitive.VertexArray.Append((float)vector4.Z);
        //                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
        //                    primitive2.VertexArray.Append((float)vector5.X);
        //                    primitive2.VertexArray.Append((float)vector5.Y);
        //                    primitive2.VertexArray.Append((float)vector5.Z);
        //                    list2.Add((ushort)((primitive2.VertexArray.Length / 3) - 1));
        //                    if (base._renderType == RenderType.Texture)
        //                    {
        //                        primitive.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                        primitive2.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive2.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                    }
        //                    primitive.NormalArray.Append((float)vector6.X);
        //                    primitive.NormalArray.Append((float)vector6.Y);
        //                    primitive.NormalArray.Append((float)vector6.Z);
        //                    primitive2.NormalArray.Append(-((float)vector6.X));
        //                    primitive2.NormalArray.Append(-((float)vector6.Y));
        //                    primitive2.NormalArray.Append(-((float)vector6.Z));
        //                }
        //                else
        //                {
        //                    primitive.VertexArray.Append((float)vector4.X);
        //                    primitive.VertexArray.Append((float)vector4.Y);
        //                    primitive.VertexArray.Append((float)vector4.Z);
        //                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
        //                    primitive.VertexArray.Append((float)vector4.X);
        //                    primitive.VertexArray.Append((float)vector4.Y);
        //                    primitive.VertexArray.Append((float)vector4.Z);
        //                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
        //                    primitive2.VertexArray.Append((float)vector5.X);
        //                    primitive2.VertexArray.Append((float)vector5.Y);
        //                    primitive2.VertexArray.Append((float)vector5.Z);
        //                    list2.Add((ushort)((primitive2.VertexArray.Length / 3) - 1));
        //                    primitive2.VertexArray.Append((float)vector5.X);
        //                    primitive2.VertexArray.Append((float)vector5.Y);
        //                    primitive2.VertexArray.Append((float)vector5.Z);
        //                    list2.Add((ushort)((primitive2.VertexArray.Length / 3) - 1));
        //                    if (base._renderType == RenderType.Texture)
        //                    {
        //                        primitive.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                        primitive.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                        primitive2.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive2.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                        primitive2.TexcoordArray.Append((float)numArray2[num2]);
        //                        primitive2.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
        //                    }
        //                    primitive.NormalArray.Append((float)vector3.X);
        //                    primitive.NormalArray.Append((float)vector3.Y);
        //                    primitive.NormalArray.Append((float)vector3.Z);
        //                    primitive.NormalArray.Append((float)-vector2.X);
        //                    primitive.NormalArray.Append((float)-vector2.Y);
        //                    primitive.NormalArray.Append((float)-vector2.Z);
        //                    primitive2.NormalArray.Append(-((float)-vector3.X));
        //                    primitive2.NormalArray.Append(-((float)-vector3.Y));
        //                    primitive2.NormalArray.Append(-((float)-vector3.Z));
        //                    primitive2.NormalArray.Append(-((float)vector2.X));
        //                    primitive2.NormalArray.Append(-((float)vector2.Y));
        //                    primitive2.NormalArray.Append(-((float)vector2.Z));
        //                }
        //                num3++;
        //            }
        //        }
        //        int num7 = (segCount + 1) * 2;
        //        for (num2 = 0; num2 < (array.Length - 1); num2++)
        //        {
        //            for (num3 = 0; num3 < segCount; num3++)
        //            {
        //                if (num2 == 0)
        //                {
        //                    primitive3.IndexArray.Append(list3[num3 * 2]);
        //                    primitive3.IndexArray.Append(list3[(num3 * 2) + 1]);
        //                    primitive3.IndexArray.Append(list3[((num3 + 1) * 2) + 1]);
        //                    primitive3.IndexArray.Append(list3[num3 * 2]);
        //                    primitive3.IndexArray.Append(list3[((num3 + 1) * 2) + 1]);
        //                    primitive3.IndexArray.Append(list3[(num3 + 1) * 2]);
        //                }
        //                if (secShape == SecShape.CircleRing)
        //                {
        //                    primitive.IndexArray.Append(list[(num2 * (segCount + 1)) + num3]);
        //                    primitive.IndexArray.Append(list[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
        //                    primitive.IndexArray.Append(list[((num2 + 1) * (segCount + 1)) + num3]);
        //                    primitive.IndexArray.Append(list[(num2 * (segCount + 1)) + num3]);
        //                    primitive.IndexArray.Append(list[((num2 * (segCount + 1)) + num3) + 1]);
        //                    primitive.IndexArray.Append(list[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
        //                    primitive2.IndexArray.Append(list2[(num2 * (segCount + 1)) + num3]);
        //                    primitive2.IndexArray.Append(list2[((num2 + 1) * (segCount + 1)) + num3]);
        //                    primitive2.IndexArray.Append(list2[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
        //                    primitive2.IndexArray.Append(list2[(num2 * (segCount + 1)) + num3]);
        //                    primitive2.IndexArray.Append(list2[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
        //                    primitive2.IndexArray.Append(list2[((num2 * (segCount + 1)) + num3) + 1]);
        //                }
        //                else
        //                {
        //                    primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                    primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                    primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                    primitive2.IndexArray.Append(list2[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive2.IndexArray.Append(list2[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive2.IndexArray.Append(list2[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                    primitive2.IndexArray.Append(list2[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
        //                    primitive2.IndexArray.Append(list2[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                    primitive2.IndexArray.Append(list2[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
        //                }
        //                if (num2 == (array.Length - 2))
        //                {
        //                    primitive3.IndexArray.Append(list3[num7 + (num3 * 2)]);
        //                    primitive3.IndexArray.Append(list3[(num7 + ((num3 + 1) * 2)) + 1]);
        //                    primitive3.IndexArray.Append(list3[(num7 + (num3 * 2)) + 1]);
        //                    primitive3.IndexArray.Append(list3[num7 + (num3 * 2)]);
        //                    primitive3.IndexArray.Append(list3[num7 + ((num3 + 1) * 2)]);
        //                    primitive3.IndexArray.Append(list3[(num7 + ((num3 + 1) * 2)) + 1]);
        //                }
        //            }
        //        }
        //        primitive4.Material.CullMode = gviCullFaceMode.gviCullNone;
        //        primitive4.VertexArray = primitive.VertexArray;
        //        primitive4.NormalArray = primitive.NormalArray;
        //        primitive4.TexcoordArray = primitive.TexcoordArray;
        //        primitive4.IndexArray = primitive.IndexArray;
        //        return true;
        //    }
        //    catch (Exception exception)
        //    {
        //        SystemLog.Instance.Log(exception);
        //        return false;
        //    }
        //}
        #endregion

        #region 单壁绘制--冯欣修改20131101
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            Vector[]      array    = null;
            double[][]    numArray = null;
            List <ushort> list     = null;
            List <ushort> list2    = null;
            List <ushort> list3    = null;

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                int        segCount;
                SecShape   secShape;
                int        num2;
                int        num3;
                double[]   numArray2;
                IDrawGroup group;
                if ((base._vtx.Length == 2) && (base._sections.Length == 2))
                {
                    if (base._sections[0].SecShape != base._sections[1].SecShape)
                    {
                        return(false);
                    }
                    if (!DrawGeometry.Compare(base._vtx[0][0], base._vtx[1][0], true))
                    {
                        return(false);
                    }
                    segCount = base._sections[0].SegCount;
                    secShape = base._sections[0].SecShape;
                    list     = new List <ushort>();
                    list2    = new List <ushort>();
                    list3    = new List <ushort>();
                    List <Vector> vtxs = new List <Vector>();
                    if ((base._vtx[0][0].Z - base._vtx[1][0].Z) > base._sections[0].Diameter)
                    {
                        for (num2 = base._vtx[0].Length - 1; num2 >= 0; num2--)
                        {
                            vtxs.Add(base._vtx[0][num2]);
                        }
                        for (num2 = 0; num2 < base._vtx[0].Length; num2++)
                        {
                            vtxs.Add(base._vtx[1][num2]);
                        }
                        vtxs = Maths.DisperseArc(vtxs, Math.Min(base._sections[0].Diameter, base._sections[1].Diameter));
                    }
                    else
                    {
                        num2 = base._vtx[0].Length - 1;
                        while (num2 >= 0)
                        {
                            vtxs.Add(base._vtx[0][num2]);
                            num2--;
                        }
                        for (num2 = 1; num2 < base._vtx[0].Length; num2++)
                        {
                            vtxs.Add(base._vtx[1][num2]);
                        }
                        vtxs = Maths.DisperseArc(vtxs, Math.Min(base._sections[0].Diameter, base._sections[1].Diameter));
                    }
                    Vector vector7 = (base._vtx[0][base._vtx.Length - 1] - base._vtx[0][0]).UnitVector();
                    Vector vector8 = (base._vtx[1][base._vtx.Length - 1] - base._vtx[1][0]).UnitVector();
                    array    = new Vector[vtxs.Count + 4];
                    array[0] = vtxs[0] + ((Vector)((vector7 * base._sections[0].Diameter) / 2.0));
                    array[1] = vtxs[0] + ((Vector)(vector7 * base._sections[0].Thick));
                    vtxs.CopyTo(array, 2);
                    array[array.Length - 2] = vtxs[vtxs.Count - 1] + ((Vector)(vector8 * base._sections[0].Thick));
                    array[array.Length - 1] = vtxs[vtxs.Count - 1] + ((Vector)((vector8 * base._sections[1].Diameter) / 2.0));
                    numArray2 = new double[array.Length];
                    for (num2 = 0; num2 < array.Length; num2++)
                    {
                        if (num2 == 0)
                        {
                            numArray2[num2] = 0.0;
                        }
                        else
                        {
                            numArray2[num2] = (array[num2] - array[num2 - 1]).Length + numArray2[num2 - 1];
                        }
                    }
                    double naN = double.NaN;
                    numArray = new double[array.Length][];
                    if (base._sections[0].Diameter != base._sections[1].Diameter)
                    {
                        double diameter = base._sections[0].Diameter;
                        double num6     = base._sections[1].Diameter - base._sections[0].Diameter;
                        for (num2 = 0; num2 < array.Length; num2++)
                        {
                            switch (num2)
                            {
                            case 0:
                            case 1:
                                naN            = (base._sections[0].Thick + base._sections[0].Diameter) / base._sections[0].Diameter;
                                numArray[num2] = base._sections[0].GetVtxs(naN, 0.0, base._sections[0].Thick);
                                break;

                            default:
                                if ((num2 == (array.Length - 2)) || (num2 == (array.Length - 1)))
                                {
                                    naN            = (base._sections[1].Thick + base._sections[1].Diameter) / base._sections[1].Diameter;
                                    numArray[num2] = base._sections[1].GetVtxs(naN, 0.0, base._sections[1].Thick);
                                }
                                else
                                {
                                    naN            = (((numArray2[num2] - numArray2[2]) / (numArray2[numArray2.Length - 3] - numArray2[2])) * num6) / diameter;
                                    numArray[num2] = base._sections[0].GetVtxs(naN + 1.0, 0.0, 0.0);
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        naN = (base._sections[0].Thick + base._sections[0].Diameter) / base._sections[0].Diameter;
                        for (num2 = 0; num2 < array.Length; num2++)
                        {
                            if (((num2 == 0) || (num2 == 1)) || ((num2 == (array.Length - 2)) || (num2 == (array.Length - 1))))
                            {
                                numArray[num2] = base._sections[0].GetVtxs(naN, 0.0, base._sections[0].Thick);
                            }
                            else
                            {
                                numArray[num2] = base._sections[0].GetVtxs();
                            }
                        }
                    }
                    object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                    int[]  index      = new int[1];
                    if (base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
                    {
                        int[] numArray4 = new int[1];
                        if (base.NewEmptyModel(numArray4, base._renderType, renderInfo, out smodel))
                        {
                            goto Label_05D6;
                        }
                    }
                }
                return(false);

Label_05D6:
                group = null;
                group = fmodel.GetGroup(0);
                IDrawPrimitive primitive  = group.GetPrimitive(0);
                IDrawPrimitive primitive4 = smodel.GetGroup(0).GetPrimitive(0);
                for (num2 = 0; num2 < array.Length; num2++)
                {
                    Vector vector;
                    Vector vector2;
                    Vector vector3;
                    if (num2 == (array.Length - 1))
                    {
                        vector = (array[num2] - array[num2 - 1]).UnitVector();
                    }
                    else
                    {
                        vector = (array[num2 + 1] - array[num2]).UnitVector();
                    }
                    Maths.GenerateComplementBasis(vector, out vector2, out vector3);
                    num3 = 0;
                    while (num3 <= segCount)
                    {
                        Vector vector6 = (((numArray[num2][num3 * 4] - base._sections[0].OffsetX) * vector2) + ((numArray[num2][(num3 * 4) + 1] - base._sections[0].OffsetY) * vector3)).UnitVector();
                        Vector vector4 = array[num2] + ((Vector)((numArray[num2][num3 * 4] * vector2) + (numArray[num2][(num3 * 4) + 1] * vector3)));
                        Vector vector5 = array[num2] + ((Vector)((numArray[num2][(num3 * 4) + 2] * vector2) + (numArray[num2][(num3 * 4) + 3] * vector3)));
                        if (secShape == SecShape.CircleRing)
                        {
                            primitive.VertexArray.Append((float)vector4.X);
                            primitive.VertexArray.Append((float)vector4.Y);
                            primitive.VertexArray.Append((float)vector4.Z);
                            list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                            if (base._renderType == RenderType.Texture)
                            {
                                primitive.TexcoordArray.Append((float)numArray2[num2]);
                                primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
                            }
                            primitive.NormalArray.Append((float)vector6.X);
                            primitive.NormalArray.Append((float)vector6.Y);
                            primitive.NormalArray.Append((float)vector6.Z);
                        }
                        else
                        {
                            primitive.VertexArray.Append((float)vector4.X);
                            primitive.VertexArray.Append((float)vector4.Y);
                            primitive.VertexArray.Append((float)vector4.Z);
                            list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                            primitive.VertexArray.Append((float)vector4.X);
                            primitive.VertexArray.Append((float)vector4.Y);
                            primitive.VertexArray.Append((float)vector4.Z);
                            list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                            if (base._renderType == RenderType.Texture)
                            {
                                primitive.TexcoordArray.Append((float)numArray2[num2]);
                                primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
                                primitive.TexcoordArray.Append((float)numArray2[num2]);
                                primitive.TexcoordArray.Append((num3 * 8f) / ((float)segCount));
                            }
                            primitive.NormalArray.Append((float)vector3.X);
                            primitive.NormalArray.Append((float)vector3.Y);
                            primitive.NormalArray.Append((float)vector3.Z);
                            primitive.NormalArray.Append((float)-vector2.X);
                            primitive.NormalArray.Append((float)-vector2.Y);
                            primitive.NormalArray.Append((float)-vector2.Z);
                        }
                        num3++;
                    }
                }
                primitive.Material.CullMode = gviCullFaceMode.gviCullNone;
                int num7 = (segCount + 1) * 2;
                for (num2 = 0; num2 < (array.Length - 1); num2++)
                {
                    for (num3 = 0; num3 < segCount; num3++)
                    {
                        if (secShape == SecShape.CircleRing)
                        {
                            primitive.IndexArray.Append(list[(num2 * (segCount + 1)) + num3]);
                            primitive.IndexArray.Append(list[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
                            primitive.IndexArray.Append(list[((num2 + 1) * (segCount + 1)) + num3]);
                            primitive.IndexArray.Append(list[(num2 * (segCount + 1)) + num3]);
                            primitive.IndexArray.Append(list[((num2 * (segCount + 1)) + num3) + 1]);
                            primitive.IndexArray.Append(list[(((num2 + 1) * (segCount + 1)) + num3) + 1]);
                        }
                        else
                        {
                            primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
                            primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
                            primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
                            primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 1]);
                            primitive.IndexArray.Append(list[(((num2 * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
                            primitive.IndexArray.Append(list[((((num2 + 1) * (segCount + 1)) * 2) + (num3 * 2)) + 2]);
                        }
                    }
                }
                primitive4.Material.CullMode = gviCullFaceMode.gviCullNone;
                primitive4.VertexArray       = primitive.VertexArray;
                primitive4.NormalArray       = primitive.NormalArray;
                primitive4.TexcoordArray     = primitive.TexcoordArray;
                primitive4.IndexArray        = primitive.IndexArray;
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 11
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            List <ushort> list2 = new List <ushort>();

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                int           num;
                int           num2;
                List <Vector> list;
                if (this._turnerStlye == TurnerStyle.Capround)
                {
                    list = Maths.DisperseLine(this._route, this._pipeSection.Diameter);
                }
                else
                {
                    list = this._route;
                }
                double[] numArray2 = this._pipeSection.GetVtxs(1.05, 0.0, 0.0);
                double[] numArray  = new double[list.Count];
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        numArray[num] = 0.0;
                    }
                    else
                    {
                        numArray[num] = (list[num] - list[num - 1]).Length + numArray[num - 1];
                    }
                }
                object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                int[]  index      = new int[1];
                if (!base.NewEmptyModel(index, base._renderType, renderInfo, out fmodel))
                {
                    return(false);
                }
                IDrawPrimitive primitive = null;
                primitive = fmodel.GetGroup(0).GetPrimitive(0);
                for (num = 0; num < list.Count; num++)
                {
                    Vector vector;
                    Vector vector2;
                    Vector vector3;
                    if (num == 0)
                    {
                        vector = list[num + 1] - list[num];
                    }
                    else if (num == (list.Count - 1))
                    {
                        vector = list[num] - list[num - 1];
                    }
                    else if (this._turnerStlye == TurnerStyle.Capround)
                    {
                        vector = list[num + 1] - list[num];
                    }
                    else
                    {
                        vector = ((list[num] - list[num - 1])).UnitVector() + ((list[num + 1] - list[num])).UnitVector();
                    }
                    Maths.GenerateComplementBasis(vector, out vector2, out vector3);
                    num2 = 0;
                    while (num2 <= this._pipeSection.SegCount)
                    {
                        Vector vector5 = (((numArray2[num2 * 4] - this._pipeSection.OffsetX) * vector2) + ((numArray2[(num2 * 4) + 1] - this._pipeSection.OffsetY) * vector3)).UnitVector();
                        Vector vector4 = list[num] + ((Vector)((numArray2[num2 * 4] * vector2) + (numArray2[(num2 * 4) + 1] * vector3)));
                        primitive.VertexArray.Append((float)vector4.X);
                        primitive.VertexArray.Append((float)vector4.Y);
                        primitive.VertexArray.Append((float)vector4.Z);
                        list2.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                        primitive.TexcoordArray.Append((float)(numArray[num] / (3.1415926535897931 * this._pipeSection.Diameter)));
                        primitive.TexcoordArray.Append((num2 * 1f) / ((float)this._pipeSection.SegCount));
                        primitive.NormalArray.Append((float)vector5.X);
                        primitive.NormalArray.Append((float)vector5.Y);
                        primitive.NormalArray.Append((float)vector5.Z);
                        num2++;
                    }
                }
                for (num = 0; num < (list.Count - 1); num++)
                {
                    for (num2 = 0; num2 < this._pipeSection.SegCount; num2++)
                    {
                        primitive.IndexArray.Append(list2[(num * (this._pipeSection.SegCount + 1)) + num2]);
                        primitive.IndexArray.Append(list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]);
                        primitive.IndexArray.Append(list2[((num + 1) * (this._pipeSection.SegCount + 1)) + num2]);
                        primitive.IndexArray.Append(list2[(num * (this._pipeSection.SegCount + 1)) + num2]);
                        primitive.IndexArray.Append(list2[((num * (this._pipeSection.SegCount + 1)) + num2) + 1]);
                        primitive.IndexArray.Append(list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]);
                    }
                }
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 12
0
        // 新建空模型
        public bool NewEmptyModel(int[] index, RenderType renderType, object renderInfo, out IModel model)
        {
            model = null;
            if (index.Length == 0)
            {
                return(false);
            }
            string[] strArray = null;
            uint[]   numArray = null;
            if (renderType == RenderType.Texture)
            {
                strArray = renderInfo as string[];
                if ((strArray == null) || (strArray.Length < index.Length))
                {
                    return(false);
                }
            }
            else
            {
                numArray = renderInfo as uint[];
                if ((numArray == null) || (numArray.Length < index.Length))
                {
                    return(false);
                }
            }
            IDrawGroup       drawGroup = null;
            IDrawPrimitive   primitive = null;
            IDrawMaterial    material  = null;
            IResourceFactory factory   = new ResourceFactoryClass();

            model            = factory.CreateModel();
            model.SwitchSize = SwitchSize;
            drawGroup        = new DrawGroupClass();
            for (int i = 0; i < index.Length; i++)
            {
                material = new DrawMaterialClass
                {
                    CullMode      = this._cullModel,
                    EnableBlend   = false,
                    EnableLight   = true,
                    SpecularColor = this._specularColor,
                    WrapModeS     = gviTextureWrapMode.gviTextureWrapRepeat,
                    WrapModeT     = gviTextureWrapMode.gviTextureWrapRepeat
                };
                primitive = new DrawPrimitiveClass
                {
                    PrimitiveMode = gviPrimitiveMode.gviPrimitiveModeTriangleList,
                    PrimitiveType = gviPrimitiveType.gviPrimitiveNormal,
                    VertexArray   = new FloatArrayClass(),
                    IndexArray    = new UInt16ArrayClass(),
                    NormalArray   = new FloatArrayClass()
                };
                if (renderType == RenderType.Texture)
                {
                    material.TextureName    = strArray[index[i]];
                    primitive.TexcoordArray = new FloatArrayClass();
                    material.DiffuseColor   = uint.MaxValue;
                }
                else
                {
                    material.TextureName    = "";
                    primitive.TexcoordArray = null;
                    material.DiffuseColor   = numArray[index[i]];
                }
                primitive.Material = material;
                drawGroup.AddPrimitive(primitive);
            }
            model.AddGroup(drawGroup);
            return(true);
        }
Esempio n. 13
0
 private void cbGlass_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (cbGlass.Checked)
         {
             foreach (IFeatureClass fc in fcMap.Keys)
             {
                 // CCTV模型设为玻璃材质
                 IResourceManager rm    = fc.FeatureDataSet as IResourceManager;
                 IModel           model = rm.GetModel("CCTV");
                 int groupCount         = model.GroupCount;
                 for (int i = 0; i < groupCount; i++)
                 {
                     IDrawGroup group          = model.GetGroup(i);
                     int        primitiveCount = group.PrimitiveCount;
                     for (int j = 0; j < primitiveCount; j++)
                     {
                         IDrawPrimitive primitive = group.GetPrimitive(j);
                         primitive.PrimitiveType = gviPrimitiveType.gviPrimitiveGlass;
                     }
                 }
                 rm.UpdateModel("CCTV", model);
                 this.axRenderControl1.RefreshModel(fc.FeatureDataSet, "CCTV");
             }
         }
         else
         {
             foreach (IFeatureClass fc in fcMap.Keys)
             {
                 // CCTV模型设为普通材质
                 IResourceManager rm    = fc.FeatureDataSet as IResourceManager;
                 IModel           model = rm.GetModel("CCTV");
                 int groupCount         = model.GroupCount;
                 for (int i = 0; i < groupCount; i++)
                 {
                     IDrawGroup group          = model.GetGroup(i);
                     int        primitiveCount = group.PrimitiveCount;
                     for (int j = 0; j < primitiveCount; j++)
                     {
                         IDrawPrimitive primitive = group.GetPrimitive(j);
                         primitive.PrimitiveType = gviPrimitiveType.gviPrimitiveNormal;
                     }
                 }
                 rm.UpdateModel("CCTV", model);
                 this.axRenderControl1.RefreshModel(fc.FeatureDataSet, "CCTV");
             }
         }
     }
     catch (System.Exception ex)
     {
         if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
         {
             MessageBox.Show("需要标准runtime授权");
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 14
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            int            index      = -1;
            IDrawPrimitive primitive  = null;
            IDoubleArray   vArray     = null;
            IUInt16Array   indexArray = null;
            IFloatArray    array3     = null;
            IDoubleArray   norms      = null;

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                object renderInfo = (base._renderType == RenderType.Texture) ? ((object)base._tcNames) : ((object)base._colors);
                int[]  numArray   = new int[2];
                numArray[1] = 1;
                if (!base.NewEmptyModel(numArray, base._renderType, renderInfo, out fmodel))
                {
                    return(false);
                }
                //绘制底部
                primitive = fmodel.GetGroup(0).GetPrimitive(0);
                if (DrawGeometry.ConvertPolygon(this._vtx2, 0.0, 0, out vArray, out indexArray, out array3, out norms))
                {
                    for (index = 0; index < vArray.Length; index++)
                    {
                        primitive.VertexArray.Append((float)vArray.Array[index]);
                    }
                    for (index = 0; index < indexArray.Length; index++)
                    {
                        primitive.IndexArray.Append(indexArray.Array[index]);
                    }
                    for (index = 0; index < (vArray.Length / 3); index++)
                    {
                        float num2 = (float)vArray.Array[index * 3];
                        primitive.TexcoordArray.Append(num2);
                        num2 = (float)vArray.Array[(index * 3) + 1];
                        primitive.TexcoordArray.Append(num2);
                    }
                    for (index = 0; index < norms.Length; index++)
                    {
                        primitive.NormalArray.Append((float)norms.Array[index]);
                    }
                }
                double        num3 = 0.0;
                int           num4 = base._vtx.Length / 2;
                List <ushort> list = new List <ushort>();
                primitive = fmodel.GetGroup(0).GetPrimitive(1);
                for (index = 0; index < num4; index++)
                {
                    primitive.VertexArray.Append((float)base._vtx[index * 2]);
                    primitive.VertexArray.Append((float)base._vtx[(index * 2) + 1]);
                    primitive.VertexArray.Append((float)(this._terrainLine[index] - base._hBottom));
                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                    primitive.VertexArray.Append((float)this._vtx2[index * 2]);
                    primitive.VertexArray.Append((float)this._vtx2[(index * 2) + 1]);
                    primitive.VertexArray.Append(0f);
                    list.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                    num3 = (index == 0) ? num3 : (num3 += this._segLenth[index - 1]);
                    primitive.TexcoordArray.Append((float)num3);
                    primitive.TexcoordArray.Append((float)(this._terrainLine[index] - base._hBottom));
                    primitive.TexcoordArray.Append((float)num3);
                    primitive.TexcoordArray.Append(0f);
                    IVector3 vector = new Vector3Class
                    {
                        X = base._vtx[index * 2],
                        Y = base._vtx[(index * 2) + 1],
                        Z = 0.0
                    };
                    vector.Normalize();
                    primitive.NormalArray.Append((float)vector.X);
                    primitive.NormalArray.Append((float)vector.Y);
                    primitive.NormalArray.Append((float)vector.Z);
                    //工程开挖挖洞效果贴图模型出错,添加法向量数组,使其与顶点数组数量一致
                    primitive.NormalArray.Append((float)vector.X);
                    primitive.NormalArray.Append((float)vector.Y);
                    primitive.NormalArray.Append((float)vector.Z);
                }
                for (index = 0; index < (num4 - 1); index++)
                {
                    primitive.IndexArray.Append(list[index * 2]);
                    primitive.IndexArray.Append(list[(index * 2) + 1]);
                    primitive.IndexArray.Append(list[((index + 1) * 2) + 1]);
                    primitive.IndexArray.Append(list[index * 2]);
                    primitive.IndexArray.Append(list[((index + 1) * 2) + 1]);
                    primitive.IndexArray.Append(list[(index + 1) * 2]);
                }
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 15
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            List <ushort> list2 = new List <ushort>();

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                double[] vtxs;
                int      num3;
                if ((this._route != null) && (this._route.Count != 0))
                {
                    vtxs = this._pipeSection.GetVtxs();
                    int[] index = new int[1];
                    if (base.NewEmptyModel(index, RenderType.Texture, new string[] { this._tcName }, out fmodel))
                    {
                        int[] numArray4 = new int[1];
                        if (base.NewEmptyModel(numArray4, RenderType.Color, new uint[] { this._color }, out smodel))
                        {
                            goto Label_0093;
                        }
                    }
                }
                return(false);

Label_0093:
                num3 = 0;
                int num4 = 0;
                foreach (List <Vector> list3 in this._route)
                {
                    int           num2;
                    List <Vector> list     = list3;
                    double[]      numArray = new double[list.Count];
                    int           num      = 0;
                    while (num < list.Count)
                    {
                        if (num == 0)
                        {
                            numArray[num] = 0.0;
                        }
                        else
                        {
                            numArray[num] = (list[num] - list[num - 1]).Length + numArray[num - 1];
                        }
                        num++;
                    }
                    IDrawPrimitive primitive = fmodel.GetGroup(0).GetPrimitive(0);
                    num = 0;
                    while (num < list.Count)
                    {
                        Vector vector;
                        Vector vector2;
                        Vector vector3;
                        if (num == 0)
                        {
                            vector = list[num + 1] - list[num];
                        }
                        else if (num == (list.Count - 1))
                        {
                            vector = list[num] - list[num - 1];
                        }
                        else
                        {
                            vector = ((list[num] - list[num - 1])).UnitVector() + ((list[num + 1] - list[num])).UnitVector();
                        }
                        Maths.GenerateComplementBasis(vector, out vector2, out vector3);
                        num2 = 0;
                        while (num2 <= this._pipeSection.SegCount)
                        {
                            Vector vector5 = (((vtxs[num2 * 4] - this._pipeSection.OffsetX) * vector2) + ((vtxs[(num2 * 4) + 1] - this._pipeSection.OffsetY) * vector3)).UnitVector();
                            Vector vector4 = list[num] + ((Vector)((vtxs[num2 * 4] * vector2) + (vtxs[(num2 * 4) + 1] * vector3)));
                            primitive.VertexArray.Append((float)vector4.X);
                            primitive.VertexArray.Append((float)vector4.Y);
                            primitive.VertexArray.Append((float)vector4.Z);
                            list2.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                            primitive.TexcoordArray.Append((float)(numArray[num] / (3.1415926535897931 * this._pipeSection.Diameter)));
                            primitive.TexcoordArray.Append((num2 * 1f) / ((float)this._pipeSection.SegCount));
                            primitive.NormalArray.Append((float)vector5.X);
                            primitive.NormalArray.Append((float)vector5.Y);
                            primitive.NormalArray.Append((float)vector5.Z);
                            num2++;
                        }
                        num++;
                    }
                    for (num = 0; num < (list.Count - 1); num++)
                    {
                        for (num2 = 0; num2 < this._pipeSection.SegCount; num2++)
                        {
                            primitive.IndexArray.Append((ushort)(num3 + list2[(num * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[((num + 1) * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(num * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[((num * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                        }
                    }
                    IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
                    primitive2.PrimitiveMode = gviPrimitiveMode.gviPrimitiveModeLineList;
                    for (int i = 0; i < (list.Count - 1); i++)
                    {
                        Vector vector6 = list[i];
                        Vector vector7 = list[i + 1];
                        primitive2.VertexArray.Append((float)vector6.X);
                        primitive2.VertexArray.Append((float)vector6.Y);
                        primitive2.VertexArray.Append((float)vector6.Z);
                        primitive2.IndexArray.Append((ushort)(num4 + (i * 2)));
                        primitive2.VertexArray.Append((float)vector7.X);
                        primitive2.VertexArray.Append((float)vector7.Y);
                        primitive2.VertexArray.Append((float)vector7.Z);
                        primitive2.IndexArray.Append((ushort)((num4 + (i * 2)) + 1));
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(1f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(1f);
                    }
                    num3 += list.Count * (this._pipeSection.SegCount + 1);
                    num4 += list.Count;
                }
                fmodel.AddGroup(smodel.GetGroup(0));
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Esempio n. 16
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            List <ushort>  list2      = new List <ushort>();
            IPolygon       polygon    = null;
            IPolygon       polygon2   = null;
            IPolygon       polygon3   = null;
            IPoint         pointValue = null;
            ITriMesh       mesh       = null;
            IDoubleArray   vArray     = null;
            IUInt16Array   indexArray = null;
            IFloatArray    array3     = null;
            IFloatArray    array4     = null;
            IDoubleArray   norms      = null;
            IDrawGroup     group      = null;
            IDrawPrimitive primitive  = null;
            IDrawPrimitive primitive2 = null;
            IDrawPrimitive primitive3 = null;
            double         naN        = double.NaN;
            double         ty         = double.NaN;

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                int           num;
                int           num2;
                List <Vector> list;
                polygon  = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                polygon2 = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                polygon3 = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                if (this._route.Count > 2)
                {
                    list = Maths.DisperseLine(this._route, this._pillarSection.Diameter);
                }
                else
                {
                    list = this._route;
                }
                double[] vtxs = this._pillarSection.GetVtxs();
                SystemLog.Instance.Log("顶点个数:" + vtxs.Length);
                double[] numArray = new double[list.Count];
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        numArray[num] = 0.0;
                    }
                    else
                    {
                        numArray[num] = (list[num] - list[num - 1]).Length + numArray[num - 1];
                    }
                }
                object renderInfo = (this._renderType == RenderType.Texture) ? ((object)this._tcNames) : ((object)this._colors);
                int[]  index      = new int[3];
                index[1] = 1;
                index[2] = 2;
                if (!base.NewEmptyModel(index, this._renderType, renderInfo, out fmodel))
                {
                    return(false);
                }
                group = fmodel.GetGroup(0);
                SystemLog.Instance.Log("开始计算正交向量:" + DateTime.Now.ToLongTimeString());
                primitive = group.GetPrimitive(0);
                for (num = 0; num < list.Count; num++)
                {
                    Vector vector;
                    Vector vector2;
                    Vector vector3;
                    if (num == 0)
                    {
                        vector = list[num + 1] - list[num];
                    }
                    else if (num == (list.Count - 1))
                    {
                        vector = list[num] - list[num - 1];
                    }
                    else
                    {
                        vector = ((list[num] - list[num - 1])).UnitVector() + ((list[num + 1] - list[num])).UnitVector();
                    }
                    Maths.GenerateComplementBasis(vector, out vector2, out vector3);
                    vector2 = -vector2;
                    num2    = 0;
                    while (num2 <= this._pillarSection.SegCount)
                    {
                        Vector vector6;
                        Vector vector7;
                        (((vtxs[num2 * 2] - this._pillarSection.OffsetX) * vector2) + ((vtxs[(num2 * 2) + 1] - this._pillarSection.OffsetY) * vector3)).UnitVector();
                        Vector vector4 = list[num] + ((Vector)((vtxs[num2 * 2] * vector2) + (vtxs[(num2 * 2) + 1] * vector3)));
                        Vector vector5 = (Vector)(vector4 * 1.01);
                        if (num == 0)
                        {
                            pointValue = DrawGeometry.geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.SetCoords(vector4.X, vector4.Y, vector4.Z, 0.0, 0);
                            polygon.ExteriorRing.AppendPoint(pointValue);
                            pointValue = DrawGeometry.geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.SetCoords(vector5.X, vector5.Y, vector5.Z, 0.0, 0);
                            polygon3.ExteriorRing.AppendPoint(pointValue);
                        }
                        else if (num == (list.Count - 1))
                        {
                            pointValue = DrawGeometry.geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            pointValue.SetCoords(vector4.X, vector4.Y, vector4.Z, 0.0, 0);
                            polygon2.ExteriorRing.AppendPoint(pointValue);
                        }
                        primitive.VertexArray.Append((float)vector4.X);
                        primitive.VertexArray.Append((float)vector4.Y);
                        primitive.VertexArray.Append((float)vector4.Z);
                        list2.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                        primitive.VertexArray.Append((float)vector4.X);
                        primitive.VertexArray.Append((float)vector4.Y);
                        primitive.VertexArray.Append((float)vector4.Z);
                        list2.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                        if (this._renderType == RenderType.Texture)
                        {
                            primitive.TexcoordArray.Append((float)(num2 * 1.0));
                            primitive.TexcoordArray.Append((float)(num * 1.0));
                            primitive.TexcoordArray.Append((float)(num2 * 1.0));
                            primitive.TexcoordArray.Append((float)(num * 1.0));
                        }
                        if (num2 == 0)
                        {
                            vector6 = new Vector(vtxs[num2 * 2] - vtxs[(this._pillarSection.SegCount - 1) * 2], vtxs[(num2 * 2) + 1] - vtxs[((this._pillarSection.SegCount - 1) * 2) + 1], 0.0).UnitVector();
                            vector7 = new Vector(vtxs[(num2 + 1) * 2] - vtxs[num2 * 2], vtxs[((num2 + 1) * 2) + 1] - vtxs[(num2 * 2) + 1], 0.0).UnitVector();
                        }
                        else if (num2 == this._pillarSection.SegCount)
                        {
                            vector6 = new Vector(vtxs[num2 * 2] - vtxs[(num2 - 1) * 2], vtxs[(num2 * 2) + 1] - vtxs[((num2 - 1) * 2) + 1], 0.0).UnitVector();
                            vector7 = new Vector(vtxs[2] - vtxs[num2 * 2], vtxs[3] - vtxs[(num2 * 2) + 1], 0.0).UnitVector();
                        }
                        else
                        {
                            vector6 = new Vector(vtxs[num2 * 2] - vtxs[(num2 - 1) * 2], vtxs[(num2 * 2) + 1] - vtxs[((num2 - 1) * 2) + 1], 0.0).UnitVector();
                            vector7 = new Vector(vtxs[(num2 + 1) * 2] - vtxs[num2 * 2], vtxs[((num2 + 1) * 2) + 1] - vtxs[(num2 * 2) + 1], 0.0).UnitVector();
                        }
                        Vector vector8 = new Vector(vector6.Y, -vector6.X, vector6.Z);
                        primitive.NormalArray.Append((float)vector8.X);
                        primitive.NormalArray.Append((float)vector8.Y);
                        primitive.NormalArray.Append((float)vector8.Z);
                        vector8 = new Vector(vector7.Y, -vector7.X, vector7.Z);
                        primitive.NormalArray.Append((float)vector8.X);
                        primitive.NormalArray.Append((float)vector8.Y);
                        primitive.NormalArray.Append((float)vector8.Z);
                        num2++;
                    }
                }
                SystemLog.Instance.Log("结束计算正交向量:" + DateTime.Now.ToLongTimeString());
                SystemLog.Instance.Log("开始添加索引数组:" + DateTime.Now.ToLongTimeString());
                for (num = 0; num < (list.Count - 1); num++)
                {
                    for (num2 = 0; num2 < this._pillarSection.SegCount; num2++)
                    {
                        primitive.IndexArray.Append(list2[((num * ((this._pillarSection.SegCount + 1) * 2)) + (num2 * 2)) + 1]);
                        primitive.IndexArray.Append(list2[((num + 1) * ((this._pillarSection.SegCount + 1) * 2)) + ((num2 + 1) * 2)]);
                        primitive.IndexArray.Append(list2[(((num + 1) * ((this._pillarSection.SegCount + 1) * 2)) + (num2 * 2)) + 1]);
                        primitive.IndexArray.Append(list2[((num * ((this._pillarSection.SegCount + 1) * 2)) + (num2 * 2)) + 1]);
                        primitive.IndexArray.Append(list2[(num * ((this._pillarSection.SegCount + 1) * 2)) + ((num2 + 1) * 2)]);
                        primitive.IndexArray.Append(list2[((num + 1) * ((this._pillarSection.SegCount + 1) * 2)) + ((num2 + 1) * 2)]);
                    }
                }
                SystemLog.Instance.Log("结束添加索引数组:" + DateTime.Now.ToLongTimeString());
                SystemLog.Instance.Log("开始画底面顶面和线框:" + DateTime.Now.ToLongTimeString());
                vArray     = new DoubleArrayClass();
                indexArray = new UInt16ArrayClass();
                array3     = new FloatArrayClass();
                norms      = new DoubleArrayClass();
                primitive2 = group.GetPrimitive(1);
                polygon.ExteriorRing.ReverseOrientation();
                mesh = DrawGeometry.geoConvertor.PolygonToTriMesh(polygon);
                if ((mesh != null) && mesh.BatchExport(ref vArray, ref indexArray, ref array3, ref array4, ref norms))
                {
                    for (num = 0; num < vArray.Length; num++)
                    {
                        primitive2.VertexArray.Append((float)vArray.Array[num]);
                    }
                    for (num = 0; num < indexArray.Length; num++)
                    {
                        primitive2.IndexArray.Append(indexArray.Array[num]);
                    }
                    for (num = 0; num < norms.Length; num++)
                    {
                        primitive2.NormalArray.Append((float)norms.Array[num]);
                    }
                    if (this._renderType == RenderType.Texture)
                    {
                        for (num = 0; num < (vArray.Length / 3); num++)
                        {
                            this.GetTexcoord(vArray.Array[num * 3], vArray.Array[(num * 3) + 1], out naN, out ty);
                            primitive2.TexcoordArray.Append((float)naN);
                            primitive2.TexcoordArray.Append((float)ty);
                        }
                    }
                }
                vArray     = new DoubleArrayClass();
                indexArray = new UInt16ArrayClass();
                array3     = new FloatArrayClass();
                norms      = new DoubleArrayClass();
                primitive3 = group.GetPrimitive(2);
                mesh       = DrawGeometry.geoConvertor.PolygonToTriMesh(polygon2);
                if ((mesh != null) && mesh.BatchExport(ref vArray, ref indexArray, ref array3, ref array4, ref norms))
                {
                    for (num = 0; num < vArray.Length; num++)
                    {
                        primitive3.VertexArray.Append((float)vArray.Array[num]);
                    }
                    for (num = 0; num < indexArray.Length; num++)
                    {
                        primitive3.IndexArray.Append(indexArray.Array[num]);
                    }
                    for (num = 0; num < norms.Length; num++)
                    {
                        primitive3.NormalArray.Append((float)norms.Array[num]);
                    }
                    if (this._renderType == RenderType.Texture)
                    {
                        for (num = 0; num < (vArray.Length / 3); num++)
                        {
                            this.GetTexcoord(vArray.Array[num * 3], vArray.Array[(num * 3) + 1], out naN, out ty);
                            primitive3.TexcoordArray.Append((float)naN);
                            primitive3.TexcoordArray.Append((float)ty);
                        }
                    }
                }
                SystemLog.Instance.Log("结束画底面顶面和线框:" + DateTime.Now.ToLongTimeString());
                SystemLog.Instance.Log("结束调用Draw:" + DateTime.Now.ToLongTimeString());
                return(true);
            }
            catch (Exception exception)
            {
                SystemLog.Instance.Log(exception);
                return(false);
            }
        }