Exemple #1
0
 private void Model2Water(ref Gvitech.CityMaker.Resource.IModel gvModel)
 {
     if (gvModel != null)
     {
         for (int i = 0; i < gvModel.GroupCount; i++)
         {
             Gvitech.CityMaker.Resource.IDrawGroup group = gvModel.GetGroup(i);
             if (group != null)
             {
                 for (int j = 0; j < group.PrimitiveCount; j++)
                 {
                     Gvitech.CityMaker.Resource.IDrawPrimitive primitive = group.GetPrimitive(j);
                     if (primitive != null)
                     {
                         primitive.PrimitiveType         = Gvitech.CityMaker.Resource.gviPrimitiveType.gviPrimitiveWater;
                         primitive.Material.DiffuseColor = 4278393126u;
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        private bool MergeModels(IFeatureClass fc, string geometryField, int[] oidList, IResourceManager resMgr, ref IModelPoint desModelPoint)
        {
            bool flag = true;
            bool result;

            try
            {
                if (fc == null || oidList == null)
                {
                    result = false;
                    return(result);
                }
                Gvitech.CityMaker.Resource.IModel model = resMgr.GetModel(desModelPoint.ModelName);
                IMatrix matrix = desModelPoint.AsMatrix().Clone();
                matrix.Inverse();
                int        position = fc.GetFields().IndexOf(geometryField);
                IFdeCursor rows     = fc.GetRows(oidList, false);
                IVector3   src      = new Vector3Class();
                IVector3   vector   = new Vector3Class();
                System.Collections.Generic.Dictionary <IMatrix, string> dictionary = new System.Collections.Generic.Dictionary <IMatrix, string>();
                IRowBuffer rowBuffer;
                while ((rowBuffer = rows.NextRow()) != null)
                {
                    IModelPoint modelPoint = rowBuffer.GetValue(position) as IModelPoint;
                    if (modelPoint != null)
                    {
                        dictionary[modelPoint.AsMatrix().Clone()] = modelPoint.ModelName;
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(modelPoint);
                    }
                }
                foreach (IMatrix current in dictionary.Keys)
                {
                    string name = dictionary[current];
                    Gvitech.CityMaker.Resource.IModel model2 = resMgr.GetModel(name);
                    for (int i = 0; i < model2.GroupCount; i++)
                    {
                        Gvitech.CityMaker.Resource.IDrawGroup drawGroup = new DrawGroupClass();
                        Gvitech.CityMaker.Resource.IDrawGroup group     = model2.GetGroup(i);
                        for (int j = 0; j < group.PrimitiveCount; j++)
                        {
                            Gvitech.CityMaker.Resource.IDrawPrimitive primitive = group.GetPrimitive(j);
                            if (primitive.PrimitiveType == Gvitech.CityMaker.Resource.gviPrimitiveType.gviPrimitiveBillboardZ)
                            {
                                flag   = false;
                                result = flag;
                                return(result);
                            }
                            Gvitech.CityMaker.Resource.IDrawPrimitive drawPrimitive = new DrawPrimitiveClass();
                            IFloatArray vertexArray = primitive.VertexArray;
                            IFloatArray floatArray  = new FloatArrayClass();
                            int         num         = 0;
                            while ((long)num < (long)((ulong)vertexArray.Length))
                            {
                                vector.X = (double)vertexArray.Get(num);
                                vector.Y = (double)vertexArray.Get(num + 1);
                                vector.Z = (double)vertexArray.Get(num + 2);
                                current.MultiplyVector(vector, ref src);
                                matrix.MultiplyVector(src, ref vector);
                                floatArray.Append((float)vector.X);
                                floatArray.Append((float)vector.Y);
                                floatArray.Append((float)vector.Z);
                                num += 3;
                            }
                            drawPrimitive.VertexArray        = floatArray;
                            drawPrimitive.BakedTexcoordArray = primitive.BakedTexcoordArray;
                            drawPrimitive.ColorArray         = primitive.ColorArray;
                            drawPrimitive.IndexArray         = primitive.IndexArray;
                            drawPrimitive.Material           = primitive.Material;
                            drawPrimitive.NormalArray        = primitive.NormalArray;
                            drawPrimitive.PrimitiveMode      = primitive.PrimitiveMode;
                            drawPrimitive.PrimitiveType      = primitive.PrimitiveType;
                            drawPrimitive.TexcoordArray      = primitive.TexcoordArray;
                            drawGroup.AddPrimitive(drawPrimitive);
                        }
                        drawGroup.CompleteMapFactor      = group.CompleteMapFactor;
                        drawGroup.CompleteMapTextureName = group.CompleteMapTextureName;
                        drawGroup.LightMapTextureName    = group.LightMapTextureName;
                        model.AddGroup(drawGroup);
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(model2);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rows);
                desModelPoint.ModelEnvelope = model.Envelope.Clone();
                resMgr.UpdateModel(desModelPoint.ModelName, model);
                resMgr.RebuildSimplifiedModel(desModelPoint.ModelName);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(matrix);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(model);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                flag = false;
                XtraMessageBox.Show(ex.Message);
            }
            catch (System.Exception e)
            {
                flag = false;
                LoggingService.Error(e);
            }
            result = flag;
            return(result);
        }