Пример #1
0
        public void run()
        {
            Recordset rc = dv.GetRecordset(false, CursorType.Dynamic);
            Dictionary <int, Feature> feas = rc.GetAllFeatures();

            foreach (KeyValuePair <int, Feature> item in feas)
            {
                GeoModel gm = item.Value.GetGeometry() as GeoModel;
                Console.WriteLine("==" + gm.Position + "==");

                //GeoModel model = new ModelIncubation.CuboidModel(10, 10, 10);
                Point3Ds p3ds = new Point3Ds();
                for (int i = 0; i < 7; i++)
                {
                    double seta = 2 * Math.PI * i / 7;
                    p3ds.Add(new Point3D(Math.Sin(seta) * 10, Math.Cos(seta) * 10, 0));
                }
                GeoModel model = new ModelIncubation.PrismModel(p3ds, 30);

                //临时处理,未知原因导致Position.Z属性设置无效,手动偏移模型实体
                model.OffsetModel(new Point3D(0, 0, 1650));
                model.Position = gm.Position;
                model.MergeMeshs();
                Console.WriteLine("");

                model.Position = gm.Position;
                model.ComputeBoundingBox();
                scene.TrackingLayer.Add(model, model.Position.ToString());
                scene.Refresh();
                GeoModel m = scene.TrackingLayer.Get(0) as GeoModel;
                Thread.Sleep(1000);

                break;
            }
        }
Пример #2
0
        //指定模型,并设置其节点动画属性
        private void cb_Model_SelectedIndexChanged(object sender, EventArgs e)
        {
            //如果之前的模型正在运动,则停止运动
            if (m_nodeAnimation != null && m_nodeAnimation.IsEnabled == true)
            {
                m_nodeAnimation.IsEnabled = false;
            }

            //获取当前模型,并设置节点动画
            String featureName = this.cb_Model.SelectedItem as String;

            Feature3Ds features = m_layerKML.Features;

            Feature3D[] feature3Ds = features.FindFeature(featureName, Feature3DSearchOption.AllFeatures);
            if (feature3Ds.Length > 0)
            {
                Feature3D    feature3D    = feature3Ds[0];
                GeoPlacemark geoPlacemark = feature3D.Geometry as GeoPlacemark;
                m_geoModel = geoPlacemark.Geometry as GeoModel;
                if (m_geoModel != null)
                {
                    m_nodeAnimation = m_geoModel.NodeAnimation;
                    //位置变更事件
                    m_nodeAnimation.TimePositionChanged -= new TimePositionChangedEventHandler(m_nodeAnimationTimePositionChanged);
                    m_nodeAnimation.TimePositionChanged += new TimePositionChangedEventHandler(m_nodeAnimationTimePositionChanged);

                    if (m_geoLine3D != null && m_geoLine3D.PartCount > 0)
                    {
                        m_nodeAnimation.SetTrack(m_geoLine3D);
                        m_nodeAnimation.TimePostition = 0;
                    }
                }
            }
        }
Пример #3
0
    private void geomag(GeoModel pmodel0, GeoModel pmodel1, double sdate,
                        double latitude, double longitude, double elev)
    {
        int nmax;

        /** This will compute everything needed for 1 point in time. **/

        if (pmodel1 != null)
        {
            getshc(1, pmodel0.data, pmodel0.smax1, this.gh1);
            getshc(1, pmodel1.data, pmodel1.smax1, this.gh2);
            interpsh(sdate, pmodel0.yrmin, pmodel0.smax1,
                     pmodel1.yrmin, pmodel1.smax1, this.gha);
            nmax = interpsh(sdate + 1, pmodel0.yrmin, pmodel0.smax1,
                            pmodel1.yrmin, pmodel1.smax1, this.ghb);
        }
        else
        {
            getshc(1, pmodel0.data, pmodel0.smax1, this.gh1);
            getshc(0, pmodel0.data, pmodel0.smax2, this.gh2);
            extrapsh(sdate, pmodel0.yrmin, pmodel0.smax1, pmodel0.smax2, this.gha);
            nmax = extrapsh(sdate + 1, pmodel0.yrmin, pmodel0.smax1, pmodel0.smax2, this.ghb);
        }

        /* Do the first calculations */
        shval3(latitude, longitude, elev / 1000.0, nmax, 3);

        dihf3();
        shval3(latitude, longitude, elev / 1000.0, nmax, 4);

        /** Above will compute everything for 1 point in time.  **/
    }
Пример #4
0
        public ActionResult ULGeoLocationList(string cityName, string type)
        {
            GeoBiz   geoBiz = GeoBiz.GetInstant();
            GeoModel geo    = geoBiz.GetGeoByCityName(cityName);
            IList <GeoLocationModel> locations = new List <GeoLocationModel>();
            string typeName = "";

            if (type == "geoDs")
            {
                typeName  = "行政区";
                locations = geoBiz.GetGeoDs(geo.id) as IList <GeoLocationModel>;
            }
            else if (type == "geoCls")
            {
                typeName  = "商业区";
                locations = geoBiz.GetGeoCls(geo.id) as IList <GeoLocationModel>;
            }
            else if (type == "geoLLs")
            {
                typeName  = "标志物";
                locations = geoBiz.GetGeoLls(geo.id) as IList <GeoLocationModel>;
            }
            ViewData[typeof(GeoLocationModel).Name] = locations;
            ViewData["typeName"] = typeName;
            return(View());
        }
Пример #5
0
        protected void InitModel(Point3Ds Bottom, Point3Ds Top)
        {
            geoModel = new GeoModel();
            n = Math.Min(Bottom.Count, Top.Count);
            surface = new Mesh[n + 2];

            surface[n] = geoModel.CreateMesh(Bottom);
            surface[n + 1] = geoModel.CreateMesh(Top);

            for (int i = 0; i < n; i++)
            {
                Point3Ds p3ds = new Point3Ds();
                p3ds.Add(Bottom[i]);
                p3ds.Add(Bottom[(i + 1) % n]);
                p3ds.Add(Top[(i + 1) % n]);
                p3ds.Add(Top[i]);
                surface[i] = geoModel.CreateMesh(p3ds);
            }

            if (this.Meshes.Count > 0)
            {
                this.Meshes.Clear();
            }
            for (int i = 0; i < surface.Length; i++)
            {
                this.Meshes.Add(surface[i]);
            }
        }
Пример #6
0
        /// <summary>
        /// Lädt ein Modell aus einer Datei
        /// </summary>
        /// <param name="name">Name des Modells</param>
        /// <param name="filename">Datei des Modells</param>
        /// <param name="callerName"></param>
        public static void LoadModelFromFile(string name, string filename, [CallerMemberName] string callerName = "")
        {
            if (callerName != "Prepare")
            {
                HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromFile()", "This method may only be called from the Prepare() method.");
                return;
            }

            if (KWEngine.Models.ContainsKey(name.Trim()))
            {
                HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromFile()", "Model name already exists.");
                return;
            }
            GeoModel m = SceneImporter.LoadModel(filename, true, SceneImporter.AssemblyMode.File);

            if (m != null)
            {
                name   = name.Trim();
                m.Name = name;
                lock (KWEngine.Models)
                {
                    KWEngine.Models.Add(name, m);
                }
            }
        }
Пример #7
0
        //
        // GET: /Geo/

        public ActionResult Index(string cityName, string geoClId, string geoDId)
        {
            GeoBiz geoBiz = GeoBiz.GetInstant();

            cityName = ObjectUtil.Parse(cityName, "广州");
            GeoModel geo = geoBiz.GetGeoByCityName(cityName);

            if (geo == null)
            {
                geo = geoBiz.GetGeoByCityName("广州");
            }

            GeoLocationModel geoLocation = null;
            PageSeoModel     seo         = PublicBiz.getCurPageSeo();

            this.setPageDesc(string.Format(seo.cityDesc, geo.cityCode, geo.cityName));
            this.setPageKeyWords(string.Format(seo.cityKeywords, geo.cityCode, geo.cityName));
            if (!string.IsNullOrEmpty(geoClId))
            {
                geoLocation = BaseZdBiz.Load <GeoCommercialLocationModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoClId));
                this.setPageDesc(string.Format(seo.cityClDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
                this.setPageKeyWords(string.Format(seo.cityClKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
            }
            else if (!string.IsNullOrEmpty(geoDId))
            {
                geoLocation = BaseZdBiz.Load <GeoDistrictsModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoDId));
                this.setPageDesc(string.Format(seo.cityDDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
                this.setPageKeyWords(string.Format(seo.cityDKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
            }

            ViewData[typeof(GeoLocationModel).Name] = geoLocation;
            ViewData[typeof(GeoModel).Name]         = geo;
            return(View());
        }
Пример #8
0
        public ActionResult Index()
        {
            PublicBiz      publicBiz = PublicBiz.GetInstant();
            FrontPageModel frontPage = publicBiz.getCurFrontPage();


            string[]         cityNames = frontPage.homeHotCityNameArray.Split(',');
            GeoBiz           geoBiz    = GeoBiz.GetInstant();
            IList <GeoModel> geos      = new List <GeoModel>();

            foreach (string cityName in cityNames)
            {
                GeoModel geo = geoBiz.GetGeoByCityName(cityName);
                geo.geoCls = geoBiz.GetGeoCls(geo.id);
                geo.geoDs  = geoBiz.GetGeoDs(geo.id);
                geo.geoLls = geoBiz.GetGeoLls(geo.id);
                geos.Add(geo);
            }
            ViewData[typeof(IList <GeoModel>).Name] = geos;
            this.VdCityTopHotel(20, cityNames);
            this.VdHotBookingHotel(10);
            this.VdHotBrand(12);
            this.VdHotCity(15);

            this.setPageDesc(PublicBiz.getCurPageSeo().hotelIndexDesc);
            this.setPageKeyWords(PublicBiz.getCurPageSeo().hotelIndexKeywords);

            return(View());
        }
Пример #9
0
        internal static Intersection TestIntersectionTerrain(Hitbox caller, Hitbox collider, Vector3 offset)
        {
            float heightOnMap;

            triangles.Clear();
            GeoModel model = collider.Owner.Model;

            triangles.AddRange(model.Meshes.Values.ElementAt(0).Terrain.GetTrianglesForHitbox(caller, collider.Owner.Position, offset));
            float a = (caller.Owner.Position.Y - caller.GetLowestVertexHeight());

            TestIntersectionSATForTerrain(ref triangles, caller, collider, offset);
            Vector3 mobbPosition             = new Vector3();
            int     lowestTriangle           = -1;
            float   lowestIntersectionHeight = float.MaxValue;
            int     c = 0;

            foreach (GeoTerrainTriangle triangle in trianglesMTV)
            {
                mobbPosition.X = caller.Owner.GetLargestHitbox().mCenter.X + offset.X;
                mobbPosition.Y = caller.Owner.GetLargestHitbox().mCenter.Y + caller.Owner.CurrentWorld.WorldCenter.Y + caller.Owner.CurrentWorld.WorldDistance;
                mobbPosition.Z = caller.Owner.GetLargestHitbox().mCenter.Z + offset.Z;

                int   rayResult          = triangle.Intersect3D_RayTriangle(ref mobbPosition, ref tmpMap, collider.Owner.Position);
                float lowestVertexHeight = caller.GetLowestVertexHeight();

                if (rayResult > 0)
                {
                    if (tmpMap.Y < lowestIntersectionHeight)
                    {
                        lowestIntersectionHeight = tmpMap.Y;
                        lowestTriangle           = c;
                    }
                }
                else
                {
                    if (rayResult == 0)
                    {
                        if (mobbPosition.X == tmpMap.X && mobbPosition.Z == tmpMap.Z)
                        {
                            if (tmpMap.Y < lowestIntersectionHeight)
                            {
                                lowestIntersectionHeight = tmpMap.Y;
                                lowestTriangle           = c;
                            }
                        }
                    }
                }
                c++;
            }
            if (lowestTriangle >= 0)
            {
                heightOnMap = lowestIntersectionHeight + a - offset.Y;
                return(new Intersection(collider.Owner, Vector3.Zero, Vector3.Zero, collider.Owner.Name, heightOnMap, lowestIntersectionHeight, true));
            }
            if (trianglesMTV.Count > 0)
            {
                return(new Intersection(collider.Owner, Vector3.Zero, Vector3.Zero, collider.Owner.Name, collider.mCenter.Y, collider.mCenter.Y, true));
            }
            return(null);
        }
Пример #10
0
        internal void DrawBloom(GeoModel quad, ref Matrix4 mvp, bool bloomDirectionHorizontal, int bloomTexture)
        {
            GL.UniformMatrix4(mUniform_MVP, false, ref mvp);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bloomTexture);
            GL.Uniform1(mUniform_TextureBloom, 0);
            GL.Uniform1(mUniform_BloomRadius, 1.0f);
            GL.Uniform1(mUniform_Horizontal, bloomDirectionHorizontal ? 1 : 0);

            float factor = KWEngine.PostProcessing == PostProcessingState.HighQuality ? 0.8f : 0.4f;

            GL.Uniform2(
                mUniform_Resolution,
                1f / (KWEngine.CurrentWindow.Width * factor),
                1f / (KWEngine.CurrentWindow.Height * factor)
                );

            GL.BindVertexArray(quad.Meshes.Values.ElementAt(0).VAO);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, quad.Meshes.Values.ElementAt(0).VBOIndex);
            GL.DrawElements(quad.Meshes.Values.ElementAt(0).Primitive, quad.Meshes.Values.ElementAt(0).IndexCount, DrawElementsType.UnsignedInt, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            GL.BindVertexArray(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Пример #11
0
        //
        // GET: /Exhi/

        public ActionResult Index(string cityName, string keyword)
        {
            ICriteria icr    = BaseZdBiz.CreateCriteria <ExhiModel>(new PagerObject(1, 20));
            GeoBiz    geoBiz = GeoBiz.GetInstant();

            if (WebUtil.IsPost())
            {
                GeoModel geo = geoBiz.GetGeoByCityName(cityName);
                icr.Add(Restrictions.Eq("geoFk", geo.id));
                icr.Add(Restrictions.Like("name", "%" + keyword + "%"));
            }
            icr.AddOrder(Order.Desc("startDate"));
            IList <ExhiModel> exhis = icr.List <ExhiModel>();

            ViewData[typeof(ExhiModel).Name] = exhis;
            this.VdHotBookingHotel(10);
            this.VdHotBrand(12);
            this.VdHotCity(15);

            PageSeoModel seo = PublicBiz.getCurPageSeo();

            this.setPageDesc(seo.exhiIndexDesc);
            this.setPageKeyWords(seo.exhiIndexKeywords);
            return(View());
        }
Пример #12
0
        internal static void InitializeModels()
        {
            Models.Add("KWCube", SceneImporter.LoadModel("kwcube.obj", false, SceneImporter.AssemblyMode.Internal));
            Models.Add("KWCube6", SceneImporter.LoadModel("kwcube6.obj", false, SceneImporter.AssemblyMode.Internal));
            KWRect = SceneImporter.LoadModel("kwrect.obj", false, SceneImporter.AssemblyMode.Internal);
            Models.Add("KWSphere", SceneImporter.LoadModel("kwsphere.obj", false, SceneImporter.AssemblyMode.Internal));
            KWStar = SceneImporter.LoadModel("star.obj", false, SceneImporter.AssemblyMode.Internal);
            Models.Add("KWStar", KWStar);
            KWHeart = SceneImporter.LoadModel("heart.obj", false, SceneImporter.AssemblyMode.Internal);
            Models.Add("KWHeart", KWHeart);
            KWSkull = SceneImporter.LoadModel("skull.obj", false, SceneImporter.AssemblyMode.Internal);
            Models.Add("KWSkull", KWSkull);
            KWDollar = SceneImporter.LoadModel("dollar.obj", false, SceneImporter.AssemblyMode.Internal);
            Models.Add("KWDollar", KWDollar);
            CoordinateSystem  = SceneImporter.LoadModel("csystem.obj", false, SceneImporter.AssemblyMode.Internal);
            CoordinateSystemX = SceneImporter.LoadModel("csystemX.obj", false, SceneImporter.AssemblyMode.Internal);
            CoordinateSystemY = SceneImporter.LoadModel("csystemY.obj", false, SceneImporter.AssemblyMode.Internal);
            CoordinateSystemZ = SceneImporter.LoadModel("csystemZ.obj", false, SceneImporter.AssemblyMode.Internal);
            GHitbox           = SceneImporter.LoadModel("Hitbox.obj", false, SceneImporter.AssemblyMode.Internal);

            for (int i = 0; i < Explosion.Axes.Length; i++)
            {
                Explosion.Axes[i] = Vector3.Normalize(Explosion.Axes[i]);
            }
        }
Пример #13
0
        protected void InitModel(Point3Ds Bottom, Point3Ds Top)
        {
            geoModel = new GeoModel();
            n        = Math.Min(Bottom.Count, Top.Count);
            surface  = new Mesh[n + 2];

            surface[n]     = geoModel.CreateMesh(Bottom);
            surface[n + 1] = geoModel.CreateMesh(Top);

            for (int i = 0; i < n; i++)
            {
                Point3Ds p3ds = new Point3Ds();
                p3ds.Add(Bottom[i]);
                p3ds.Add(Bottom[(i + 1) % n]);
                p3ds.Add(Top[(i + 1) % n]);
                p3ds.Add(Top[i]);
                surface[i] = geoModel.CreateMesh(p3ds);
            }

            if (this.Meshes.Count > 0)
            {
                this.Meshes.Clear();
            }
            for (int i = 0; i < surface.Length; i++)
            {
                this.Meshes.Add(surface[i]);
            }
        }
Пример #14
0
        internal static Intersection TestIntersectionTerrain(Hitbox caller, Hitbox collider, Vector3 offset)
        {
            GeoModel model = collider.Owner.Model;
            Vector3  untranslatedPosition = caller.Owner.GetLargestHitbox().GetCenter() + offset - new Vector3(collider.Owner.Position.X, 0, collider.Owner.Position.Z);
            Sector   s = model.Meshes.Values.ElementAt(0).Terrain.GetSectorForUntranslatedPosition(untranslatedPosition);

            if (s != null)
            {
                GeoTerrainTriangle?tris = s.GetTriangle(ref untranslatedPosition);
                if (tris.HasValue)
                {
                    Intersection i = TestIntersectionSATForTerrain(tris.Value, caller, collider, ref offset);
                    if (i != null)
                    {
                        return(i);
                    }
                    return(null);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #15
0
        /// <summary>
        /// 该方法可将geomodel中的mesh集合合并为一个mesh对象
        /// </summary>
        /// <param name="geoModel"></param>
        /// <param name="Tolerance">容差,小数点后位数。设置后所有点坐标的小数点后只保留该长度</param>
        public static void MergeMeshs(this GeoModel geoModel, int Tolerance = 2)
        {
            if (geoModel.Meshes.Count > 0)
            {
                Mesh mesh = new Mesh();

                Dictionary <int, Vertice> vPDic;
                List <Index> vPIndex;

                geoModel.structureData(Tolerance, out vPDic, out vPIndex);
                //归一化法线
                foreach (KeyValuePair <int, Vertice> vP in vPDic)
                {
                    double distence = Math.Sqrt(Math.Pow(vP.Value.Normal.X, 2) + Math.Pow(vP.Value.Normal.Y, 2) + Math.Pow(vP.Value.Normal.Z, 2));
                    if (distence > 0)
                    {
                        vP.Value.Normal.X /= distence;
                        vP.Value.Normal.Y /= distence;
                        vP.Value.Normal.Z /= distence;
                    }
                }
                geoModel.MakeMesh(vPDic, vPIndex);
                geoModel.CalculateNormals(ref vPDic, vPIndex);
            }
        }
Пример #16
0
        public IHttpActionResult PutGeo(GeoModel geoModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var locationExist = db.Geos.FirstOrDefault(w => w.Id == geoModel.Id);
                if (locationExist != null)
                {
                    var locationValue = Common.CreatePoint(geoModel.Latitude, geoModel.Longitude);
                    locationExist.Location = locationValue;
                }
                else
                {
                    var locationValue = Common.CreatePoint(geoModel.Latitude, geoModel.Longitude);
                    var location      = new Geo();
                    location.Id       = geoModel.Id;
                    location.Address  = geoModel.Address;
                    location.Location = locationValue;
                    db.Geos.Add(location);
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
Пример #17
0
        public ActionResult Datagrid_del()
        {
            GeoModel e = new GeoModel();

            DatagridObject datagrid = createGeoDatagrid(BaseModel.STATUS_DELETE);

            return(JsonText(datagrid, JsonRequestBehavior.AllowGet));
        }
Пример #18
0
        /// <summary>
        /// 计算法向量
        /// </summary>
        /// <param name="geoModel"></param>
        public static void CalculateNormals(this GeoModel geoModel, ref Dictionary <int, Vertice> vPDic, List <Index> vPIndex)
        {
            Normal normal1, normal2, normal3;

            foreach (Index index in vPIndex)
            {
                normal1 = vPDic[index.P1].Normal;
                normal2 = vPDic[index.P2].Normal;
                normal3 = vPDic[index.P3].Normal;

                double a1 = vPDic[index.P2].X - vPDic[index.P1].X,
                       a2 = vPDic[index.P2].Y - vPDic[index.P1].Y,
                       a3 = vPDic[index.P2].Z - vPDic[index.P1].Z,

                       b1 = vPDic[index.P3].X - vPDic[index.P1].X,
                       b2 = vPDic[index.P3].Y - vPDic[index.P1].Y,
                       b3 = vPDic[index.P3].Z - vPDic[index.P1].Z;

                double aXb1 = a2 * b3 - a3 * b2,
                       aXb2 = a3 * b1 - a1 * b3,
                       aXb3 = a1 * b2 - a2 * b1;
                #region 法线正向
                //法线投影到XY平面,(aXb1,aXb2)+(Px,Py)长度大于(Px,Py),则为正
                if ((Math.Pow(vPDic[index.P1].X + aXb1, 2) + Math.Pow(vPDic[index.P1].Y + aXb2, 2)) < (Math.Pow(vPDic[index.P1].X, 2) + Math.Pow(vPDic[index.P1].Y, 2)))
                {
                    aXb1 *= -1;
                    aXb2 *= -1;
                    aXb3 *= -1;
                }

                #endregion

                normal1.X += aXb1; normal1.Y = aXb2; normal1.Z = aXb3;
                normal2.X += aXb1; normal2.Y = aXb2; normal2.Z = aXb3;
                normal3.X += aXb1; normal3.Y = aXb2; normal3.Z = aXb3;

                //归一化法线
                double d1 = Math.Sqrt(Math.Pow(normal1.X, 2) + Math.Pow(normal1.Y, 2) + Math.Pow(normal1.Z, 2));
                double d2 = Math.Sqrt(Math.Pow(normal2.X, 2) + Math.Pow(normal2.Y, 2) + Math.Pow(normal2.Z, 2));
                double d3 = Math.Sqrt(Math.Pow(normal3.X, 2) + Math.Pow(normal3.Y, 2) + Math.Pow(normal3.Z, 2));
                if (d1 > 0)
                {
                    normal1.X /= d1; normal1.Y /= d1; normal1.Z /= d1;
                }
                if (d2 > 0)
                {
                    normal2.X /= d2; normal2.Y /= d2; normal2.Z /= d2;
                }
                if (d3 > 0)
                {
                    normal3.X /= d3; normal3.Y /= d3; normal3.Z /= d3;
                }

                vPDic[index.P1].Normal = normal1;
                vPDic[index.P2].Normal = normal2;
                vPDic[index.P3].Normal = normal3;
            }
        }
Пример #19
0
        /// <summary>
        /// 根据结构化的数据制作mesh,三角网构造算法还没写好。此函数构造的面连线不正确
        /// </summary>
        /// <param name="geoModel"></param>
        /// <param name="vPDic">顶点集合</param>
        /// <param name="vPIndex">索引列表</param>
        public static void MakeMesh(this GeoModel geoModel, Dictionary <int, Vertice> vPDic, List <Index> vPIndex)
        {
            #region 输出结构化数据到顺序数组
            double[] Vertices = new double[vPIndex.Count * 3 * 3];//由于顶点被按照索引展开,这里需要额外的空间。
            Int32[]  Indexes  = new Int32[vPIndex.Count * 3];
            double[] Normals  = new double[Vertices.Length];

            int j = 0;
            for (int i = 0; i < Indexes.Length; i++)
            {
                Indexes[i] = i;//顺序写入索引,之后的点序列按照这个索引展开
            }
            foreach (Index index in vPIndex)
            {
                //这里又产生了重复数据,我不知道要怎么再不产生重复的基础上写入数组
                #region 依赖索引list写入顶点数组,此过程多次索引的顶点被展开了
                Vertices[j]     = vPDic[index.P1].X; Vertices[j + 1] = vPDic[index.P1].Y; Vertices[j + 2] = vPDic[index.P1].Z;
                Vertices[j + 3] = vPDic[index.P2].X; Vertices[j + 4] = vPDic[index.P2].Y; Vertices[j + 5] = vPDic[index.P2].Z;
                Vertices[j + 6] = vPDic[index.P3].X; Vertices[j + 7] = vPDic[index.P3].Y; Vertices[j + 8] = vPDic[index.P3].Z;
                #endregion

                #region 计算法向量
                geoModel.CalculateNormals(ref vPDic, vPIndex);
                #endregion

                #region 写入法向量
                Normals[j / 9]       = vPDic[index.P1].Normal.X;
                Normals[(j / 9) + 1] = vPDic[index.P1].Normal.Y;
                Normals[(j / 9) + 2] = vPDic[index.P1].Normal.Z;

                Normals[(j / 9) + 3] = vPDic[index.P2].Normal.X;
                Normals[(j / 9) + 4] = vPDic[index.P2].Normal.Y;
                Normals[(j / 9) + 5] = vPDic[index.P2].Normal.Z;

                Normals[(j / 9) + 6] = vPDic[index.P3].Normal.X;
                Normals[(j / 9) + 7] = vPDic[index.P3].Normal.Y;
                Normals[(j / 9) + 8] = vPDic[index.P3].Normal.Z;

                #endregion

                j += 9;
            }
            #endregion
            Mesh mesh = new Mesh();
            mesh.Vertices = Vertices;
            mesh.Indexes  = Indexes;
            mesh.Normals  = Normals;

            geoModel.Meshes.Clear();

            geoModel.Meshes.Add(mesh);
        }
Пример #20
0
        public ActionResult Save()
        {
            GeoModel geo = new GeoModel();

            geo = ObjectUtil.Eval(geo, Request.Params, "", "");
            if (string.IsNullOrEmpty(geo.id))
            {
                geo.id = geo.createPk().ToString();
            }
            JsResultObject result = BaseZdBiz.SaveOrUpdate(geo, "地理信息");

            return(JsonText(result, JsonRequestBehavior.AllowGet));
        }
Пример #21
0
        //关闭对话框
        private void DlgNodeAnimation_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.cb_Model.Items.Clear();
            this.m_sceneControl.Scene.TrackingLayer.Clear();
            m_nodeAnimation.TimePositionChanged -= new TimePositionChangedEventHandler(m_nodeAnimationTimePositionChanged);
            m_sceneControl.Tracked   -= new Tracked3DEventHandler(m_sceneControl_Tracked);
            m_nodeAnimation.IsEnabled = false;

            m_geoLine3D               = null;
            m_style3D                 = null;
            m_nodeAnimation           = null;
            m_geoModel                = null;
            this.btn_AddToKML.Enabled = false;
        }
Пример #22
0
        internal void DrawBloom(GeoModel quad, ref Matrix4 mvp, int bloomTexture, float step)
        {
            GL.UniformMatrix4(mUniform_MVP, false, ref mvp);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bloomTexture);
            GL.Uniform1(mUniform_TextureBloom, 0);

            GL.BindVertexArray(quad.Meshes.Values.ElementAt(0).VAO);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, quad.Meshes.Values.ElementAt(0).VBOIndex);
            GL.DrawElements(quad.Meshes.Values.ElementAt(0).Primitive, quad.Meshes.Values.ElementAt(0).IndexCount, DrawElementsType.UnsignedInt, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            GL.BindVertexArray(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Пример #23
0
        public static string GetPathClHotel(GeoModel geo, GeoLocationModel geoCl)
        {
            string pattern  = "{0}{1}";
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ZDSL.Webapp.path.Hotel.Cl"];

            filePath = string.Format(filePath, geo.cityCode, geoCl.locationId);
            if (IsDebug())
            {
                return(string.Format(pattern, WebUtil.GetWebRootPath(), "/Public/Hotel/Search?cityName=" + geo.cityName + "&geoClId=" + geoCl.locationId));
            }
            else
            {
                return(string.Format(pattern, WebUtil.GetWebRootPath(), filePath));
            }
        }
Пример #24
0
 public static void OffsetModel(this GeoModel geoModel, Point3D p)
 {
     foreach (Mesh m in geoModel.Meshes)
     {
         int      length   = m.Vertices.Length;
         double[] Vertices = m.Vertices;
         for (int i = 0; i < length - 2; i += 3)
         {
             Vertices[i]     += p.X;
             Vertices[i + 1] += p.Y;
             Vertices[i + 2] += p.Z;
         }
         m.Vertices = Vertices;
     }
 }
Пример #25
0
        private void updateMask(GeoModel model, GeoCell cell)
        {
            short nswe = cell.getNSWE();

            if ((nswe & GEO.NSWE_ALL) == GEO.NSWE_ALL)
            {
                model.Mask = Vector4.Zero;
            }
            else
            {
                model.Mask.X = ((nswe & GEO.NORTH) == GEO.NORTH ? 0f : 1f);
                model.Mask.Y = ((nswe & GEO.EAST) == GEO.EAST  ? 0f : 1f);
                model.Mask.Z = ((nswe & GEO.SOUTH) == GEO.SOUTH ? 0f : 1f);
                model.Mask.W = ((nswe & GEO.WEST) == GEO.WEST  ? 0f : 1f);
            }
        }
Пример #26
0
        public void ImportGeoList()
        {
            IList <ELongGeoAdapter> Geos = ELongStaticClient.GetGeoList();

            this.OpenSession();
            ITransaction tx = this.session.BeginTransaction();

            foreach (ELongGeoAdapter geo in Geos)
            {
                GeoModel temp = new GeoModel();
                temp.from(geo);
                System.Console.WriteLine(string.Format("{0}:{1}:{2}:{3}", temp.id, temp.provinceName, temp.cityName, temp.url));
                this.session.SaveOrUpdate(temp);
            }
            tx.Commit();
        }
Пример #27
0
        // GET: api/Geos
        public IHttpActionResult GetGeos()
        {
            var             location  = db.Geos;
            List <GeoModel> geomodels = new List <GeoModel>();

            foreach (var item in location)
            {
                GeoModel model = new GeoModel();
                model.Latitude  = (double)item.Location.Latitude;
                model.Longitude = (double)item.Location.Longitude;
                model.Id        = item.Id;
                model.Address   = item.Address;
                geomodels.Add(model);
            }
            return(Ok(geomodels));
        }
Пример #28
0
        private GeoModel appendModel(float x, float y, float z, bool is_large)
        {
            float size_xz = (is_large ? 8f * GeoScene.BLOCK_SIZE : GeoScene.BLOCK_SIZE);
            //
            GeoModel i = new GeoModel();

            i.IsLarge    = is_large;
            i.Position.X = x;
            i.Position.Y = y;
            i.Position.Z = z;
            i.SetBounds(size_xz, GeoScene.BLOCK_SIZE, size_xz);
            i.UpdateWorld();
            models.Add(i);
            //
            vis_tree.InsertTree(i);
            return(i);
        }
Пример #29
0
        private async void PostGeoData(Location location)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                GeoModel model = new GeoModel
                {
                    gps_time = DateTime.Now,
                    lat      = location.Latitude.ToString().Replace(",", "."),
                    lng      = location.Longitude.ToString().Replace(",", ".")
                };

                DriverInfoService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await DriverInfoService.PostGeoData(model);

                Toast.MakeText(Application.Context, o_data.Message, ToastLength.Long).Show();
            }
        }
Пример #30
0
 public static NodeBinder Bind(ModelBuilder builder, GeoModel node)
 {
     if (null != (object)builder)
     {
         var nb = new NodeBinder
         {
             builder = builder,
             Restore = System.Threading.Interlocked.Exchange(ref builder.geoModel, node),
             Replace = node,
         };
         nb.NeedDispose = nb.Restore != nb.Replace;
         if (nb.NeedDispose)
         {
             return(nb);
         }
     }
     return(default(NodeBinder));
 }
Пример #31
0
        public ActionResult Search(string cityName, string keyWord, string geoClId, string geoDId, DateTime?checkInDate)
        {
            PublicBiz      publicBiz = PublicBiz.GetInstant();
            FrontPageModel frontPage = publicBiz.getCurFrontPage();
            GeoBiz         geoBiz    = GeoBiz.GetInstant();
            GeoModel       geo       = geoBiz.GetGeoByCityName(cityName);

            this.VdGeoLocation(geo);
            GeoLocationModel geoLocation = null;
            PageSeoModel     seo         = PublicBiz.getCurPageSeo();

            this.setPageDesc(string.Format(seo.cityDesc, geo.cityCode, geo.cityName));
            this.setPageKeyWords(string.Format(seo.cityKeywords, geo.cityCode, geo.cityName));
            if (!string.IsNullOrEmpty(geoClId))
            {
                geoLocation = BaseZdBiz.Load <GeoCommercialLocationModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoClId));
                this.setPageDesc(string.Format(seo.cityClDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
                this.setPageKeyWords(string.Format(seo.cityClKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
            }
            else if (!string.IsNullOrEmpty(geoDId))
            {
                geoLocation = BaseZdBiz.Load <GeoDistrictsModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoDId));
                this.setPageDesc(string.Format(seo.cityDDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
                this.setPageKeyWords(string.Format(seo.cityDKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name));
            }
            else if (!string.IsNullOrEmpty(keyWord))
            {
                this.setPageDesc(string.Format(seo.hotelSearchDesc, cityName, keyWord, (checkInDate ?? DateTime.Now).ToShortDateString()));

                this.setPageKeyWords(string.Format(seo.hotelSearchKeywords, cityName, keyWord, (checkInDate ?? DateTime.Now).ToShortDateString()));
            }
            ViewData[typeof(GeoLocationModel).Name] = geoLocation;

            ICriteria icr = BaseZdBiz.CreateCriteria <BrandModel>();

            string[] brandNames = frontPage.searchBrandNameArray.Split(',');
            icr.Add(Restrictions.In("brandName", brandNames));
            IList <BrandModel> brands = icr.List <BrandModel>();

            ViewData[typeof(BrandModel).Name] = brands;
            this.VdHotCity(15);
            return(View());
        }
Пример #32
0
        public void run()
        {
            Recordset rc = dv.GetRecordset(false, CursorType.Dynamic);

            Dictionary<int, Feature> feas = rc.GetAllFeatures();

            foreach (KeyValuePair<int, Feature> item in feas)
            {
                GeoModel gm = item.Value.GetGeometry() as GeoModel;
                Console.WriteLine("==" + gm.Position + "==");

                GeoModel model = new GeoModel();
                model.Position = gm.Position;
                foreach (Mesh m in gm.Meshes)
                {
                    if (m.Material.TextureFile.Length > 1)
                    {
                        //Console.WriteLine(m.Material.TextureFile.ToString());
                        Point3Ds p3ds = new Point3Ds();

                        for (int i = 0; i < m.Vertices.Length; i += 3)
                        {
                            bool repition = false;
                            foreach (Point3D p in p3ds)
                            {
                                if (p.X == m.Vertices[i] && p.Y == m.Vertices[i + 1] && p.Z == m.Vertices[i + 2])
                                {
                                    repition = true;
                                }
                            }
                            if (!repition)
                            {
                                p3ds.Add(new Point3D(m.Vertices[i], m.Vertices[i + 1], m.Vertices[i + 2]));

                            }
                        }

                        foreach (Point3D p3d in p3ds)
                        {
                            Console.WriteLine(string.Format(" {0},{1},{2}", p3d.X, p3d.Y, p3d.Z));
                            scene.TrackingLayer.Add(new GeoPoint3D(p3d.X, p3d.Y, p3d.Z), "");
                        }
                        //model.Meshes.Add(MakeMeshPot(p3ds));
                        Mesh mesh = new Mesh(m);
                        mesh.Material.TextureFile = @".\78310a55b319ebc41f7810198326cffc1e171629.png";
                        model.Meshes.Add(mesh);

                        #region 写属性表
                        Dictionary<string, double> fields = new Dictionary<string, double>();
                        fields.Add("FaceMeshCenterX", model.Position.X);
                        fields.Add("FaceMeshCenterY", model.Position.Y);
                        fields.Add("FaceMeshCenterZ", model.Position.Z);
                        fields.Add("FaceMeshLx", p3ds.leftbottom().X);
                        fields.Add("FaceMeshLy", p3ds.leftbottom().Y);
                        fields.Add("FaceMeshLz", p3ds.leftbottom().Z);
                        fields.Add("FaceMeshUx", p3ds.rightup().X);
                        fields.Add("FaceMeshUy", p3ds.rightup().Y);
                        fields.Add("FaceMeshUz", p3ds.rightup().Z);

                        foreach (KeyValuePair<string, double> field in fields)
                        {
                            if (dv.FieldInfos.IndexOf(field.Key) < 0)
                            {
                                FieldInfo fieldInf = new FieldInfo(field.Key, FieldType.Double);
                                dv.FieldInfos.Add(fieldInf);
                            }

                            string fieldName = field.Key;
                            double fieldValue = field.Value;
                            try
                            {
                                rc.SeekID(item.Value.GetID());
                                rc.Edit();
                                rc.SetFieldValue(fieldName, fieldValue);
                                rc.Update();
                            }
                            catch
                            {
                                Console.WriteLine("error!");
                            }
                            //Console.WriteLine(string.Format("{0},{1},{2}", item.GetID(), fieldName, fieldValue));
                        }
                        #endregion
                    }
                }
                Console.WriteLine("");

                model.ComputeBoundingBox();
                scene.TrackingLayer.Add(model, gm.Position.ToString());
                scene.Refresh();
            }
        }