Exemplo n.º 1
0
        // 烟花
        private GSOFeature AddFireSpark()
        {
            // 烟火示例

            string strResPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource";

            //  烟火粒子示例,由三个发射器构成
            GSOGeoParticle geoParticle = new GSOGeoParticle();
            geoParticle.SetPosition(116.312, 39.84, 200); // 添加到这个经纬度位置
            geoParticle.AltitudeMode = EnumAltitudeMode.RelativeToGround;

            GSORingParticleEmitter emitter = new GSORingParticleEmitter();
            emitter.TexturePath = strResPath + "/ParticleImage/flare3.png";

            emitter.SetSizeFix(8, 8);
            emitter.VelFix = 70;
            emitter.AccFix = -2.0f;
            emitter.GravityAcc = 9.8f; // 重力加速度
            emitter.AngleXYFix = 0;
            emitter.AngleXYRnd = 180;

            emitter.AngleXZFix = 0;
            emitter.AngleXZRnd = 90;

            emitter.LifeFix = 5.0f;
            emitter.LifeRnd = 0.0f;

            emitter.EmitPerSec = 99999;
            emitter.MaxCount = 300;

            // 采用线性插值生成粒子的初始颜色
            emitter.ColorRndStart = Color.White;
            emitter.ColorRndEnd = Color.Red;

            emitter.IsLumAdded = true; // 例子颜色亮度叠加

            GSOIncreaseSizeParticleEffector effector1 = new GSOIncreaseSizeParticleEffector();
            effector1.SetIncreasePerSecond(-2, -2);
            effector1.StartTime = 0;
            effector1.EndTime = -1; // 负数表示整个粒子生命结束

            // 添加效果器
            emitter.AddEffector(effector1);

            GSOColorParticleEffector effector2 = new GSOColorParticleEffector();
            effector2.SetColorChanged(0, 0, 0, -1);
            effector2.StartTime = 0.8f;
            effector2.EndTime = 1.5f;
            emitter.AddEffector(effector2);

            // 将三个发射器添加到粒子对象中
            geoParticle.AddEmitter(emitter);

            geoParticle.Play();
            GSOFeature feature = new GSOFeature();
            feature.Geometry = geoParticle;
            globeControl1.Globe.FlyToFeature(feature);

            return feature;
        }
Exemplo n.º 2
0
        // 添加火苗
        private GSOFeature AddFire()
        {
            // 烟火示例
            string strResPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource";

            //  烟火粒子示例,由三个发射器构成
            GSOGeoParticle geoParticle = new GSOGeoParticle();
            geoParticle.SetPosition(116.313, 39.84, 200); // 添加到这个经纬度位置
            geoParticle.AltitudeMode = EnumAltitudeMode.RelativeToGround;

            GSORingParticleEmitter emitter = new GSORingParticleEmitter();
            emitter.TexturePath = strResPath + "/ParticleImage/flare.png";

            emitter.SetSizeFix(8, 8);
            emitter.VelFix = 25;
            emitter.VelRnd = 20;

            emitter.AngleXYFix = 0;
            emitter.AngleXYRnd = 180;

            emitter.AngleXZFix = 90;
            emitter.AngleXZRnd = 0;

            emitter.LifeFix = 0.5f;
            emitter.LifeRnd = 0.0f;

            emitter.RotFix = 0;
            emitter.RotRnd = 0;

            emitter.RotVelFix = 0;
            emitter.RotVelRnd = 0;

            emitter.EmitPerSec = 100;

            // 采用线性插值生成粒子的初始颜色
            emitter.ColorRndStart = Color.White;
            emitter.ColorRndEnd = Color.Red;

            GSOColorParticleEffector effector2 = new GSOColorParticleEffector();
            effector2.SetColorChanged(0, -1, -1, 0);
            effector2.StartTime = 0.0f;
            effector2.EndTime = -1.0f;
            emitter.AddEffector(effector2);

            // 将三个发射器添加到粒子对象中
            geoParticle.AddEmitter(emitter);

            geoParticle.Play();
            GSOFeature feature = new GSOFeature();
            feature.Geometry = geoParticle;
            globeControl1.Globe.FlyToFeature(feature);

            return feature;
        }
Exemplo n.º 3
0
        //烟火
        private GSOFeature AddFireSmoke()
        {
            // 烟火示例
            string strResPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource";

            //  烟火粒子示例,由三个发射器构成
            GSOGeoParticle geoParticle = new GSOGeoParticle();
            geoParticle.SetPosition(116.31, 39.84, 0); // 添加到这个经纬度位置

            GSORingParticleEmitter emitter = new GSORingParticleEmitter();
            emitter.TexturePath = strResPath + "/ParticleImage/烟1111111111111.png";

            emitter.SetSizeFix(20, 20); //20,20
            emitter.VelFix = 70; //70
            emitter.AccFix = -3.0f; //-0.3f
            emitter.AngleXYFix = 0;
            emitter.AngleXYRnd = 180;

            emitter.AngleXZFix = 85;
            emitter.AngleXZRnd = 5;

            emitter.InnerRadius = 0;
            emitter.OuterRadius = 30;

            emitter.LifeFix = 2.0f;
            emitter.LifeRnd = 1.0f;

            emitter.RotFix = 0;
            emitter.RotRnd = 10;

            emitter.RotVelFix = 0;
            emitter.RotVelRnd = 180;

            emitter.EmitPerSec = 60;
            emitter.ColorRndStart = Color.Black;
            emitter.ColorRndEnd = Color.Black;

            emitter.IsLumAdded = false;

            GSOScaleParticleEffector effector1 = new GSOScaleParticleEffector();
            effector1.SetScale(4, 4);  //4,4
            effector1.StartTime = 0;
            effector1.EndTime = 1.8f;

            // 添加效果器
            emitter.AddEffector(effector1);

            GSOColorParticleEffector effector2 = new GSOColorParticleEffector();
            effector2.SetColorChanged(0.6f, 0.6f, 0.6f, 0);
            effector2.StartTime = 0;
            effector2.EndTime = -1; // 负数表示整个粒子生命结束

            emitter.AddEffector(effector2);

            GSOColorParticleEffector effector3 = new GSOColorParticleEffector();
            effector3.SetColorChanged(0, 0, 0, -1);
            effector3.StartTime = 0.5f;
            effector3.StartTimeType = EnumEffectorTimeType.ToDeadSeconds; // 距离粒子生命结束0.5秒
            effector3.EndTime = 0;
            effector3.EndTimeType = EnumEffectorTimeType.ToDeadSeconds; // 距离粒子生命结束0秒

            emitter.AddEffector(effector3);

            GSORingParticleEmitter emitter2 = new GSORingParticleEmitter();

            emitter2.TexturePath = strResPath + "/ParticleImage/fire_final_2.png";

            emitter2.SetSizeFix(8, 8); //8,8
            emitter2.VelFix = 30;    //30

            emitter2.GravityAcc = -3.0f; // 重力加速度 -3.0

            emitter2.AngleXYFix = 0;
            emitter2.AngleXYRnd = 180;

            emitter2.AngleXZFix = 90;
            emitter2.AngleXZRnd = 5;

            emitter2.InnerRadius = 0;
            emitter2.OuterRadius = 30; //30

            emitter2.LifeFix = 2.0f;
            emitter2.LifeRnd = 0.5f;

            emitter2.RotFix = 0;
            emitter2.RotRnd = 30;

            emitter2.RotVelFix = 0;
            emitter2.RotVelRnd = 60;

            emitter2.EmitPerSec = 300;

            emitter2.ColorRndStart = Color.FromArgb(255, 255, (int)(0.38 * 255), 0);
            emitter2.ColorRndEnd = Color.FromArgb(255, 255, (int)(0.404 * 255), 0);

            GSOColorParticleEffector effector4 = new GSOColorParticleEffector();
            effector4.SetColorChanged(-1, -1, -1, 0);
            effector4.StartTime = 1;
            effector4.StartTimeType = EnumEffectorTimeType.ToDeadSeconds; // 距离粒子生命结束0.5秒
            effector4.EndTime = 0;
            effector4.EndTimeType = EnumEffectorTimeType.ToDeadSeconds; // 距离粒子生命结束0秒
            emitter2.AddEffector(effector4);

            GSORingParticleEmitter emitter3 = (GSORingParticleEmitter)emitter2.Clone();
            emitter3.TexturePath = strResPath + "/ParticleImage/fire_final_1.png";
            emitter3.GravityAcc = -2.0f; // 重力加速度 -2.0f

            // 将三个发射器添加到粒子对象中
            geoParticle.AddEmitter(emitter);
            geoParticle.AddEmitter(emitter2);
            geoParticle.AddEmitter(emitter3);

            geoParticle.Play();
            GSOFeature feature = new GSOFeature();

            feature.Geometry = geoParticle;

            //globeControl1.Globe.MemoryLayer.AddFeature(feature);
            globeControl1.Globe.FlyToFeature(feature);

            return feature;
        }
        //火
        private void btn_Fire_Click(object sender, EventArgs e)
        {
            if (_glbControl.Globe.Ocean.Visible)
            {
                btn_Ocean.PerformClick();
            }

            //烟火粒子示例,由三个发射器构成
            GSOGeoParticle geoParticle = new GSOGeoParticle();

            // 添加到相机当前经纬度位置
            geoParticle.SetPosition(_glbControl.Globe.CameraState.Longitude, _glbControl.Globe.CameraState.Latitude, 0);

            //创建环形烟雾粒子发射器
            GSORingParticleEmitter emitterSmoke = new GSORingParticleEmitter();

            //添加烟雾纹理
            emitterSmoke.TexturePath = _smokePath;
            //设置粒子大小
            emitterSmoke.SetSizeFix(20, 20); //20,20
            //初始速度
            emitterSmoke.VelFix = 70;        //70
            //重力加速度(负值为向上加速)
            emitterSmoke.AccFix = -3.0f;     //-0.3f
            //发射方向为四周,呈圆形
            emitterSmoke.AngleXYFix = 0;
            emitterSmoke.AngleXYRnd = 180;

            //发射高度角为80-90度
            emitterSmoke.AngleXZFix = 85;
            emitterSmoke.AngleXZRnd = 5;
            //内环半径
            emitterSmoke.InnerRadius = 0;
            //外环半径
            emitterSmoke.OuterRadius = 30;
            //生命1-3秒
            emitterSmoke.LifeFix = 2.0f;
            emitterSmoke.LifeRnd = 1.0f;
            //初始旋转角度-10-10度
            emitterSmoke.RotFix = 0;
            emitterSmoke.RotRnd = 10;
            //旋转速度-180-180度/s
            emitterSmoke.RotVelFix = -180;
            emitterSmoke.RotVelRnd = 0;

            //发射速度60个/s
            emitterSmoke.EmitPerSec    = 60;
            emitterSmoke.ColorRndStart = Color.Black;
            emitterSmoke.ColorRndEnd   = Color.Black;

            emitterSmoke.IsLumAdded = false;

            GSOScaleParticleEffector effectorSmokeStart = new GSOScaleParticleEffector();

            effectorSmokeStart.SetScale(4, 4);  //4,4
            effectorSmokeStart.StartTime = 0;
            effectorSmokeStart.EndTime   = 1.8f;
            // 添加效果器
            emitterSmoke.AddEffector(effectorSmokeStart);

            GSOColorParticleEffector effectorSmokeEnd = new GSOColorParticleEffector();

            effectorSmokeEnd.SetColorChanged(0.6f, 0.6f, 0.6f, 0);
            effectorSmokeEnd.StartTime = 0;
            // 负数表示整个粒子生命结束
            effectorSmokeEnd.EndTime = -1;
            emitterSmoke.AddEffector(effectorSmokeEnd);

            GSOColorParticleEffector effector3 = new GSOColorParticleEffector();

            //粒子透明
            effector3.SetColorChanged(0, 0, 0, -1);
            // 距离粒子生命结束0.5秒
            effector3.StartTime     = 0.5f;
            effector3.StartTimeType = EnumEffectorTimeType.ToDeadSeconds;
            // 距离粒子生命结束0秒
            effector3.EndTime     = 0;
            effector3.EndTimeType = EnumEffectorTimeType.ToDeadSeconds;
            emitterSmoke.AddEffector(effector3);

            //火焰2发射器
            GSORingParticleEmitter emitterFire2 = new GSORingParticleEmitter();

            //添加火焰纹理
            emitterFire2.TexturePath = _fire2Path;

            emitterFire2.SetSizeFix(8, 8); //8,8
            emitterFire2.VelFix = 30;      //30

            // 重力加速度 -3.0
            emitterFire2.GravityAcc = -3.0f;

            emitterFire2.AngleXYFix = 0;
            emitterFire2.AngleXYRnd = 180;

            emitterFire2.AngleXZFix = 90;
            emitterFire2.AngleXZRnd = 5;

            emitterFire2.InnerRadius = 0;
            emitterFire2.OuterRadius = 30;

            emitterFire2.LifeFix = 2.0f;
            emitterFire2.LifeRnd = 0.5f;

            emitterFire2.RotFix = 0;
            emitterFire2.RotRnd = 30;

            emitterFire2.RotVelFix = 0;
            emitterFire2.RotVelRnd = 60;

            emitterFire2.EmitPerSec = 300;

            emitterFire2.ColorRndStart = Color.FromArgb(255, 255, (int)(0.38 * 255), 0);
            emitterFire2.ColorRndEnd   = Color.FromArgb(255, 255, (int)(0.404 * 255), 0);

            GSOColorParticleEffector fire2ColoreEffector = new GSOColorParticleEffector();

            fire2ColoreEffector.SetColorChanged(-1, -1, -1, 0);
            // 距离粒子生命结束1秒
            fire2ColoreEffector.StartTime     = 1;
            fire2ColoreEffector.StartTimeType = EnumEffectorTimeType.ToDeadSeconds;
            // 距离粒子生命结束0秒
            fire2ColoreEffector.EndTime     = 0;
            fire2ColoreEffector.EndTimeType = EnumEffectorTimeType.ToDeadSeconds;
            emitterFire2.AddEffector(fire2ColoreEffector);

            //复制火焰2发射器为火焰1发射器
            GSORingParticleEmitter emitterFire1 = (GSORingParticleEmitter)emitterFire2.Clone();

            //修改纹理图片
            emitterFire1.TexturePath = _fire1Path;
            //修改重力加速度为 -2.0f
            emitterFire1.GravityAcc = -2.0f;

            //将三个发射器添加到粒子对象中
            geoParticle.AddEmitter(emitterSmoke);
            geoParticle.AddEmitter(emitterFire2);
            geoParticle.AddEmitter(emitterFire1);

            //播放动画效果
            geoParticle.Play();
            geoParticle.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            //创建要素对象
            GSOFeature feature = new GSOFeature();

            feature.Geometry = geoParticle;

            _glbControl.Globe.MemoryLayer.AddFeature(feature);
            _glbControl.Globe.JumpToFeature(feature, 1000);
        }