Beispiel #1
0
 private void LoadPeople(IDynamicObject dynamicObject)
 {
     if (skinMesh == null)
     {
         // 构造ModelPoint
         mp = geoFac.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
         string modelName = (strMediaPath + @"\x\Character\QiYeYuanGong.X");
         mp.ModelName  = modelName;
         mp.SpatialCRS = dataset_Road.SpatialReference;
         // 设置位置
         IMatrix matrix = new Matrix();
         matrix.MakeIdentity();
         IPoint startPoint = null;
         double speed      = 0.0;
         dynamicObject.GetWaypoint2(0, out startPoint, out speed);
         matrix.SetTranslate(startPoint.Position);
         mp.FromMatrix(matrix);
         mp.SelfScale(5, 5, 5);
         // 创建骨骼动画
         skinMesh = this.axRenderControl1.ObjectManager.CreateSkinnedMesh(mp, rootId);
         if (skinMesh == null)
         {
             MessageBox.Show("骨骼动画创建失败!");
             return;
         }
         skinMesh.Loop = true;
         skinMesh.Play();
         skinMesh.MaxVisibleDistance = 10000;
         skinMesh.ViewingDistance    = 100;
         // 绑定到运动路径
         IMotionable m = skinMesh as IMotionable;
         pos.Set(0, 0, 0);
         m.Bind2(dynamicObject, pos, 0, 0, 0);
     }
 }
Beispiel #2
0
        private void ToolStripMenuItemCreateComplexParticleEffect_Click(object sender, EventArgs e)
        {
            IComplexParticleEffect p = this.axRenderControl1.ObjectManager.CreateComplexParticleEffect(gviComplexParticleEffectType.gviComplexParticleEffectFire_3, selectedId);

            p.ScalingFactor = 5;
            p.Name          = "粒子火Fire_0";

            IPoint pos = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ) as IPoint;

            pos.SetCoords(fireX, fireY, fireZ, 0, 0);
            p.Position = pos;
            this.axRenderControl1.Camera.FlyToObject(p.Guid, gviActionCode.gviActionFlyTo);

            TreeNode node = new TreeNode("粒子火Fire_0", 1, 1);

            node.Tag     = p.Guid;
            node.Checked = true;
            selectedNode.Nodes.Add(node);
            this.treeView1.UpdateView();

            //this.axRenderControl1.InteractMode = gviInteractMode.gviInteractSelect;
            //this.axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectParticleEffect;
            //this.axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick;

            //this.axRenderControl1.RcMouseClickSelect += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            if (motionPath != null)
            {
                IMotionable m = p as IMotionable;
                position.Set(0, 0, 0);
                m.Bind(motionPath, position, 0, 45, 90);
                motionPath.Play();
                this.axRenderControl1.Camera.FlyToObject(p.Guid, gviActionCode.gviActionFollowBehindAndAbove);
            }
        }
Beispiel #3
0
        private void LoadPlane()
        {
            // 加载直升飞机
            string fileName = (strMediaPath + @"\x\Vehicles\wrj.X");

            if (skinMeshPlane == null)
            {
                // 构造ModelPoint
                IGeometryFactory gf = new GeometryFactory();
                IModelPoint      mp = gf.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                mp.ModelName  = fileName;
                mp.SpatialCRS = new CRSFactory().CreateFromWKT(wkt) as ISpatialCRS;
                // 设置位置
                IMatrix matrix = new Matrix();
                matrix.MakeIdentity();
                matrix.SetTranslate(line.GetPoint(0).Position);
                mp.FromMatrix(matrix);
                // 创建骨骼动画
                skinMeshPlane = this.axRenderControl1.ObjectManager.CreateSkinnedMesh(mp, rootId);
                if (skinMeshPlane == null)
                {
                    MessageBox.Show("骨骼动画创建失败!");
                    return;
                }
                skinMeshPlane.Loop = true;
                skinMeshPlane.Play();
                skinMeshPlane.MaxVisibleDistance = 1000;
                skinMeshPlane.ViewingDistance    = 100;

                // 绑定到运动路径
                IMotionable m = skinMeshPlane as IMotionable;
                position.Set(0, 0, 0);
                m.Bind2(dynamicObject, position, 0, 0, 0);
            }
        }
Beispiel #4
0
 private void LoadCar(IDynamicObject dynamicObject)
 {
     if (renderModelPoint == null)
     {
         // 构造ModelPoint
         mp = geoFac.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
         string modelName = (strMediaPath + @"\osg\Vehicles\Car\TCJ006.osg");
         mp.ModelName  = modelName;
         mp.SpatialCRS = dataset_Road.SpatialReference;
         // 设置位置
         IMatrix matrix = new Matrix();
         matrix.MakeIdentity();
         IPoint startPoint = null;
         double speed      = 0.0;
         dynamicObject.GetWaypoint2(0, out startPoint, out speed);
         matrix.SetTranslate(startPoint.Position);
         mp.FromMatrix(matrix);
         mp.SelfScale(0.05, 0.05, 0.05);
         // 创建骨骼动画
         renderModelPoint = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
         renderModelPoint.MaxVisibleDistance = 10000;
         renderModelPoint.ViewingDistance    = 200;
         // 绑定到运动路径
         IMotionable m = renderModelPoint as IMotionable;
         pos.Set(0, 0, 0);
         m.Bind2(dynamicObject, pos, 90, 0, 0);
     }
 }
Beispiel #5
0
        private void LoadTableLabel()
        {
            dynamicTableLabel = this.axRenderControl1.ObjectManager.CreateTableLabel(3, 2, rootId);

            dynamicTableLabel.TitleText = "直升机当前位置";
            dynamicTableLabel.SetRecord(0, 0, "X:");
            dynamicTableLabel.SetRecord(0, 1, line.GetPoint(0).X.ToString());
            dynamicTableLabel.SetRecord(1, 0, "Y:");
            dynamicTableLabel.SetRecord(1, 1, line.GetPoint(0).Y.ToString());
            dynamicTableLabel.SetRecord(2, 0, "Z:");
            dynamicTableLabel.SetRecord(2, 1, line.GetPoint(0).Z.ToString());

            dynamicTableLabel.Position = line.GetPoint(0);

            dynamicTableLabel.BorderColor          = System.Drawing.Color.FromArgb(255, 255, 255, 255);
            dynamicTableLabel.BorderWidth          = 2;
            dynamicTableLabel.TableBackgroundColor = System.Drawing.Color.FromArgb(200, 255, 255, 165);
            dynamicTableLabel.TitleBackgroundColor = System.Drawing.Color.FromArgb(180, 122, 122, 122);

            // 第一列文本样式
            TextAttribute headerTextAttribute = new TextAttribute();

            headerTextAttribute.TextColor              = System.Drawing.Color.FromArgb(120, 127, 64, 0);
            headerTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            headerTextAttribute.Font                   = "细黑";
            headerTextAttribute.Bold                   = true;
            headerTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(0, headerTextAttribute);

            // 第二列文本样式
            TextAttribute contentTextAttribute = new TextAttribute();

            contentTextAttribute.TextColor              = System.Drawing.Color.Black;
            contentTextAttribute.OutlineColor           = System.Drawing.Color.FromArgb(125, 255, 127, 64);
            contentTextAttribute.Font                   = "黑体";
            contentTextAttribute.Bold                   = false;
            contentTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(1, contentTextAttribute);

            // 标题文本样式
            TextAttribute capitalTextAttribute = new TextAttribute();

            capitalTextAttribute.TextColor              = System.Drawing.Color.White;
            capitalTextAttribute.OutlineColor           = System.Drawing.Color.Gray;
            capitalTextAttribute.Font                   = "华文新魏";
            capitalTextAttribute.TextSize               = 14;
            capitalTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineCenter;
            capitalTextAttribute.Bold                   = true;
            dynamicTableLabel.TitleTextAttribute        = capitalTextAttribute;

            // 绑定到运动路径
            IMotionable m = dynamicTableLabel as IMotionable;

            position.Set(0, 0, 2);
            m.Bind2(dynamicObject, position, 0, 0, 0);
        }
Beispiel #6
0
        private void LoadParticleEffect()
        {
            if (particleEffect == null)
            {
                particleEffect = this.axRenderControl1.ObjectManager.CreateParticleEffect(rootId);
                string fileName = (strMediaPath + @"\png\water.png");
                particleEffect.ImageName                = fileName;
                particleEffect.EmissionMaxMoveSpeed     = 200;
                particleEffect.EmissionMinMoveSpeed     = 0;
                particleEffect.EmissionMinRate          = 600;
                particleEffect.EmissionMaxRate          = 7300;
                particleEffect.ParticleMaxLifeTime      = 5.5;
                particleEffect.ParticleMinLifeTime      = 1.5;
                particleEffect.ParticleBillboardType    = gviParticleBillboardType.gviParticleBillboardOrientedCamera;
                particleEffect.WindDirection            = 0;
                particleEffect.WindAcceleration         = 0.2;
                particleEffect.ParticleBirthColor       = System.Drawing.Color.White;
                particleEffect.ParticleDeathColor       = System.Drawing.Color.Blue;
                particleEffect.EmissionMinScaleSpeed    = 1;
                particleEffect.EmissionMaxScaleSpeed    = 2;
                particleEffect.VerticalAcceleration     = 0;
                particleEffect.EmissionMaxAngle         = 0.078536816339744828;
                particleEffect.EmissionMinAngle         = 0;
                particleEffect.EmissionMinParticleSize  = 0.2;
                particleEffect.EmissionMaxParticleSize  = 0.6;
                particleEffect.EmissionMinRotationSpeed = 0;
                particleEffect.EmissionMaxRotationSpeed = 0;
                particleEffect.Damping             = 0.5;
                particleEffect.MaxVisibleDistance  = 10000;
                particleEffect.ParticleAspectRatio = 1;
                angle.Set(0, 90, 0);
                particleEffect.EmissionDirectionEulerAngle = angle;
                particleEffect.SetTextureTileRange(0, 0, 0, 0);
                particleEffect.Start(-1);
                particleEffect.MaxVisibleDistance = 10000;

                IPoint pTemp = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                pTemp.SpatialCRS = new CRSFactory().CreateFromWKT(this.axRenderControl1.GetCurrentCrsWKT()) as ISpatialCRS;
                IPoint p = line.GetPoint(0).Clone() as IPoint;
                p.Project(pTemp.SpatialCRS);
                pTemp.SetCoords(p.X, p.Y, p.Z, 0, 0);
                particleEffect.SetPointEmitter(pTemp);

                // 绑定到运动路径
                IMotionable m = particleEffect as IMotionable;
                //position.Set(4.3, -7, 0);
                position.Set(0, 0, 0);
                m.Bind(motionPath, position, 0, 90, 0);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 绑定运动路径
        /// </summary>
        private void BindPath()
        {
            if (renderModelPoint != null && water != null && motionPath != null)
            {
                m = renderModelPoint as IMotionable;
                v3.Set(0, 0, 0);
                m.Bind(motionPath, v3, 0, 0, 0);


                m = water.ParticleEffectObject as IMotionable;
                v3.Set(0, 0, 2.5);
                m.Bind(motionPath, v3, 0, 0, 0);

                m = skinMeshCharacter as IMotionable;
                v3.Set(-10, -7, 0);
                m.Bind(motionPath, v3, 0, 0, 0);
            }
        }
Beispiel #8
0
        private void LoadSkinMeshAndViewshed()
        {
            string fileName = (strMediaPath + @"\x\Character\QiYeYuanGong.X");

            if (skinMesh == null)
            {
                // 构造ModelPoint
                IGeometryFactory gf = new GeometryFactory();
                IModelPoint      mp = gf.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                mp.ModelName  = fileName;
                mp.SpatialCRS = new CRSFactory().CreateFromWKT(wkt) as ISpatialCRS;
                // 设置位置
                IMatrix matrix = new Matrix();
                matrix.MakeIdentity();
                matrix.SetTranslate(line.GetPoint(0).Position);
                mp.FromMatrix(matrix);
                // 创建骨骼动画
                skinMesh = this.axRenderControl1.ObjectManager.CreateSkinnedMesh(mp, rootId);
                if (skinMesh == null)
                {
                    MessageBox.Show("骨骼动画创建失败!");
                    return;
                }
                skinMesh.Loop = true;
                skinMesh.Play();
                skinMesh.MaxVisibleDistance = 1000;
                skinMesh.ViewingDistance    = 50;

                // 绑定到运动路径
                IMotionable m = skinMesh as IMotionable;
                position.Set(0, 0, 0);
                m.Bind2(dynamicObject, position, 0, 0, 0);
                this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehind);
            }

            if (tv == null)
            {
                tv = this.axRenderControl1.ObjectManager.CreateViewshed(line.GetPoint(0), rootId);
                IMotionable tvm = tv as IMotionable;
                position.Set(0, 0, 0);
                tvm.Bind2(dynamicObject, position, 0, 0, 0);
            }
        }
Beispiel #9
0
        private void LoadDynamicTableLabel()
        {
            #region 加载一个标签
            dynamicTableLabel = axRenderControl1.ObjectManager.CreateTableLabel(2, 2, rootId);

            dynamicTableLabel.TitleText = "消防车当前位置";
            dynamicTableLabel.SetRecord(0, 0, "X:");
            dynamicTableLabel.SetRecord(0, 1, firstX.ToString());
            dynamicTableLabel.SetRecord(1, 0, "Y:");
            dynamicTableLabel.SetRecord(1, 1, firstY.ToString());

            position.Set(firstX, firstY, firstZ + 2.4);
            if (fde_point == null)
            {
                fde_point = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            }
            fde_point.Position         = position;
            dynamicTableLabel.Position = fde_point;

            dynamicTableLabel.BorderColor          = System.Drawing.Color.White;
            dynamicTableLabel.BorderWidth          = 2;
            dynamicTableLabel.TableBackgroundColor = System.Drawing.Color.Gray;
            dynamicTableLabel.TitleBackgroundColor = System.Drawing.Color.Red;

            // 表头样式
            TextAttribute headerTextAttribute = new TextAttribute();
            headerTextAttribute.TextColor              = System.Drawing.Color.Black;
            headerTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            headerTextAttribute.Font                   = "黑体";
            headerTextAttribute.Bold                   = true;
            headerTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(0, headerTextAttribute);

            // 内容样式
            TextAttribute contentTextAttribute = new TextAttribute();
            contentTextAttribute.TextColor              = System.Drawing.Color.Black;
            contentTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            contentTextAttribute.Font                   = "黑体";
            contentTextAttribute.Bold                   = false;
            contentTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(1, contentTextAttribute);

            // 标题样式
            TextAttribute capitalTextAttribute = new TextAttribute();
            capitalTextAttribute.TextColor              = System.Drawing.Color.White;
            capitalTextAttribute.OutlineColor           = System.Drawing.Color.Gray;
            capitalTextAttribute.Font                   = "华文新魏";
            capitalTextAttribute.TextSize               = 14;
            capitalTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineCenter;
            capitalTextAttribute.Bold                   = true;
            dynamicTableLabel.TitleTextAttribute        = capitalTextAttribute;

            angle.Set(0, -20, 0);
            axRenderControl1.Camera.LookAt(position, 30, angle);
            #endregion

            #region 加载一个模型
            if (renderModelPoint == null)
            {
                string           modelName  = (strMediaPath + @"\osg\Vehicles\XiaoFangChe\xiaoFangChe3.OSG");
                IGeometryFactory geoFactory = new GeometryFactory();
                IModelPoint      modePoint  = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
                modePoint.ModelName = modelName;
                modePoint.SetCoords(firstX, firstY, firstZ, 0, 0);
                renderModelPoint = axRenderControl1.ObjectManager.CreateRenderModelPoint(modePoint, null, rootId);
            }
            #endregion

            #region 加载一个运动路径
            if (motionPath == null)
            {
                motionPath = axRenderControl1.ObjectManager.CreateMotionPath(rootId);
                // 为MotionPath添加第一个点
                position.Set(firstX, firstY, firstZ);
                angle.Set(firstH, firstP, firstR);
                scale.Set(firstSX, firstSY, firstSZ);
                motionPath.AddWaypoint(position, angle, scale, firtWhen);
                //为MotionPath添加第二个点
                position.Set(secondX, secondY, secondZ);
                angle.Set(secondH, secondP, secondR);
                scale.Set(secondSX, secondSY, secondSZ);
                motionPath.AddWaypoint(position, angle, scale, secondWhen);
                //为MotionPath添加第三个点
                position.Set(thirdX, thirdY, thirdZ);
                angle.Set(thirdH, thirdP, thirdR);
                scale.Set(thirdSX, thirdSY, thirdSZ);
                motionPath.AddWaypoint(position, angle, scale, thirdWhen);
                //为MotionPath添加第四个点
                position.Set(fourthX, fourthY, fourthZ);
                angle.Set(fourthH, fourthP, fourthR);
                scale.Set(fourthSX, fourthSY, fourthSZ);
                motionPath.AddWaypoint(position, angle, scale, fourthWhen);
            }
            #endregion

            #region 将模型和标牌同时绑定在路径上
            m = renderModelPoint as IMotionable;
            //将模型绑定到路径上

            v3.Set(0, 0, 0);
            m.Bind(motionPath, v3, 0, 0, 0);

            // 将标牌绑定到路径上
            if (dynamicTableLabel != null && motionPath != null)
            {
                m = dynamicTableLabel as IMotionable;
                v3.Set(0, 0, 6);
                m.Bind(motionPath, v3, 0, 0, 0);
            }
            #endregion
        }