コード例 #1
0
        //粒子系统
        private void btn_Particle_Click(object sender, EventArgs e)
        {
            if (_glbControl.Globe.Ocean.Visible)
            {
                btn_Ocean.PerformClick();
            }

            GSORectParticleEmitter emitter = new GSORectParticleEmitter();

            //设置粒子初始大小
            emitter.Length = 10;
            emitter.Width  = 20;
            //纹理路径
            emitter.TexturePath = _flarePath;
            //每秒喷射数量,每秒两个
            emitter.EmitPerSec = 3;
            //重力加速度
            emitter.GravityAcc = 8.9f;

            //场景中最大粒子数量,30个
            emitter.MaxCount = 30;
            //初始粒子个数
            emitter.InitCount = 20;

            //开始时间,从Play时开始(好像不管用)
            emitter.StartEmitTime = 30;
            //喷射持续时间  秒,默认负数,表示不限制
            emitter.EndEmitTime = 50;

            //粒子存活时间 秒
            emitter.LifeFix = 1;
            //粒子生命值变化范围(随机生命)
            emitter.LifeRnd = 10;

            //发射速度 米/s
            emitter.VelFix = 100;
            //发射速度变化范围
            emitter.VelRnd = 10;

            //粒子初始旋转角度 度
            emitter.RotFix = 1;
            //粒子初始旋转角度变化范围
            emitter.RotRnd = 10;

            //粒子旋转速度 度/s
            emitter.RotVelFix = -180;
            //粒子旋转速度变化范围
            emitter.RotVelRnd = 0;

            //粒子初始化大小倍数
            emitter.SizeFix = new GSOPoint2d(10, 10);
            //粒子初始化大小倍数变化范围
            emitter.SizeRnd = new GSOPoint2d(1, 1);

            //发射器方向角
            emitter.AngleXYFix = 90;
            //发射器方向角变化范围,可以理解为XY范围值
            emitter.AngleXYRnd = 0;

            //发射器高度角
            emitter.AngleXZFix = 45;
            //发射器高度角变化范围,可以理解为XZ范围值
            emitter.AngleXZRnd = 45;

            //粒子颜色变化初始值
            emitter.ColorRndStart = Color.AliceBlue;
            //粒子颜色变化终止值
            emitter.ColorRndEnd = Color.Gray;

            //亮度是否叠加
            emitter.IsLumAdded = true;
            //是否独立于发射器
            emitter.IsParticleIndepend = false;

            GSOScaleParticleEffector scaleEffect = new GSOScaleParticleEffector();

            //设定变化值(相对初始化值X,Y值增加10倍)
            scaleEffect.SetScale(10, 10);
            //开始/结束生效的时间的类型,相对出生时间、百分比,还是相对死亡的时间、百分比,默认是相对出生的时间(秒)
            scaleEffect.StartTimeType = EnumEffectorTimeType.FromBornSeconds;
            scaleEffect.EndTimeType   = EnumEffectorTimeType.FromBornSeconds;
            scaleEffect.StartTime     = 1;
            scaleEffect.EndTime       = 5;
            //添加效果
            emitter.AddEffector(scaleEffect);

            //创建粒子场景要素
            GSOGeoParticle geoParticle = new GSOGeoParticle();

            //设置场景位置
            geoParticle.SetPosition(_glbControl.Globe.CameraState.Longitude, _glbControl.Globe.CameraState.Latitude, 0);
            //将发射器添加到粒子场景要素中
            geoParticle.AddEmitter(emitter);
            //播放
            geoParticle.Play();

            //创建要素
            GSOFeature feature = new GSOFeature();

            feature.Geometry = geoParticle;
            //添加要素
            _glbControl.Globe.MemoryLayer.AddFeature(feature);
            _glbControl.Globe.JumpToFeature(feature, 100);
        }
コード例 #2
0
ファイル: MainFrm.cs プロジェクト: StarU/qkKL6Dgf12
        //烟火
        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;
        }
コード例 #3
0
        //火
        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);
        }