2.6.2 粒子特效


粒子特效

粒子特效是指通过使用OpenGl的粒子系统形成的一些特效效果模拟。如雨、雪效果。

粒子系统是指:采用许多形状简单的微小粒子作为基本元素,用它们来表示不规则模糊物体。这些粒子都有各自的生命周期,在系统中都要经历"产生” 、 "运动和生长”及"消亡”三个阶段。因此可以通过粒子系统来模拟一系列动态的效果。

由于粒子系统需要由多种对象组合使用,并且每种对象都有它的特定配置,因此这里只展示一些粒子系统的效果和相关代码。

下图是添加了雨雪和喷泉特效的效果:

  

代码调用示例

Javascript调用

<!--Html代码-->
<object id="VPSDKCtrl" classid="CLSID:A1F1748A-2B6E-4616-954D-3F39B11DF57D" style="width:100%;height:95%"></object>
<select id="select">
<option value="rain"></option>
<option value="snow"></option>
<option value="fountain">喷泉</option>
<option value="fire">火焰</option>
<option value="hydraulicGun">水枪</option>
</select>
<input id="Button0" type="button" value="创建粒子特效图层" onclick="createParticleLayer()" />
<input id="Button1" type="button" value="删除粒子特效图层" onclick="removeParticleLayer()" />
//JS代码
var dataPath = obj.GetSDKPath().substring(0, obj.GetSDKPath().length - 4) + "\\data\\";//sdk data文件夹路径,存放默认文件用
var layerMap = [null, null, null, null, null];
var mySelect = document.getElementById("select");
var transformate = map.CreateTransformation();
var sizeRatio = 1.0;
var rainRatio = 0.5;
var mSize = 1;
var event = null;
var fountainState = false;
var fireState = false;
var hGFirstState = false;
var hGSecondState = false;
var startPos;
var endPos;
var rainscale = 3.0;
//回调实现函数
function callBackFun(x, y){
    if(fountainState){
        createFountain(x + "," + y);
        fountainState = false;
    }
    if(fireState){
        createFire(x + "," + y);
        fireState = false;
    }
    if(hGFirstState){
        startPos = transformate.ScreenPosToWorldPos(x, y);//将屏幕坐标点转换成经纬度坐标
        hGFirstState = false;
        hGSecondState = true;
        alert("请点击下一个点!")
        return;
    }
    if(hGSecondState){
        endPos = transformate.ScreenPosToWorldPos(x, y);//将屏幕坐标点转换成经纬度坐标
        hGSecondState = false;
        createHydraulicGun();
    }
}

//创建粒子特效图层
function createParticleLayer(){
    if(event == null){
        event = addEvent(obj, "FireOnLButtonUp", callBackFun);//返回值用于IE11版本事件移除
    }
    var value = mySelect.options[mySelect.selectedIndex].value;
    switch(value){
        case "rain":
            createRain();break;
        case "snow":
            createSnow();break;
        case "fountain":
            fountainState = true;break;
        case "fire":
            fireState = true;break;
        case "hydraulicGun":{
            if(layerMap[4] == null){
                hGFirstState = true;
            }
            break;
        }
        default:
            break;
    }
}

//删除粒子特效图层
function removeParticleLayer(){
    if(layerMap[mySelect.selectedIndex]){
        map.RemoveLayer(layerMap[mySelect.selectedIndex]);
        layerMap[mySelect.selectedIndex] = null;
    }else{
        alert("图层为空,无法移除!");
    }
    if(event){
        delEvent(obj, "FireOnLButtonUp", callBackFun, event);//返回值用于IE11版本事件移除
        event = null;
    }
}
//创建雨效
function createRain(){
    if(layerMap[0] == null){
        var longlatPos = transformate.ScreenPosToWorldPos(document.body.clientWidth / 2, document.body.clientHeight / 2);//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        clicklonglatPos = longlatPos;
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        ////建粒子渲染类型
        var rainRender = map.CreateParticleRender();
        rainRender.AddConfig("RenderType", "ParticleLineRender");//创建线粒子渲染类型, ParticleLineRender代表线粒子渲染类型
        rainRender.AddConfig("Width", param(1.0, 4.0) * sizeRatio);//线宽(0-10)
        rainRender.AddConfig("Length", "-0.02");//线长
        //// 建立粒子模板 param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        // 第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        // 第二个参数第二部分标识参数具体值
        // 第二个参数第三部分标识差值参数, 竖线(|)分割
        var rainParticleModel = map.CreateParticleModel();
        rainParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        rainParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        rainParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        rainParticleModel.AddConfig("AlphaParam", "0;0.3");
        rainParticleModel.AddConfig("MassParam", "2;" + param(0.4, 0.8) + "," + param(0.8, 1.6));
        /// 非 param 参数
        rainParticleModel.AddConfig("Immortal", "true");//永生参数
        //// 设置粒子区域对象
        var rainZone = map.CreateParticleZone();// 创建发射区区域
        rainZone.AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        rainZone.AddConfig("Radius", "200");// 区域半径
        rainZone.AddConfig("Position", ZonePos.GetX() + "," + ZonePos.GetY() + "," + ZonePos.GetZ())// 区域位置 / 基准位置
        rainZone.AddConfig("AutoPosition", "true");// 自动视野
        rainZone.AddConfig("Position", worldPos.GetX() + "," + worldPos.GetY() + "," + worldPos.GetZ());// 区域位置 / 基准位置
        //// 设置粒子发射器
        var rainEmitter = map.CreateParticleEmitter();//创建发射器
        rainEmitter.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter.AddConfig("Name", "RainEmitter"); //雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        /// 基础参数
        rainEmitter.AddConfig("ParticleZone", rainZone.GetConfig());//配置发射区域
        rainEmitter.AddConfig("Flow", param(0.0, 2000.0 * rainscale));//发射器每秒发射粒子数
        rainEmitter.AddConfig("MinForce", param(5.0, 10.0));//最小推力
        rainEmitter.AddConfig("MaxForce", param(5.0, 10.0));//最大推力
        /// 子类参数
        rainEmitter.AddConfig("Direction", (-1 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (-1 * DirectVec.GetZ()));//发射器方向 0,-1,0   
        rainEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter.AddConfig("MaxAngle", "0.157");//发射器最大偏移角
        //// 设置粒子组
        var rainGroup = map.CreateParticleGroup();//创建粒子组
        rainGroup.AddConfig("Name", "Rain");//粒子名称,与其他类型粒子不能重名
        rainGroup.AddConfig("Capacity", "8000");//粒子组粒子容量
        rainGroup.AddConfig("ParticleRender", rainRender.GetConfig());//配置粒子渲染器
        rainGroup.AddConfig("ParticleModel", rainParticleModel.GetConfig());//配置粒子模板
        rainGroup.AddConfig("ParticleEmitters", rainEmitter.GetConfig());//配置粒子发射器
        rainGroup.AddConfig("Friction", "0.7");//摩擦力系数
        rainGroup.AddConfig("Gravity", (-20 * rainscale * DirectVec.GetX()) + "," + (-20 * rainscale * DirectVec.GetY()) + "," + (-20 * rainscale * DirectVec.GetZ()));//重力方向
        rainGroup.AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        rainGroup.AddConfig("CustomUpdateType", 2);//粒子更新类型
        //rainGroup.AddConfig("CustomParticlePosition", DirectPos.GetX() + "," + DirectPos.GetY() + "," + DirectPos.GetZ());//粒子更新位置
        rainGroup.AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        ///  粒子渲染类型  水花效果
        dropRender = map.CreateParticleRender();//建粒子渲染类型
        dropRender.AddConfig("RenderType", "ParticlePointRender");//创建点粒子渲染类型, ParticlePointRender代表点粒子渲染类型
        dropRender.AddConfig("Size", 2.0 * sizeRatio);//点的大小
        ///  粒子模板
        var dropParticleModel = map.CreateParticleModel();
        dropParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        dropParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        dropParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        dropParticleModel.AddConfig("AlphaParam", "0;0.6");
        dropParticleModel.AddConfig("MassParam", "2;" + param(0.4, 0.8) + "," + param(3.0, 4.0));
        dropParticleModel.AddConfig("MinLifeTime", param(0.05, 0.3));//最小生命周期
        dropParticleModel.AddConfig("MaxLifeTime", param(0.1, 0.5));//最大生命周期
        ///  粒子发射器
        dropEmitter = map.CreateParticleEmitter();
        dropEmitter.AddConfig("EmitterType", "SphericEmitter");//发射器类型
        dropEmitter.AddConfig("Name", "DropEmitter");//发射器名称
        dropEmitter.AddConfig("MinForce", param(0.1, 1.0));//最小推力
        dropEmitter.AddConfig("MaxForce", param(0.2, 2.0));//最大推力
        dropEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射器方向
        dropEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        dropEmitter.AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        ///  设置粒子组
        var dropGroup = map.CreateParticleGroup();
        dropGroup.AddConfig("Name", "Drop");//粒子名称,与其他类型粒子不能重名
        dropGroup.AddConfig("Capacity", "16000");
        dropGroup.AddConfig("ParticleRender", dropRender.GetConfig());
        dropGroup.AddConfig("ParticleModel", dropParticleModel.GetConfig());
        dropGroup.AddConfig("ParticleEmitters", dropEmitter.GetConfig());
        dropGroup.AddConfig("Friction", "0.7");
        dropGroup.AddConfig("Gravity", (-2 * DirectVec.GetX()) + "," + (-2 * DirectVec.GetY()) + "," + (-2 * DirectVec.GetZ()));
        //// 爆炸效果
        ///  粒子渲染类型
        splashRender = map.CreateParticleRender();//建粒子渲染类型
        splashRender.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        splashRender.AddConfig("XScale", "0.1");//X轴缩放比例
        splashRender.AddConfig("YScale", "0.1");//Y轴缩放比例
        splashRender.AddConfig("TextureEnable", "true");//是否启用纹理

        var splashParticleModel = map.CreateParticleModel();
        splashParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        splashParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        splashParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        splashParticleModel.AddConfig("AlphaParam", "1;1.0,0.0");
        splashParticleModel.AddConfig("SizeParam", "3;0,0," + param(0.375, 2.25) + "," + param(0.75, 3.78));//粒子大小
        splashParticleModel.AddConfig("AngleParam", "2;0.0,6.283");//粒子角度 1表示参数随机生成
        splashParticleModel.AddConfig("MinLifeTime", param(0.2, 0.3));
        splashParticleModel.AddConfig("MaxLifeTime", param(0.4, 0.5));

        var splashGroup = map.CreateParticleGroup();
        splashGroup.AddConfig("Name", "Splash");//粒子名称,与其他类型粒子不能重名
        splashGroup.AddConfig("Capacity", "2400");
        splashGroup.AddConfig("ParticleRender", splashRender.GetConfig());
        splashGroup.AddConfig("ParticleModel", splashParticleModel.GetConfig());
        splashGroup.AddConfig("ImageUrl", dataPath + "texture//waterdrops.bmp.dds");//配置纹理
        splashGroup.AddConfig("BlendMode", "770,1,1");//设置混合模式

        //// 设置粒子发射器
        var rainEmitter2 = map.CreateParticleEmitter();//创建发射器
        rainEmitter2.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter2.AddConfig("Name", "RainEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        rainEmitter2.AddConfig("MinForce", param(0.1, 1.0));//最小推力
        rainEmitter2.AddConfig("MaxForce", param(0.2, 2.0));//最大推力
        rainEmitter2.AddConfig("Direction", (DirectVec.GetX()) + "," + (DirectVec.GetY()) + "," + (DirectVec.GetZ()));//发射器方向 0,-1,0   
        rainEmitter2.AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter2.AddConfig("MaxAngle", "0.628");//发射器最大偏移角

        var tlo = map.CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticleGroups", rainGroup.GetConfig() + dropGroup.GetConfig() + splashGroup.GetConfig());//配置粒子组
        tlo.AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo.AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo.AddConfig("CustomUpdateEmitter", rainEmitter2.GetConfig());//更新中使用的发射器
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + longlatPos.GetZ());//粒子图层坐标(经纬度)
        var particleRainLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[0] = particleRainLayer;
        particleRainLayer.AddObserver();
        map.AddLayer(particleRainLayer);//添加粒子图层  
    }else{
        alert("图层已存在,请勿重复创建!");
    }
}
//创建雪效
function createSnow(){
    if(layerMap[1] == null){
        var longlatPos = transformate.ScreenPosToWorldPos(document.body.clientWidth / 2, document.body.clientHeight / 2);// 将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);// 经纬度转场景坐标
        clicklonglatPos = longlatPos;
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        ////建粒子渲染类型
        var snowRender = map.CreateParticleRender();
        snowRender.AddConfig("RenderType", "ParticleQuadRender");                                                    
        snowRender.AddConfig("XScale", 1.0);                                                                    
        snowRender.AddConfig("YScale", 1.0);                                                                    
        snowRender.AddConfig("TextureEnable", "true");                                                            
        snowRender.AddConfig("AtlasDimensionX",2);
        snowRender.AddConfig("AtlasDimensionY",2);
        //// 建立粒子模板
        /// param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        // 第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        // 第二个参数第二部分标识参数具体值
        // 第二个参数第三部分标识差值参数, 竖线(|)分割
        var snowParticleModel = map.CreateParticleModel();
        snowParticleModel.AddConfig("RedParam", "0;1");
        snowParticleModel.AddConfig("GreenParam", "0;1");
        snowParticleModel.AddConfig("BlueParam", "0;1");
        snowParticleModel.AddConfig("MassParam", "2;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        snowParticleModel.AddConfig("AlphaParam", "1;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        snowParticleModel.AddConfig("SizeParam", "1;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        ///非 param 参数
        snowParticleModel.AddConfig("Immortal", "true");//永生参数
        //// 设置粒子区域对象
        var snowZone = map.CreateParticleZone();//创建发射区区域
        snowZone.AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        snowZone.AddConfig("Radius", "200");//区域半径
        snowZone.AddConfig("Position", ZonePos.GetX() + "," + ZonePos.GetY() + "," + ZonePos.GetZ());//区域位置 / 基准位置
        snowZone.AddConfig("AutoPosition", "true");//自动视野
        snowZone.AddConfig("Position", worldPos.GetX() + "," + worldPos.GetY() + "," + worldPos.GetZ());//区域位置 / 基准位置


        //// 设置粒子发射器
        var snowEmitter = map.CreateParticleEmitter();//创建发射器
        snowEmitter.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter.AddConfig("Name", "RainEmitter");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        /// 基础参数
        snowEmitter.AddConfig("ParticleZone", snowZone.GetConfig());//配置发射区域
        snowEmitter.AddConfig("Flow", param(0.0, 2000.0));//发射器每秒发射粒子数
        snowEmitter.AddConfig("MinForce", param(0.3, 0.5));//最小推力
        snowEmitter.AddConfig("MaxForce", param(0.5, 0.7));//最大推力
        /// 子类参数
        snowEmitter.AddConfig("Direction", (-1 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (-1 * DirectVec.GetZ()));//发射器方向 0,-1,0   
        snowEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter.AddConfig("MaxAngle", "0.157");//发射器最大偏移角

        //// 设置粒子组
        var snowGroup = map.CreateParticleGroup();//创建粒子组
        snowGroup.AddConfig("Name", "Snow");//粒子名称,与其他类型粒子不能重名
        snowGroup.AddConfig("Capacity", "8000");//粒子组粒子容量
        snowGroup.AddConfig("ParticleRender", snowRender.GetConfig());//配置粒子渲染器
        snowGroup.AddConfig("ParticleModel", snowParticleModel.GetConfig());//配置粒子模板
        snowGroup.AddConfig("ParticleEmitters", snowEmitter.GetConfig());//配置粒子发射器
        snowGroup.AddConfig("Friction", "0.7");//摩擦力系数
        snowGroup.AddConfig("Gravity", (-10 * DirectVec.GetX()) + "," + (-10 * DirectVec.GetY()) + "," + (-10 * DirectVec.GetZ()));//重力方向
        snowGroup.AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        snowGroup.AddConfig("CustomUpdateType", 2);//粒子更新类型
        //snowGroup.AddConfig("CustomParticlePosition", DirectPos.GetX() + "," + DirectPos.GetY() + "," + DirectPos.GetZ());//粒子更新位置
        snowGroup.AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        snowGroup.AddConfig("ImageUrl", gIconFolderPath + "//SnowLarge.bmp.dds");//配置纹理
        snowGroup.AddConfig("BlendMode", "770,1,1");//设置混合模式
        snowGroup.AddConfig("DepthBuffer", "0,1");                                                                                    
        snowGroup.AddConfig("AlphaTest", "516,0.5,0,1");                                                                            
        snowGroup.AddConfig("TextureEnv", "0,8448,1");
        snowGroup.AddConfig("TextureEnvFilter", "1,1");    
        //// 设置粒子发射器
        var snowEmitter2 = map.CreateParticleEmitter();//创建发射器
        snowEmitter2.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter2.AddConfig("Name", "snowEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        snowEmitter2.AddConfig("MinForce", param(0.1, 1.0));//最小推力
        snowEmitter2.AddConfig("MaxForce", param(0.2, 2.0));//最大推力
        snowEmitter2.AddConfig("Direction", (DirectVec.GetX()) + "," + (DirectVec.GetY()) + "," + (DirectVec.GetZ()));//发射器方向 0,-1,0   
        snowEmitter2.AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter2.AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticleGroups", snowGroup.GetConfig());//配置粒子组
        tlo.AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo.AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo.AddConfig("CustomUpdateEmitter", snowEmitter2.GetConfig());//更新中使用的发射器
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + longlatPos.GetZ());//粒子图层坐标(经纬度)
        var particleSnowLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[1] = particleSnowLayer;
        particleSnowLayer.AddObserver();
        map.AddLayer(particleSnowLayer);//添加粒子图层    
    }else{
        alert("图层已存在,请勿重复创建!");
    }     
}
//创建喷泉
function createFountain(pos){
    if(layerMap[2] == null){
        var screenPos = pos.split(",");
        var longlatPos = transformate.ScreenPosToWorldPos(screenPos[0], screenPos[1]);//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());

        var mHeight = 1.0;            
        var mAngle = 3.14/2.0;            
        var mSplashHeight = 0.0;    

        var mGravityScale = 1.0;    
        var mAlphaScale = 1.0;        
        var mParticleNumScale = 1.0;

        var g = 9.8 * mGravityScale;
        var upTime = Math.sqrt(2.0 * mHeight / g);
        var downTime = 1.05 * Math.sqrt(2.0 * (mHeight - mSplashHeight) / g);
        var lifeTime = upTime + downTime;
        var force = upTime * g / Math.cos(mAngle/2.0);
        var scale = Math.sqrt(mHeight * 2.0 * upTime * force * Math.sin(mAngle/2.0)) * 0.35;

        ////// 创建粒子渲染类型
        /////水滴样式
        var particleRenderer;
        ///Warning: 部分硬件不支持点粒子,使用四边形粒子代替(TODO)
        particleRenderer = map.CreateParticleRender();                                                                            /// 建粒子渲染类型
        particleRenderer.AddConfig("RenderType", "ParticleQuadRender");                                                            /// 创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer.AddConfig("XScale", scale);                                                                            /// X轴缩放比例
        particleRenderer.AddConfig("YScale", scale);                                                                            /// Y轴缩放比例
        particleRenderer.AddConfig("TextureEnable", "true");                                                                    /// 是否启用纹理
        particleRenderer.AddConfig("AtlasDimensionX",2);
        particleRenderer.AddConfig("AtlasDimensionY",2);
        /////水滴颜色
        //// 建立粒子模板
        var particleModel = map.CreateParticleModel();                                                                                /// 创建粒子模板
        particleModel.AddConfig("RedParam", "0;0.9,1.0,0.9,1.0");                                                                    /// 红色参数
        particleModel.AddConfig("GreenParam", "0;0.9,1.0,0.9,1.0");                                                                    /// 绿色参数
        particleModel.AddConfig("BlueParam", "0;0.9,1.0,0.9,1.0");    
        particleModel.AddConfig("TextureIndexParam", "0;0.0,4.0");    
        particleModel.AddConfig("AlphaParam", "4;3;0.0,0.06|0.6,0.2|0.85,0.08|1.0,0.04");                                            /// 透明参数
        particleModel.AddConfig("SizeParam", "4;4;0.0,0.05|0.5,0.1|1.0,0.08");    
        particleModel.AddConfig("MinLifeTime", lifeTime + 3);                                                                        /// 最小生命周期
        particleModel.AddConfig("MaxLifeTime", lifeTime + 3.5);                                                                        /// 最大生命周期

        /////喷泉圆锥发射区域
        //// 设置粒子区域对象        
        var pointZone = map.CreateParticleZone();//创建粒子区域
        pointZone.AddConfig("ZoneType", "PointZone");//创建点区域类型, PointZone代表点区域类型
        pointZone.AddConfig("Position", "0,0,0");//创建区域位置
        //// 设置粒子发射器
        var particleEmitter = map.CreateParticleEmitter();//创建区域发射器            
        particleEmitter.AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射方向(0,1,0)
        particleEmitter.AddConfig("MinAngle", 0.10 * 3.14 + "");//最小角度
        particleEmitter.AddConfig("MaxAngle", 0.15 * 3.14 + "");//最大角度
        particleEmitter.AddConfig("ParticleZone", pointZone.GetConfig());//设置发射区域
        particleEmitter.AddConfig("Flow", 800 * mParticleNumScale);//发射数量(TODO: 中断发射)
        particleEmitter.AddConfig("MinForce", 1.5);//最小推力
        particleEmitter.AddConfig("MaxForce", 1.5);//最大推力
        /////喷泉水花地面反弹
        //// 设置粒子区域对象
        var PlaneDirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var PlaneDirectVec = normalize(PlaneDirectPos.GetX(), PlaneDirectPos.GetY(), PlaneDirectPos.GetZ());//计算投影坐标单位向量
        var planeZone = map.CreateParticleZone();//创建粒子区域对象
        planeZone.AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone.AddConfig("Normal", PlaneDirectVec.GetX() + "," + PlaneDirectVec.GetY() + "," + PlaneDirectVec.GetZ());//区域方向
        planeZone.AddConfig("Position", "0, -1, 0");//区域位置 (TODO: 不生效)
        //// 设置修改器
        var particleModifier = map.CreateParticleModifier();//创建修改器
        particleModifier.AddConfig("ModifierType", "ObstacleModifier");//修改器类型
        particleModifier.AddConfig("ParticleZone", planeZone.GetConfig());//影响区域
        particleModifier.AddConfig("Trigger", "8");//触发信号(INTERSECT_ZONE)
        particleModifier.AddConfig("BouncingRatio", "0.2");//反弹系数
        particleModifier.AddConfig("Friction", "1.0");//速度因子
        //// 设置粒子组
        var particleGroup = map.CreateParticleGroup();//创建粒子组
        particleGroup.AddConfig("Name", "Fountain");//粒子名称,与其他类型粒子不能重名
        particleGroup.AddConfig("Capacity", "5000");//粒子发射数量
        particleGroup.AddConfig("ParticleRender", particleRenderer.GetConfig());//配置粒子渲染类型
        particleGroup.AddConfig("ParticleModel", particleModel.GetConfig());//配置粒子模板
        particleGroup.AddConfig("ParticleEmitters", particleEmitter.GetConfig());//配置粒子发射器
        particleGroup.AddConfig("ParticleModifiers", particleModifier.GetConfig());//配置粒子修改器
        particleGroup.AddConfig("Gravity", (-DirectVec.GetX()) + "," + (-DirectVec.GetY()) + "," + (-DirectVec.GetZ()));//重力方向
        particleGroup.AddConfig("ImageUrl", dataPath + "texture\\fire_alpha.png");//资源路径
        particleGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        //// 粒子图层配置
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型
        tlo.AddConfig("ParticleGroups", particleGroup.GetConfig());//设置粒子组配置
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ() + 2));//粒子图层坐标(经纬度)
        var particleFountainLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建喷泉粒子图层
        layerMap[2] = particleFountainLayer;
        map.AddLayer(particleFountainLayer);//添加粒子图层
    }else{
        alert("图层已存在,请勿重复创建!");
    }
}
//创建烟火
function createFire(pos){
    if(layerMap[3] == null){
        var screenPos = pos.split(",");
        var longlatPos = transformate.ScreenPosToWorldPos(screenPos[0], screenPos[1]);//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        var scale = mSize / 1.4;
        if (Math.abs(scale - 0.0) < 1.0e-6){
            scale = 1.0;
        }
        ////// 火焰效果粒子组
        //// 创建粒子渲染类型
        var mFireRenderer = map.CreateParticleRender();//建粒子渲染类型
        mFireRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mFireRenderer.AddConfig("XScale", 0.3 * scale);//X轴缩放比例
        mFireRenderer.AddConfig("YScale", 0.3 * scale);//Y轴缩放比例
        mFireRenderer.AddConfig("TextureEnable", "true");//是否启用纹理
        mFireRenderer.AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mFireRenderer.AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        //// 建立粒子模板
        var mFireModel = map.CreateParticleModel();//创建粒子模板
        mFireModel.AddConfig("RedParam", "3;0.8,0.9,0.8,0.9");//红色参数
        mFireModel.AddConfig("GreenParam", "3;0.5,0.6,0.5,0.6");//绿色参数
        mFireModel.AddConfig("BlueParam", "0;0.3");//蓝色参数
        mFireModel.AddConfig("AlphaParam", "1;0.4,0.0");//透明参数
        mFireModel.AddConfig("SizeParam", "4;;0.5,2.0,5.0|1.0,0.0");//粒子大小
        mFireModel.AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mFireModel.AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mFireModel.AddConfig("MinLifeTime", 1);//最小生命周期
        mFireModel.AddConfig("MaxLifeTime", 1.5);//最大生命周期
        //// 设置粒子区域对象
        var zone1 = map.CreateParticleZone();//创建粒子区域
        zone1.AddConfig("ZoneType", "SphereZone");//创建区域类型
        zone1.AddConfig("Position", (0 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (0 * DirectVec.GetZ()));//区域坐标
        zone1.AddConfig("Radius", 0.5 * scale);//区域半径
        var direct1 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0, 1, 0);
        //// 设置粒子发射器
        var mFireEmitter1 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter1.AddConfig("EmitterType", "StraightEmitter");//粒子发射器类型
        mFireEmitter1.AddConfig("Name", "mFireEmitter1");//发射器名称
        mFireEmitter1.AddConfig("Direction", (DirectVec.GetX() * direct1) + "," + (DirectVec.GetY() * direct1) + "," + (DirectVec.GetZ() * direct1));//发射方向 (0,1,0)
        //mFireEmitter1.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射方向 (0,1,0)
        mFireEmitter1.AddConfig("ParticleZone", zone1.GetConfig());//发射器区域
        mFireEmitter1.AddConfig("Flow", 40);//发射数量
        mFireEmitter1.AddConfig("MinForce", 1.0 * scale);//最小推力
        mFireEmitter1.AddConfig("MaxForce", 2.5 * scale);//最大推力
        //// 设置粒子区域对象
        var zone2 = map.CreateParticleZone();//创建粒子区域
        zone2.AddConfig("ZoneType", "SphereZone");//区域类型
        zone2.AddConfig("Position", (0.15 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (0.075 * DirectVec.GetZ()));//区域位置
        zone2.AddConfig("Radius", 0.1 * scale);//区域半径
        var direct2 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0, 0.6, 0);
        //// 设置粒子发射器
        var mFireEmitter2 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter2.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter2.AddConfig("Name", "mFireEmitter2");//发射器名称
        mFireEmitter2.AddConfig("Direction", (DirectVec.GetX() * direct2) + "," + (DirectVec.GetY() * direct2) + "," + (DirectVec.GetZ() * direct2));//发射器方向
        mFireEmitter2.AddConfig("ParticleZone", zone2.GetConfig());//发射器区域
        mFireEmitter2.AddConfig("Flow", 15);//发射数量
        mFireEmitter2.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter2.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //// 设置粒子区域对象
        var zone3 = map.CreateParticleZone();//创建粒子区域
        zone3.AddConfig("ZoneType", "SphereZone");//创建粒子区域类型
        zone3.AddConfig("Position", (-0.375 * DirectVec.GetX()) + "," + (-1.15 * DirectVec.GetY()) + "," + (-0.375 * DirectVec.GetZ()));//区域坐标位置
        zone3.AddConfig("Radius", 0.3 * scale);//区域半径
        var direct3 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), -0.6, 0.8, -0.8);
        //// 设置粒子发射器
        var mFireEmitter3 = map.CreateParticleEmitter();//创建发射器
        mFireEmitter3.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter3.AddConfig("Name", "mFireEmitter3");//发射器名称
        mFireEmitter3.AddConfig("Direction", (DirectVec.GetX() * direct3) + "," + (DirectVec.GetY() * direct3) + "," + (DirectVec.GetZ() * direct3));//发射器方向
        mFireEmitter3.AddConfig("ParticleZone", zone3.GetConfig());//发射区域
        mFireEmitter3.AddConfig("Flow", 15);//粒子数量
        mFireEmitter3.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter3.AddConfig("MaxForce", 1.5 * scale);//最大推力

        //// 设置粒子区域对象
        var zone4 = map.CreateParticleZone();//创建粒子区域
        zone4.AddConfig("ZoneType", "SphereZone");//区域类型
        zone4.AddConfig("Position", (-0.255 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (0.225 * DirectVec.GetZ()));//粒子区域位置
        zone4.AddConfig("Radius", 0.2 * scale);//区域半径

        var direct4 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), -0.8, 0.5, 0.2);
        //// 设置粒子发射器
        var mFireEmitter4 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter4.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter4.AddConfig("Name", "mFireEmitter4");//发射器名称
        mFireEmitter4.AddConfig("Direction", (DirectVec.GetX() * direct4) + "," + (DirectVec.GetY() * direct4) + "," + (DirectVec.GetZ() * direct4));//发射器方向
        mFireEmitter4.AddConfig("ParticleZone", zone4.GetConfig());//发射器区域
        mFireEmitter4.AddConfig("Flow", 10);//发射器每秒发射粒子数
        mFireEmitter4.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter4.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //// 设置粒子区域对象
        var zone5 = map.CreateParticleZone();//创建区域对象
        zone5.AddConfig("ZoneType", "SphereZone");//区域类型
        zone5.AddConfig("Position", (-0.075 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (-0.3 * DirectVec.GetZ()));//区域位置
        zone5.AddConfig("Radius", 0.2 * scale);//区域半径

        var direct5 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0.1, 0.8, -1.0);
        //// 设置粒子发射器
        var mFireEmitter5 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter5.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter5.AddConfig("Name", "mFireEmitter5");//发射器名称
        mFireEmitter5.AddConfig("Direction", (DirectVec.GetX() * direct5) + "," + (DirectVec.GetY() * direct5) + "," + (DirectVec.GetZ() * direct5));//发射器方向
        mFireEmitter5.AddConfig("ParticleZone", zone5.GetConfig());//发射器区域
        mFireEmitter5.AddConfig("Flow", 10);//发射器每秒发射粒子数
        mFireEmitter5.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter5.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //// 设置粒子组
        var mFireGroup = map.CreateParticleGroup();//创建粒子组
        mFireGroup.AddConfig("Name", "Fire");//粒子名称,与其他类型粒子不能重名
        mFireGroup.AddConfig("Capacity", "1350");//粒子组粒子容量
        mFireGroup.AddConfig("ParticleRender", mFireRenderer.GetConfig());//粒子组绘制配置
        mFireGroup.AddConfig("ParticleModel", mFireModel.GetConfig());//粒子组模板配置
        mFireGroup.AddConfig("ParticleEmitters", mFireEmitter1.GetConfig() + mFireEmitter2.GetConfig() + mFireEmitter3.GetConfig() + mFireEmitter4.GetConfig() + mFireEmitter5.GetConfig());//粒子组发射器配置
        //mFireGroup.AddConfig("Gravity", 0.0 + "," + 3.0 * scale + "," + 0.0);                                                        //重力方向
        mFireGroup.AddConfig("Gravity", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//重力方向
        mFireGroup.AddConfig("ImageUrl", dataPath + "texture\\fire.bmp.dds");//粒子纹理
        mFireGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        mFireGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mFireGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        ////// 烟雾效果粒子组
        //// 创建粒子渲染类型
        var mSmokeRenderer = map.CreateParticleRender();//建粒子渲染类型
        mSmokeRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mSmokeRenderer.AddConfig("XScale", 0.3 * scale);//X轴缩放比例
        mSmokeRenderer.AddConfig("YScale", 0.3 * scale);//Y轴缩放比例
        mSmokeRenderer.AddConfig("TextureEnable", "true");//是否启用纹理
        mSmokeRenderer.AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mSmokeRenderer.AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        ////建立粒子模板
        var mSmokeModel = map.CreateParticleModel();//创建粒子模板
        mSmokeModel.AddConfig("RedParam", "1;0.3,0.2");//红色参数
        mSmokeModel.AddConfig("GreenParam", "1;0.25,0.2");//绿色参数
        mSmokeModel.AddConfig("BlueParam", "0;0.2");//蓝色参数
        mSmokeModel.AddConfig("AlphaParam", "4;0.2,0.0;0.0,0.0|0.2,0.2|1.0,0.0");//透明度参数
        mSmokeModel.AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mSmokeModel.AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mSmokeModel.AddConfig("SizeParam", "1;5,10");//尺寸参数
        mSmokeModel.AddConfig("MinLifeTime", 5);//最大生命周期
        mSmokeModel.AddConfig("MaxLifeTime", 5);//最小生命周期
        ////设置粒子区域对象
        var smokeZone = map.CreateParticleZone();//创建粒子区域
        smokeZone.AddConfig("ZoneType", "SphereZone");//区域类型
        smokeZone.AddConfig("Position", "0,0,0");//区域位置
        smokeZone.AddConfig("Radius", 1.2 * scale);//区域半径
        ////设置粒子发射器
        var mSmokeEmitter = map.CreateParticleEmitter();//创建粒子发射器
        mSmokeEmitter.AddConfig("EmitterType", "SphericEmitter");//发射器类型
        mSmokeEmitter.AddConfig("Name", "SmokeEmitter");//发射器名称
        mSmokeEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//发射方向 (0,1,0)
        mSmokeEmitter.AddConfig("MinAngle", "0");//最小角度
        mSmokeEmitter.AddConfig("MaxAngle", "1.57");//最大角度
        mSmokeEmitter.AddConfig("ParticleZone", smokeZone.GetConfig());//发射器区域
        mSmokeEmitter.AddConfig("Flow", 25);//发射器每秒发射粒子数
        mSmokeEmitter.AddConfig("MinForce", 0.5*scale);//最小推力
        mSmokeEmitter.AddConfig("MaxForce", 1.0*scale);//最大推力
        ///设置粒子组
        var mSmokeGroup = map.CreateParticleGroup();//创建粒子组
        mSmokeGroup.AddConfig("Name", "Smoke");//粒子名称,与其他类型粒子不能重名
        mSmokeGroup.AddConfig("Capacity", "1350");//容量
        mSmokeGroup.AddConfig("ParticleRender", mSmokeRenderer.GetConfig());//绘制参数配置
        mSmokeGroup.AddConfig("ParticleModel", mSmokeModel.GetConfig());//模板参数配置
        mSmokeGroup.AddConfig("ParticleEmitters", mSmokeEmitter.GetConfig());//粒子发射器配置
        mSmokeGroup.AddConfig("Gravity", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//重力方向 (0.0,0.4*scale,0.0)
        mSmokeGroup.AddConfig("ImageUrl", dataPath + "texture\\fire_alpha.png");//粒子纹理配置
        mSmokeGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        mSmokeGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mSmokeGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        ////// 图层配置
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ()  ));//粒子图层坐标(经纬度)
        tlo.AddConfig("ParticleGroups", mFireGroup.GetConfig() + mSmokeGroup.GetConfig());//粒子组配置
        //tlo.AddConfig("BlendMode", "770, 1");
        var particleFireLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[3] = particleFireLayer;
        map.AddLayer(particleFireLayer);//添加粒子图层
    }else{
        alert("图层已存在,请勿重复创建!");
    }
}
//创建水枪
function createHydraulicGun(){
    if(layerMap[4] == null){
        var mStartLLHPoint = map.CreatePosition(startPos.GetX(), startPos.GetY(), startPos.GetZ() + 1);
        var mStartWorldPoint = transformate.ConvertLongLatHeightToXYZ(mStartLLHPoint);

        var mEndLLHPoint = map.CreatePosition(endPos.GetX(), endPos.GetY(), endPos.GetZ() + 1);
        var mEndWorldPoint = transformate.ConvertLongLatHeightToXYZ(mEndLLHPoint);

        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(mStartLLHPoint.GetX(), mStartLLHPoint.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var DirectVec2 = normalize(mEndWorldPoint.GetX() - mStartWorldPoint.GetX(), mEndWorldPoint.GetY() - mStartWorldPoint.GetY(), mEndWorldPoint.GetZ() - mStartWorldPoint.GetZ());// 计算投影坐标单位向量

        var fXSpeed = (mStartWorldPoint.GetX() - mEndWorldPoint.GetX()) / 4.0;
        var fYSpeed = (mStartWorldPoint.GetY() - mEndWorldPoint.GetY()) * 5.0 / 12.0;
        var fZSpeed = (mStartWorldPoint.GetZ() - mEndWorldPoint.GetZ()) / 4.0;

        var mForce = Math.sqrt(Math.pow(fXSpeed, 2) + Math.pow(fYSpeed, 2) + Math.pow(fZSpeed, 2));

        var mDirection = normalize(fXSpeed, fYSpeed, fZSpeed);

        var mGravity = Math.abs(fYSpeed / 5.0);
        var mSize = mForce / 15;

        var particleRenderer = map.CreateParticleRender();//建粒子渲染类型
        particleRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer.AddConfig("XScale", "0.03");//X轴缩放比例
        particleRenderer.AddConfig("YScale", "0.03");//Y轴缩放比例
        //particleRenderer.AddConfig("AtlasDimensionX", "2");                                                                        
        //particleRenderer.AddConfig("AtlasDimensionY", "2");                                                                        
        particleRenderer.AddConfig("TextureEnable", "true");//是否启用纹理

        var particleModel = map.CreateParticleModel();//创建粒子模板
        particleModel.AddConfig("RedParam", "0;1");//红色参数
        particleModel.AddConfig("GreenParam", "0;1");//绿色参数
        particleModel.AddConfig("BlueParam", "0;1");//蓝色参数
        particleModel.AddConfig("AlphaParam", "0;0.8");//透明参数
        particleModel.AddConfig("MinLifeTime", "8.5");//最小生命周期
        particleModel.AddConfig("MaxLifeTime", "8.5");//最大生命周期

        //// 设置粒子区域对象
        var zone = map.CreateParticleZone();//创建粒子区域
        //zone.AddConfig("ZoneType", "PointZone");//创建区域类型
        zone.AddConfig("ZoneType", "SphereZone");//创建区域类型
        //zone.AddConfig("Position", (1 * mStartWorldPoint.GetX()) + "," + (1 * mStartWorldPoint.GetY()) + "," + (1 * mStartWorldPoint.GetZ()));//区域坐标
        zone.AddConfig("Position", "1, 1, 1");//区域坐标
        zone.AddConfig("Radius", 0.2);        

        var particleEmitter = map.CreateParticleEmitter();//创建区域发射器            
        particleEmitter.AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter.AddConfig("Direction", DirectVec2.GetX() + "," + DirectVec2.GetY() + "," + DirectVec2.GetZ());//发射方向(0,1,0)
        particleEmitter.AddConfig("MinAngle", "0.0");//最小角度
        particleEmitter.AddConfig("MaxAngle", 0.02 * 3.14 + "");//最大角度
        //particleEmitter.AddConfig("MaxAngle", "0.0");//最大角度
        particleEmitter.AddConfig("ParticleZone", zone.GetConfig());//设置发射区域
        particleEmitter.AddConfig("Flow", "12000");//发射数量
        particleEmitter.AddConfig("MinForce","12.5");//最小推力
        particleEmitter.AddConfig("MaxForce","12.5");//最大推力


        var planeZone = map.CreateParticleZone();//创建粒子区域对象
        planeZone.AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone.AddConfig("Normal", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//区域方向
        //planeZone.AddConfig("Position", "" + ModifierPos.GetX() - mStartWorldPoint.GetX() + "," + ModifierPos.GetY() - mStartWorldPoint.GetY() 
        //+ "," + ModifierPos.GetZ() - mStartWorldPoint.GetZ());//区域位置 
        planeZone.AddConfig("Position", "0,-10,0");


        var particleGroup = map.CreateParticleGroup();//创建粒子组
        particleGroup.AddConfig("Name", "HydraulicGun");//粒子名称,与其他类型粒子不能重名
        particleGroup.AddConfig("Capacity", "80000");//粒子最大数量
        particleGroup.AddConfig("ParticleRender", particleRenderer.GetConfig());//配置粒子渲染类型
        particleGroup.AddConfig("ParticleModel", particleModel.GetConfig());//配置粒子模板
        particleGroup.AddConfig("ParticleEmitters", particleEmitter.GetConfig());//配置粒子发射器

        particleGroup.AddConfig("Gravity", (-DirectVec.GetX()*3) + "," + (-DirectVec.GetY()*3) + "," + (-DirectVec.GetZ()*3));//重力方向
        particleGroup.AddConfig("ImageUrl", dataPath + "/texture/point.bmp.dds");//资源路径
        particleGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试

        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型
        tlo.AddConfig("ParticleGroups", particleGroup.GetConfig());//设置粒子组配置
        //tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ() + 2));//粒子图层坐标(经纬度)
        tlo.AddConfig("ParticlePosition", mStartLLHPoint.GetX() + "," + mStartLLHPoint.GetY() + "," + (mStartLLHPoint.GetZ()));//粒子图层坐标(经纬度)
        particleGunLayer = map.CreateLayer("ParticleSystemLayer", tlo);    
        map.AddLayer(particleGunLayer);
        layerMap[4] = particleGunLayer;
    }else{
        alert("图层已存在,请勿重复创建!");
    }

}

function param(min, max){
    return min + rainRatio * (max - min);
}
// 取单位向量用于控制方向
function normalize(x, y, z){
    var length = Math.sqrt(x * x + y * y + z * z );
    var mx = x / length;
    var my = y / length;
    var mz = z / length;
    return map.CreatePosition(mx, my, mz);
}

function vectorDirection(x1, y1, z1, x2, y2, z2){
    var vec1 = Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1);
    var vec2 = Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2);
    var tmp = x1 * x2 + y1 * y2 + z1 * z2;
    return tmp / (vec1 * vec2);
}
// 区域大小控制
function record(x, y, z){
    var length = Math.sqrt(x * x + y * y + z * z );
    var factor = (5.0 / length) + 1;
    var mx = x * factor;
    var my = y * factor;
    var mz = z * factor;
    return map.CreatePosition(mx, my, mz);
}

C++调用

std::string mIniPath;
std::string dataPath;
CoordinateSystemCOMLib::ITransformatePtr transformate;
double rainRatio;
double sizeRatio;
double rainscale;
bool fountainState;
double mSize;
//创建雨效
void CParticleDlg::createRain()
{
    if(layerMap[0] == NULL)
    {
        BaseObjectCOMLib::IPositionPtr longlatPos = transformate->ScreenPosToWorldPos(rectDlg.Width()/ 2, rectDlg.Height() / 2);//将屏幕坐标点转换成经纬度坐标
        BaseObjectCOMLib::IPositionPtr worldPos = transformate->ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        BaseObjectCOMLib::IPositionPtr DirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr DirectVec = normalize(DirectPos->GetX(), DirectPos->GetY(), DirectPos->GetZ());//计算投影坐标单位向量
        BaseObjectCOMLib::IPositionPtr RecordPos = record(worldPos->GetX(), worldPos->GetY(), worldPos->GetZ());//配置区域
        BaseObjectCOMLib::IPositionPtr ZoneXYZPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 20));//取投影坐标
        BaseObjectCOMLib::IPositionPtr ZonePos = map->CreatePosition(ZoneXYZPos->GetX() - worldPos->GetX(), ZoneXYZPos->GetY() - worldPos->GetY(), ZoneXYZPos->GetZ() - worldPos->GetZ());
        //建粒子渲染类型
        ConfigOptionsCOMLib::IParticleRenderPtr rainRender = map->CreateParticleRender();
        rainRender->AddConfig("RenderType", "ParticleLineRender");//创建线粒子渲染类型, ParticleLineRender代表线粒子渲染类型
        rainRender->AddConfig("Width", DoubleToString(param(1.0, 4.0) * sizeRatio).c_str());//线宽(0-10)
        rainRender->AddConfig("Length", "-0.02");//线长
        //建立粒子模板 param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        //第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        //第二个参数第二部分标识参数具体值
        //第二个参数第三部分标识差值参数, 竖线(|)分割
        ConfigOptionsCOMLib::IParticleModelPtr rainParticleModel = map->CreateParticleModel();
        std::stringstream streamRedParam;
        streamRedParam << param(1.0, 0.40);
        streamRedParam.str() = "0;" + streamRedParam.str();
        rainParticleModel->AddConfig("RedParam", streamRedParam.str().c_str());
        std::stringstream streamGreenParam;
        streamGreenParam << param(1.0, 0.40);
        streamGreenParam.str() = "0;" + streamGreenParam.str();
        rainParticleModel->AddConfig("GreenParam", streamGreenParam.str().c_str());
        std::stringstream streamBlueParam;
        streamBlueParam << param(1.0, 0.42);
        streamBlueParam.str() = "0;" + streamBlueParam.str();
        rainParticleModel->AddConfig("BlueParam", streamBlueParam.str().c_str());
        rainParticleModel->AddConfig("AlphaParam", "0;0.3");
        std::stringstream streamMassParam,streamMassParam1;
        streamMassParam << param(0.4, 0.8);
        streamMassParam1 << param(0.8, 1.6);
        streamMassParam.str() = "2;" + streamMassParam.str()+ "," +streamMassParam1.str();
        rainParticleModel->AddConfig("MassParam",  streamMassParam.str().c_str());
        //非 param 参数
        rainParticleModel->AddConfig("Immortal", "true");//永生参数
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr rainZone = map->CreateParticleZone();//创建发射区区域
        rainZone->AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        rainZone->AddConfig("Radius", "200");//区域半径
        std::stringstream ZonePosX,ZonePosY,ZonePosZ;
        ZonePosX << ZonePos->GetX();
        ZonePosY << ZonePos->GetY();
        ZonePosZ << ZonePos->GetZ();
        std::string ZonePosXYZ = ZonePosX.str() + "," + ZonePosY.str() + "," + ZonePosZ.str();
        rainZone->AddConfig("Position", ZonePosXYZ.c_str());//区域位置 / 基准位置
        rainZone->AddConfig("AutoPosition", "true");//自动视野
        std::stringstream worldPosX,worldPosY,worldPosZ;
        worldPosX << worldPos->GetX();
        worldPosY << worldPos->GetY();
        worldPosZ << worldPos->GetZ();
        std::string worldPosXYZ = worldPosX.str() + "," + worldPosY.str() + "," + worldPosZ.str();
        rainZone->AddConfig("Position", worldPosXYZ.c_str());//区域位置 / 基准位置
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr rainEmitter = map->CreateParticleEmitter();//创建发射器
        rainEmitter->AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter->AddConfig("Name", "RainEmitter"); //雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        //基础参数
        rainEmitter->AddConfig("ParticleZone", rainZone->GetConfig());//配置发射区域
        std::stringstream streamFlow;
        streamFlow << param(0.0, 2000.0 * rainscale);
        rainEmitter->AddConfig("Flow", streamFlow.str().c_str());//发射器每秒发射粒子数
        std::stringstream streamMinForce;
        streamMinForce << param(5.0, 10.0);
        rainEmitter->AddConfig("MinForce", streamMinForce.str().c_str());//最小推力
        std::stringstream streamMaxForce;
        streamMaxForce << param(5.0, 10.0);
        rainEmitter->AddConfig("MaxForce", streamMaxForce.str().c_str());//最大推力
        //子类参数
        std::stringstream DirectVecX,DirectVecY,DirectVecZ;
        DirectVecX <<  (-1 * DirectVec->GetX());
        DirectVecY <<(-1 * DirectVec->GetY());
        DirectVecZ << (-1 * DirectVec->GetZ());
        std::string DirectVecXYZ = DirectVecX.str() + "," + DirectVecY.str() + "," + DirectVecZ.str();
        rainEmitter->AddConfig("Direction", DirectVecXYZ.c_str());//发射器方向 0,-1,0   
        rainEmitter->AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter->AddConfig("MaxAngle", "0.157");//发射器最大偏移角
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr rainGroup = map->CreateParticleGroup();//创建粒子组
        rainGroup->AddConfig("Name", "Rain");//粒子名称,与其他类型粒子不能重名
        rainGroup->AddConfig("Capacity", "8000");//粒子组粒子容量
        rainGroup->AddConfig("ParticleRender", rainRender->GetConfig());//配置粒子渲染器
        rainGroup->AddConfig("ParticleModel", rainParticleModel->GetConfig());//配置粒子模板
        rainGroup->AddConfig("ParticleEmitters", rainEmitter->GetConfig());//配置粒子发射器
        rainGroup->AddConfig("Friction", "0.7");//摩擦力系数
        std::stringstream GravityX,GravityY,GravityZ;
        GravityX <<  (-20 * rainscale *  DirectVec->GetX());
        GravityY <<(-20 * rainscale *DirectVec->GetY());
        GravityZ << (-20 * rainscale * DirectVec->GetZ());
        std::string GravityXYZ = GravityX.str() + "," + GravityY.str() + "," + GravityZ.str();
        rainGroup->AddConfig("Gravity", GravityXYZ.c_str());//重力方向
        rainGroup->AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        rainGroup->AddConfig("CustomUpdateType", "2");//粒子更新类型
        rainGroup->AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        //粒子渲染类型  水花效果
        ConfigOptionsCOMLib::IParticleRenderPtr dropRender = map->CreateParticleRender();//建粒子渲染类型
        dropRender->AddConfig("RenderType", "ParticlePointRender");//创建点粒子渲染类型, ParticlePointRender代表点粒子渲染类型
        std::stringstream streamSize;
        streamSize <<  2.0 * sizeRatio;
        dropRender->AddConfig("Size", streamSize.str().c_str());//点的大小
        //粒子模板
        ConfigOptionsCOMLib::IParticleModelPtr dropParticleModel = map->CreateParticleModel();
        dropParticleModel->AddConfig("RedParam",("0;" + DoubleToString(param(1.0, 0.40))).c_str());
        dropParticleModel->AddConfig("GreenParam",("0;" + DoubleToString(param(1.0, 0.40))).c_str());
        dropParticleModel->AddConfig("BlueParam", ("0;" + DoubleToString(param(1.0, 0.42))).c_str());
        dropParticleModel->AddConfig("AlphaParam", "0;0.6");
        dropParticleModel->AddConfig("MassParam", ("2;" + DoubleToString(param(0.4, 0.8)) + "," + DoubleToString(param(3.0, 4.0))).c_str());
        dropParticleModel->AddConfig("MinLifeTime", DoubleToString(param(0.05, 0.3)).c_str());//最小生命周期
        dropParticleModel->AddConfig("MaxLifeTime", DoubleToString(param(0.1, 0.5)).c_str());//最大生命周期
        //粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr dropEmitter = map->CreateParticleEmitter();
        dropEmitter->AddConfig("EmitterType", "SphericEmitter");//发射器类型
        dropEmitter->AddConfig("Name", "DropEmitter");//发射器名称
        dropEmitter->AddConfig("MinForce", DoubleToString(param(0.1, 1.0)).c_str());//最小推力
        dropEmitter->AddConfig("MaxForce", DoubleToString(param(0.2, 2.0)).c_str());//最大推力
        dropEmitter->AddConfig("Direction", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY()) + "," + DoubleToString(DirectVec->GetZ())).c_str());//发射器方向
        dropEmitter->AddConfig("MinAngle", "0");//发射器最小偏移角
        dropEmitter->AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr dropGroup = map->CreateParticleGroup();
        dropGroup->AddConfig("Name", "Drop");//粒子名称,与其他类型粒子不能重名
        dropGroup->AddConfig("Capacity", "16000");
        dropGroup->AddConfig("ParticleRender", dropRender->GetConfig());
        dropGroup->AddConfig("ParticleModel", dropParticleModel->GetConfig());
        dropGroup->AddConfig("ParticleEmitters", dropEmitter->GetConfig());
        dropGroup->AddConfig("Friction", "0.7");
        dropGroup->AddConfig("Gravity", (DoubleToString((-2 * DirectVec->GetX())) + "," + DoubleToString((-2 * DirectVec->GetY())) + "," + DoubleToString((-2 * DirectVec->GetZ()))).c_str());
        //爆炸效果
        //粒子渲染类型
        ConfigOptionsCOMLib::IParticleRenderPtr splashRender = map->CreateParticleRender();//建粒子渲染类型
        splashRender->AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        splashRender->AddConfig("XScale", "0.1");//X轴缩放比例
        splashRender->AddConfig("YScale", "0.1");//Y轴缩放比例
        splashRender->AddConfig("TextureEnable", "true");//是否启用纹理

        ConfigOptionsCOMLib::IParticleModelPtr splashParticleModel = map->CreateParticleModel();
        splashParticleModel->AddConfig("RedParam", ("0;" + DoubleToString(param(1.0, 0.40))).c_str());
        splashParticleModel->AddConfig("GreenParam", ("0;" + DoubleToString(param(1.0, 0.40))).c_str());
        splashParticleModel->AddConfig("BlueParam", ("0;" + DoubleToString(param(1.0, 0.42))).c_str());
        splashParticleModel->AddConfig("AlphaParam", "1;1.0,0.0");
        splashParticleModel->AddConfig("SizeParam", ("3;0,0," + DoubleToString(param(0.375, 2.25)) + "," + DoubleToString(param(0.75, 3.78))).c_str());//粒子大小
        splashParticleModel->AddConfig("AngleParam", "2;0.0,6.283");//粒子角度 1表示参数随机生成
        splashParticleModel->AddConfig("MinLifeTime", DoubleToString(param(0.2, 0.3)).c_str());
        splashParticleModel->AddConfig("MaxLifeTime", DoubleToString(param(0.4, 0.5)).c_str());

        ConfigOptionsCOMLib::IParticleGroupPtr splashGroup = map->CreateParticleGroup();
        splashGroup->AddConfig("Name", "Splash");//粒子名称,与其他类型粒子不能重名
        splashGroup->AddConfig("Capacity", "2400");
        splashGroup->AddConfig("ParticleRender", splashRender->GetConfig());
        splashGroup->AddConfig("ParticleModel", splashParticleModel->GetConfig());
        splashGroup->AddConfig("ImageUrl", (dataPath + "/waterdrops.bmp.dds").c_str());//配置纹理
        splashGroup->AddConfig("BlendMode", "770,1,1");//设置混合模式
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr rainEmitter2 = map->CreateParticleEmitter();//创建发射器
        rainEmitter2->AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter2->AddConfig("Name", "RainEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        rainEmitter2->AddConfig("MinForce", DoubleToString(param(0.1, 1.0)).c_str());//最小推力
        rainEmitter2->AddConfig("MaxForce", DoubleToString(param(0.2, 2.0)).c_str());//最大推力
        rainEmitter2->AddConfig("Direction", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY()) + "," + DoubleToString(DirectVec->GetZ())).c_str());//发射器方向 0,-1,0   
        rainEmitter2->AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter2->AddConfig("MaxAngle", "0.628");//发射器最大偏移角

        ConfigOptionsCOMLib::ILayerOptionsPtr tlo = map->CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo->AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo->AddConfig("ParticleGroups", rainGroup->GetConfig() + dropGroup->GetConfig() + splashGroup->GetConfig());//配置粒子组
        tlo->AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo->AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo->AddConfig("CustomUpdateEmitter", rainEmitter2->GetConfig());//更新中使用的发射器
        tlo->AddConfig("ParticlePosition", (DoubleToString(longlatPos->GetX()) + "," + DoubleToString(longlatPos->GetY()) + "," + DoubleToString(longlatPos->GetZ())).c_str());//粒子图层坐标(经纬度)
        BaseObjectCOMLib::ILayerObjectPtr particleRainLayer = map->CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[0] = particleRainLayer;
        particleRainLayer->AddObserver();
        map->AddLayer(particleRainLayer);//添加粒子图层  
    }
}
//创建雪效
void CParticleDlg::createSnow()
{
    if(layerMap[1] == NULL)
    {
        BaseObjectCOMLib::IPositionPtr longlatPos = transformate->ScreenPosToWorldPos(rectDlg.Width()/ 2, rectDlg.Height() / 2);//将屏幕坐标点转换成经纬度坐标
        BaseObjectCOMLib::IPositionPtr worldPos = transformate->ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        BaseObjectCOMLib::IPositionPtr DirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr DirectVec = normalize(DirectPos->GetX(), DirectPos->GetY(), DirectPos->GetZ());//计算投影坐标单位向量
        BaseObjectCOMLib::IPositionPtr RecordPos = record(worldPos->GetX(), worldPos->GetY(), worldPos->GetZ());//配置区域
        BaseObjectCOMLib::IPositionPtr ZoneXYZPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 20));//取投影坐标
        BaseObjectCOMLib::IPositionPtr ZonePos = map->CreatePosition(ZoneXYZPos->GetX() - worldPos->GetX(), ZoneXYZPos->GetY() - worldPos->GetY(), ZoneXYZPos->GetZ() - worldPos->GetZ());
        //建粒子渲染类型
        ConfigOptionsCOMLib::IParticleRenderPtr snowRender = map->CreateParticleRender();
        snowRender->AddConfig("RenderType", "ParticleQuadRender");//创建线粒子渲染类型, ParticleLineRender代表线粒子渲染类型
        snowRender->AddConfig("Width", DoubleToString(param(1.0, 4.0) * sizeRatio).c_str());//线宽(0-10)
        snowRender->AddConfig("XScale", "1.0");                                                                    
        snowRender->AddConfig("YScale", "1.0");                                                                    
        snowRender->AddConfig("TextureEnable", "true");                                                            
        snowRender->AddConfig("AtlasDimensionX","2");
        snowRender->AddConfig("AtlasDimensionY","2");//建立粒子模板
        //param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        //第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        //第二个参数第二部分标识参数具体值
        //第二个参数第三部分标识差值参数, 竖线(|)分割
        ConfigOptionsCOMLib::IParticleModelPtr snowParticleModel = map->CreateParticleModel();
        snowParticleModel->AddConfig("RedParam", "0;1");
        snowParticleModel->AddConfig("GreenParam", "0;1");
        snowParticleModel->AddConfig("BlueParam", "0;1");
        snowParticleModel->AddConfig("MassParam", ("2;" + DoubleToString(param(0.5, 0.6)) + "," + DoubleToString(param(0.8, 1.0))).c_str());
        snowParticleModel->AddConfig("AlphaParam",("1;" + DoubleToString(param(0.5, 0.6)) + "," + DoubleToString(param(0.8, 1.0))).c_str());
        snowParticleModel->AddConfig("SizeParam", ("1;" + DoubleToString(param(0.5, 0.6)) + "," + DoubleToString(param(0.8, 1.0))).c_str());
        //非 param 参数
        snowParticleModel->AddConfig("Immortal", "true");//永生参数
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr snowZone = map->CreateParticleZone();//创建发射区区域
        snowZone->AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        snowZone->AddConfig("Radius", "200");//区域半径
        snowZone->AddConfig("Position", (DoubleToString(ZonePos->GetX()) + "," + DoubleToString(ZonePos->GetY()) + "," + DoubleToString(ZonePos->GetZ())).c_str());//区域位置 / 基准位置
        snowZone->AddConfig("AutoPosition", "true");//自动视野
        snowZone->AddConfig("Position", (DoubleToString(worldPos->GetX()) + "," + DoubleToString(worldPos->GetY()) + "," + DoubleToString(worldPos->GetZ())).c_str());//区域位置 / 基准位置
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr snowEmitter = map->CreateParticleEmitter();//创建发射器
        snowEmitter->AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter->AddConfig("Name", "RainEmitter");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        //基础参数
        snowEmitter->AddConfig("ParticleZone", snowZone->GetConfig());//配置发射区域
        snowEmitter->AddConfig("Flow", DoubleToString(param(0.0, 2000.0)).c_str());//发射器每秒发射粒子数
        snowEmitter->AddConfig("MinForce", DoubleToString(param(0.3, 0.5)).c_str());//最小推力
        snowEmitter->AddConfig("MaxForce", DoubleToString(param(0.5, 0.7)).c_str());//最大推力
        //子类参数
        snowEmitter->AddConfig("Direction", (DoubleToString(-1 * DirectVec->GetX()) + "," + DoubleToString(-1 * DirectVec->GetY()) + "," + DoubleToString(-1 * DirectVec->GetZ())).c_str());//发射器方向 0,-1,0 
        snowEmitter->AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter->AddConfig("MaxAngle", "0.157");//发射器最大偏移角
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr snowGroup = map->CreateParticleGroup();//创建粒子组
        snowGroup->AddConfig("Name", "Snow");//粒子名称,与其他类型粒子不能重名
        snowGroup->AddConfig("Capacity", "8000");//粒子组粒子容量
        snowGroup->AddConfig("ParticleRender", snowRender->GetConfig());//配置粒子渲染器
        snowGroup->AddConfig("ParticleModel", snowParticleModel->GetConfig());//配置粒子模板
        snowGroup->AddConfig("ParticleEmitters", snowEmitter->GetConfig());//配置粒子发射器
        snowGroup->AddConfig("Friction", "0.7");//摩擦力系数
        snowGroup->AddConfig("Gravity", (DoubleToString(-10 * DirectVec->GetX()) + "," + DoubleToString(-10 * DirectVec->GetY()) + "," + DoubleToString(-10 * DirectVec->GetZ())).c_str());//重力方向
        snowGroup->AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        snowGroup->AddConfig("CustomUpdateType", "2");//粒子更新类型
        snowGroup->AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        snowGroup->AddConfig("ImageUrl", (dataPath + "/SnowLarge.bmp.dds").c_str());//配置纹理
        snowGroup->AddConfig("BlendMode", "770,1,1");//设置混合模式
        snowGroup->AddConfig("DepthBuffer", "0,1");                                                                                    
        snowGroup->AddConfig("AlphaTest", "516,0.5,0,1");                                                                            
        snowGroup->AddConfig("TextureEnv", "0,8448,1");
        snowGroup->AddConfig("TextureEnvFilter", "1,1");    
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr snowEmitter2 = map->CreateParticleEmitter();//创建发射器
        snowEmitter2->AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter2->AddConfig("Name", "snowEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        snowEmitter2->AddConfig("MinForce", DoubleToString(param(0.1, 1.0)).c_str());//最小推力
        snowEmitter2->AddConfig("MaxForce", DoubleToString(param(0.2, 2.0)).c_str());//最大推力
        snowEmitter2->AddConfig("Direction", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY()) + "," + DoubleToString(DirectVec->GetZ())).c_str());//发射器方向 0,-1,0   
        snowEmitter2->AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter2->AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        ConfigOptionsCOMLib::ILayerOptionsPtr tlo = map->CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo->AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo->AddConfig("ParticleGroups", snowGroup->GetConfig());//配置粒子组
        tlo->AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo->AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo->AddConfig("CustomUpdateEmitter", snowEmitter2->GetConfig());//更新中使用的发射器
        tlo->AddConfig("ParticlePosition", (DoubleToString(longlatPos->GetX()) + "," + DoubleToString(longlatPos->GetY()) + "," + DoubleToString(longlatPos->GetZ())).c_str());//粒子图层坐标(经纬度)
        BaseObjectCOMLib::ILayerObjectPtr particleSnowLayer = map->CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[1] = particleSnowLayer;
        particleSnowLayer->AddObserver();
        map->AddLayer(particleSnowLayer);//添加粒子图层    
    }
}

//创建喷泉
void CParticleDlg::createFountain(std::string pos)
{
    if(layerMap[2] == NULL)
    {
        std::vector<std::string> screenPos;
        SplitString(pos,screenPos,",");
        BaseObjectCOMLib::IPositionPtr longlatPos = transformate->ScreenPosToWorldPos(StringToInt(screenPos[0]), StringToInt(screenPos[1]));//将屏幕坐标点转换成经纬度坐标
        BaseObjectCOMLib::IPositionPtr worldPos = transformate->ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        BaseObjectCOMLib::IPositionPtr DirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr DirectVec = normalize(DirectPos->GetX(), DirectPos->GetY(), DirectPos->GetZ());//计算投影坐标单位向量
        BaseObjectCOMLib::IPositionPtr RecordPos = record(worldPos->GetX(), worldPos->GetY(), worldPos->GetZ());//配置区域
        BaseObjectCOMLib::IPositionPtr ZoneXYZPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 20));//取投影坐标
        BaseObjectCOMLib::IPositionPtr ZonePos = map->CreatePosition(ZoneXYZPos->GetX() - worldPos->GetX(), ZoneXYZPos->GetY() - worldPos->GetY(), ZoneXYZPos->GetZ() - worldPos->GetZ());

        double mHeight = 1.0;            
        double mAngle = 3.14/2.0;            
        double mSplashHeight = 0.0;    

        double mGravityScale = 1.0;    
        double mAlphaScale = 1.0;        
        double mParticleNumScale = 1.0;

        double g = 9.8 * mGravityScale;
        double upTime = sqrt(2.0 * mHeight / g);
        double downTime = 1.05 * sqrt(2.0 * (mHeight - mSplashHeight) / g);
        double lifeTime = upTime + downTime;
        double force = upTime * g / cos(mAngle/2.0);
        double scale = sqrt(mHeight * 2.0 * upTime * force * sin(mAngle/2.0)) * 0.35;

        //创建粒子渲染类型
        //水滴样式
        ConfigOptionsCOMLib::IParticleRenderPtr particleRenderer;
        //Warning: 部分硬件不支持点粒子,使用四边形粒子代替(TODO)
        particleRenderer = map->CreateParticleRender();//建粒子渲染类型
        particleRenderer->AddConfig("RenderType", "ParticleQuadRender");                                                            //创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer->AddConfig("XScale", DoubleToString(scale).c_str());//X轴缩放比例
        particleRenderer->AddConfig("YScale", DoubleToString(scale).c_str());//Y轴缩放比例
        particleRenderer->AddConfig("TextureEnable", "true");//是否启用纹理
        particleRenderer->AddConfig("AtlasDimensionX","2");
        particleRenderer->AddConfig("AtlasDimensionY","2");

        //水滴颜色
        //建立粒子模板
        ConfigOptionsCOMLib::IParticleModelPtr particleModel = map->CreateParticleModel();//创建粒子模板
        particleModel->AddConfig("RedParam", "0;0.9,1.0,0.9,1.0");//红色参数
        particleModel->AddConfig("GreenParam", "0;0.9,1.0,0.9,1.0");                                                                    //绿色参数
        particleModel->AddConfig("BlueParam", "0;0.9,1.0,0.9,1.0");    
        particleModel->AddConfig("TextureIndexParam", "0;0.0,4.0");    
        particleModel->AddConfig("AlphaParam", "4;3;0.0,0.06|0.6,0.2|0.85,0.08|1.0,0.04");//透明参数
        particleModel->AddConfig("SizeParam", "4;4;0.0,0.05|0.5,0.1|1.0,0.08");    
        particleModel->AddConfig("MinLifeTime", DoubleToString(lifeTime + 3).c_str());//最小生命周期
        particleModel->AddConfig("MaxLifeTime", DoubleToString(lifeTime + 3.5).c_str());//最大生命周期

        //喷泉圆锥发射区域
        //设置粒子区域对象        
        ConfigOptionsCOMLib::IParticleZonePtr pointZone = map->CreateParticleZone();//创建粒子区域
        pointZone->AddConfig("ZoneType", "PointZone");//创建点区域类型, PointZone代表点区域类型
        pointZone->AddConfig("Position", "0,0,0");//创建区域位置
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr particleEmitter = map->CreateParticleEmitter();//创建区域发射器            
        particleEmitter->AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter->AddConfig("Direction", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY()) + "," + DoubleToString(DirectVec->GetZ())).c_str());//发射方向(0,1,0)
        particleEmitter->AddConfig("MinAngle", (DoubleToString(0.10 * 3.14) + "").c_str());//最小角度
        particleEmitter->AddConfig("MaxAngle", (DoubleToString(0.15 * 3.14) + "").c_str());//最大角度
        particleEmitter->AddConfig("ParticleZone", pointZone->GetConfig());//设置发射区域
        particleEmitter->AddConfig("Flow", DoubleToString(800 * mParticleNumScale).c_str());//发射数量(TODO: 中断发射)
        particleEmitter->AddConfig("MinForce", "1.5");//最小推力
        particleEmitter->AddConfig("MaxForce", "1.5");//最大推力
        //喷泉水花地面反弹
        //设置粒子区域对象
        BaseObjectCOMLib::IPositionPtr PlaneDirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr PlaneDirectVec = normalize(PlaneDirectPos->GetX(), PlaneDirectPos->GetY(), PlaneDirectPos->GetZ());//计算投影坐标单位向量
        ConfigOptionsCOMLib::IParticleZonePtr planeZone = map->CreateParticleZone();//创建粒子区域对象
        planeZone->AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone->AddConfig("Normal", (DoubleToString(PlaneDirectVec->GetX()) + "," + DoubleToString(PlaneDirectVec->GetY()) + "," + DoubleToString(PlaneDirectVec->GetZ())).c_str());//区域方向
        planeZone->AddConfig("Position", "0, -1, 0");//区域位置 (TODO: 不生效)
        //设置修改器
        ConfigOptionsCOMLib::IParticleModifierPtr particleModifier = map->CreateParticleModifier();//创建修改器
        particleModifier->AddConfig("ModifierType", "ObstacleModifier");//修改器类型
        particleModifier->AddConfig("ParticleZone", planeZone->GetConfig());//影响区域
        particleModifier->AddConfig("Trigger", "8");//触发信号(INTERSECT_ZONE)
        particleModifier->AddConfig("BouncingRatio", "0.2");//反弹系数
        particleModifier->AddConfig("Friction", "1.0");//速度因子
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr particleGroup = map->CreateParticleGroup();//创建粒子组
        particleGroup->AddConfig("Name", "Fountain");//粒子名称,与其他类型粒子不能重名
        particleGroup->AddConfig("Capacity", "5000");//粒子发射数量
        particleGroup->AddConfig("ParticleRender", particleRenderer->GetConfig());//配置粒子渲染类型
        particleGroup->AddConfig("ParticleModel", particleModel->GetConfig());//配置粒子模板
        particleGroup->AddConfig("ParticleEmitters", particleEmitter->GetConfig());//配置粒子发射器
        particleGroup->AddConfig("ParticleModifiers", particleModifier->GetConfig());//配置粒子修改器
        particleGroup->AddConfig("Gravity", (DoubleToString(-DirectVec->GetX()) + "," + DoubleToString(-DirectVec->GetY()) + "," + DoubleToString(-DirectVec->GetZ())).c_str());//重力方向
        particleGroup->AddConfig("ImageUrl", (dataPath + "texture\\fire_alpha.png").c_str());//资源路径
        particleGroup->AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup->AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup->AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        //粒子图层配置
        ConfigOptionsCOMLib::ILayerOptionsPtr tlo = map->CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo->AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo->AddConfig("ParticleGroups", particleGroup->GetConfig());//配置粒子组
        tlo->AddConfig("ParticlePosition", (DoubleToString(longlatPos->GetX()) + "," + DoubleToString(longlatPos->GetY()) + "," + DoubleToString(longlatPos->GetZ())).c_str());//粒子图层坐标(经纬度)
        BaseObjectCOMLib::ILayerObjectPtr particleFountainLayer = map->CreateLayer("ParticleSystemLayer", tlo);//创建喷泉粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[2] = particleFountainLayer;
        particleFountainLayer->AddObserver();
        map->AddLayer(particleFountainLayer);//添加粒子图层    
    }
}

double CParticleDlg::param(double min, double max){
    return min + rainRatio * (max - min);
}

//取单位向量用于控制方向
BaseObjectCOMLib::IPositionPtr CParticleDlg::normalize(double x,double y,double z){
    double length = sqrt(x * x + y * y + z * z );
    length = abs(length);
    double mx = x / length;
    double my = y / length;
    double mz = z / length;
    return map->CreatePosition(mx, my, mz);
}

double CParticleDlg::vectorDirection(double x1,double y1,double z1,double x2,double y2,double z2){
    double vec1 = sqrt(x1 * x1 + y1 * y1 + z1 * z1);
    vec1 = abs(vec1);
    double vec2 = sqrt(x2 * x2 + y2 * y2 + z2 * z2);
    vec2 = abs(vec2);
    double tmp = x1 * x2 + y1 * y2 + z1 * z2;
    return tmp / (vec1 * vec2);
}

//创建烟火
void CParticleDlg::createFire(std::string pos)
{
    if(layerMap[3] == NULL)
    {
        std::vector<std::string> screenPos;
        SplitString(pos,screenPos,",");
        //BaseObjectCOMLib::IPositionPtr longlatPos = transformate->ScreenPosToWorldPos(StringToInt(screenPos[0]), StringToInt(screenPos[1]));//将屏幕坐标点转换成经纬度坐标
        BaseObjectCOMLib::IPositionPtr longlatPos =map->CreatePosition(120.219194335872,30.210871230719,14.799973526038);//创建坐标对象 ;
        BaseObjectCOMLib::IPositionPtr worldPos = transformate->ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        BaseObjectCOMLib::IPositionPtr DirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr DirectVec = normalize(DirectPos->GetX(), DirectPos->GetY(), DirectPos->GetZ());//计算投影坐标单位向量
        BaseObjectCOMLib::IPositionPtr RecordPos = record(worldPos->GetX(), worldPos->GetY(), worldPos->GetZ());//配置区域
        BaseObjectCOMLib::IPositionPtr ZoneXYZPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(longlatPos->GetX(), longlatPos->GetY(), 20));//取投影坐标
        BaseObjectCOMLib::IPositionPtr ZonePos = map->CreatePosition(ZoneXYZPos->GetX() - worldPos->GetX(), ZoneXYZPos->GetY() - worldPos->GetY(), ZoneXYZPos->GetZ() - worldPos->GetZ());
        double scale = mSize / 1.4;
        if (abs(scale - 0.0) < 1.0e-6){
            scale = 1.0;
        }
        //火焰效果粒子组
        //创建粒子渲染类型
        ConfigOptionsCOMLib::IParticleRenderPtr mFireRenderer = map->CreateParticleRender();//建粒子渲染类型
        mFireRenderer->AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mFireRenderer->AddConfig("XScale", DoubleToString(0.3 * scale).c_str());//X轴缩放比例
        mFireRenderer->AddConfig("YScale", DoubleToString(0.3 * scale).c_str());//Y轴缩放比例
        mFireRenderer->AddConfig("TextureEnable", "true");//是否启用纹理
        mFireRenderer->AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mFireRenderer->AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        //建立粒子模板
        ConfigOptionsCOMLib::IParticleModelPtr mFireModel = map->CreateParticleModel();//创建粒子模板
        mFireModel->AddConfig("RedParam", "3;0.8,0.9,0.8,0.9");//红色参数
        mFireModel->AddConfig("GreenParam", "3;0.5,0.6,0.5,0.6");//绿色参数
        mFireModel->AddConfig("BlueParam", "0;0.3");//蓝色参数
        mFireModel->AddConfig("AlphaParam", "1;0.4,0.0");//透明参数
        mFireModel->AddConfig("SizeParam", "4;;0.5,2.0,5.0|1.0,0.0");//粒子大小
        mFireModel->AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mFireModel->AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mFireModel->AddConfig("MinLifeTime", "1");//最小生命周期
        mFireModel->AddConfig("MaxLifeTime", "1.5");//最大生命周期
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone1 = map->CreateParticleZone();//创建粒子区域
        zone1->AddConfig("ZoneType", "SphereZone");//创建区域类型
        zone1->AddConfig("Position", (DoubleToString(0 * DirectVec->GetX()) + "," + DoubleToString(-1 * DirectVec->GetY()) + "," + DoubleToString(0 * DirectVec->GetZ())).c_str());//区域坐标
        zone1->AddConfig("Radius", DoubleToString(0.5 * scale).c_str());//区域半径
        double direct1 = 1 - vectorDirection(DirectVec->GetX(), DirectVec->GetY(), DirectVec->GetZ(), 0, 1, 0);
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mFireEmitter1 = map->CreateParticleEmitter();//创建粒子发射器
        mFireEmitter1->AddConfig("EmitterType", "StraightEmitter");//粒子发射器类型a
        mFireEmitter1->AddConfig("Name", "mFireEmitter1");//发射器名称
        mFireEmitter1->AddConfig("Direction", (DoubleToString(DirectVec->GetX() * direct1) + "," + DoubleToString(DirectVec->GetY() * direct1) + "," + DoubleToString(DirectVec->GetZ() * direct1)).c_str());//发射方向 (0,1,0)
        mFireEmitter1->AddConfig("ParticleZone", zone1->GetConfig());//发射器区域
        mFireEmitter1->AddConfig("Flow", "40");//发射数量
        mFireEmitter1->AddConfig("MinForce", DoubleToString(1.0 * scale).c_str());//最小推力
        mFireEmitter1->AddConfig("MaxForce", DoubleToString(2.5 * scale).c_str());//最大推力
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone2 = map->CreateParticleZone();//创建粒子区域
        zone2->AddConfig("ZoneType", "SphereZone");//区域类型
        zone2->AddConfig("Position", (DoubleToString(0.15 * DirectVec->GetX()) + "," + DoubleToString(-1.2 * DirectVec->GetY()) + "," + DoubleToString(0.075 * DirectVec->GetZ())).c_str());//区域位置
        zone2->AddConfig("Radius", DoubleToString(0.1 * scale).c_str());//区域半径
        double direct2 = 1 - vectorDirection(DirectVec->GetX(), DirectVec->GetY(), DirectVec->GetZ(), 0, 0.6, 0);
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mFireEmitter2 = map->CreateParticleEmitter();//创建粒子发射器
        mFireEmitter2->AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter2->AddConfig("Name", "mFireEmitter2");//发射器名称
        mFireEmitter2->AddConfig("Direction", (DoubleToString(DirectVec->GetX() * direct2) + "," + DoubleToString(DirectVec->GetY() * direct2) + "," + DoubleToString(DirectVec->GetZ() * direct2)).c_str());//发射器方向
        mFireEmitter2->AddConfig("ParticleZone", zone2->GetConfig());//发射器区域
        mFireEmitter2->AddConfig("Flow", "15");//发射数量
        mFireEmitter2->AddConfig("MinForce", DoubleToString(0.5 * scale).c_str());//最小推力
        mFireEmitter2->AddConfig("MaxForce", DoubleToString(1.5 * scale).c_str());//最大推力
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone3 = map->CreateParticleZone();//创建粒子区域
        zone3->AddConfig("ZoneType", "SphereZone");//创建粒子区域类型
        zone3->AddConfig("Position", (DoubleToString(-0.375 * DirectVec->GetX()) + "," + DoubleToString(-1.15 * DirectVec->GetY()) + "," + DoubleToString(-0.375 * DirectVec->GetZ())).c_str());//区域坐标位置
        zone3->AddConfig("Radius", DoubleToString(0.3 * scale).c_str());//区域半径
        double direct3 = 1 - vectorDirection(DirectVec->GetX(), DirectVec->GetY(), DirectVec->GetZ(), -0.6, 0.8, -0.8);
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mFireEmitter3 = map->CreateParticleEmitter();//创建发射器
        mFireEmitter3->AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter3->AddConfig("Name", "mFireEmitter3");//发射器名称
        mFireEmitter3->AddConfig("Direction", (DoubleToString(DirectVec->GetX() * direct3) + "," + DoubleToString(DirectVec->GetY() * direct3) + "," + DoubleToString(DirectVec->GetZ() * direct3)).c_str());//发射器方向
        mFireEmitter3->AddConfig("ParticleZone", zone3->GetConfig());//发射区域
        mFireEmitter3->AddConfig("Flow", "15");//粒子数量
        mFireEmitter3->AddConfig("MinForce", DoubleToString(0.5 * scale).c_str());//最小推力
        mFireEmitter3->AddConfig("MaxForce", DoubleToString(1.5 * scale).c_str());//最大推力
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone4 = map->CreateParticleZone();//创建粒子区域
        zone4->AddConfig("ZoneType", "SphereZone");//区域类型
        zone4->AddConfig("Position", (DoubleToString(-0.255 * DirectVec->GetX()) + "," + DoubleToString(-1.2 * DirectVec->GetY()) + "," + DoubleToString(0.225 * DirectVec->GetZ())).c_str());//粒子区域位置
        zone4->AddConfig("Radius", DoubleToString(0.2 * scale).c_str());//区域半径
        double direct4 = 1 - vectorDirection(DirectVec->GetX(), DirectVec->GetY(), DirectVec->GetZ(), -0.8, 0.5, 0.2);
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mFireEmitter4 = map->CreateParticleEmitter();//创建粒子发射器
        mFireEmitter4->AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter4->AddConfig("Name", "mFireEmitter4");//发射器名称
        mFireEmitter4->AddConfig("Direction", (DoubleToString(DirectVec->GetX() * direct4) + "," + DoubleToString(DirectVec->GetY() * direct4) + "," + DoubleToString(DirectVec->GetZ() * direct4)).c_str());//发射器方向
        mFireEmitter4->AddConfig("ParticleZone", zone4->GetConfig());//发射器区域
        mFireEmitter4->AddConfig("Flow", "10");//发射器每秒发射粒子数
        mFireEmitter4->AddConfig("MinForce", DoubleToString(0.5 * scale).c_str());//最小推力
        mFireEmitter4->AddConfig("MaxForce", DoubleToString(1.5 * scale).c_str());//最大推力
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone5 = map->CreateParticleZone();//创建区域对象
        zone5->AddConfig("ZoneType", "SphereZone");//区域类型
        zone5->AddConfig("Position", (DoubleToString(-0.075 * DirectVec->GetX()) + "," + DoubleToString(-1.2 * DirectVec->GetY()) + "," + DoubleToString(-0.3 * DirectVec->GetZ())).c_str());//区域位置
        zone5->AddConfig("Radius", DoubleToString(0.2 * scale).c_str());//区域半径

        double direct5 = 1 - vectorDirection(DirectVec->GetX(), DirectVec->GetY(), DirectVec->GetZ(), 0.1, 0.8, -1.0);
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mFireEmitter5 = map->CreateParticleEmitter();//创建粒子发射器
        mFireEmitter5->AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter5->AddConfig("Name", "mFireEmitter5");//发射器名称
        mFireEmitter5->AddConfig("Direction", (DoubleToString(DirectVec->GetX() * direct5) + "," + DoubleToString(DirectVec->GetY() * direct5) + "," + DoubleToString(DirectVec->GetZ() * direct5)).c_str());//发射器方向
        mFireEmitter5->AddConfig("ParticleZone", zone5->GetConfig());//发射器区域
        mFireEmitter5->AddConfig("Flow", "10");//发射器每秒发射粒子数
        mFireEmitter5->AddConfig("MinForce", DoubleToString(0.5 * scale).c_str());//最小推力
        mFireEmitter5->AddConfig("MaxForce", DoubleToString(1.5 * scale).c_str());//最大推力
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr mFireGroup = map->CreateParticleGroup();//创建粒子组
        mFireGroup->AddConfig("Name", "Fire");//粒子名称,与其他类型粒子不能重名
        mFireGroup->AddConfig("Capacity", "1350");//粒子组粒子容量
        mFireGroup->AddConfig("ParticleRender", mFireRenderer->GetConfig());//粒子组绘制配置
        mFireGroup->AddConfig("ParticleModel", mFireModel->GetConfig());//粒子组模板配置
        mFireGroup->AddConfig("ParticleEmitters", mFireEmitter1->GetConfig() + mFireEmitter2->GetConfig() + mFireEmitter3->GetConfig() + mFireEmitter4->GetConfig() + mFireEmitter5->GetConfig());//粒子组发射器配置
        mFireGroup->AddConfig("Gravity", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY() * scale) + "," + DoubleToString(DirectVec->GetZ())).c_str());//重力方向
        mFireGroup->AddConfig("ImageUrl", (dataPath + "texture\\fire.bmp.dds").c_str());//粒子纹理
        mFireGroup->AddConfig("BlendMode", "770,1,1");//混合模式
        mFireGroup->AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mFireGroup->AddConfig("DepthBuffer", "0,1");//深度缓存
        //烟雾效果粒子组
        //创建粒子渲染类型
        ConfigOptionsCOMLib::IParticleRenderPtr mSmokeRenderer = map->CreateParticleRender();//建粒子渲染类型
        mSmokeRenderer->AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mSmokeRenderer->AddConfig("XScale", DoubleToString(0.3 * scale).c_str());//X轴缩放比例
        mSmokeRenderer->AddConfig("YScale", DoubleToString(0.3 * scale).c_str());//Y轴缩放比例
        mSmokeRenderer->AddConfig("TextureEnable", "true");//是否启用纹理
        mSmokeRenderer->AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mSmokeRenderer->AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        //建立粒子模板
        ConfigOptionsCOMLib::IParticleModelPtr mSmokeModel = map->CreateParticleModel();//创建粒子模板
        mSmokeModel->AddConfig("RedParam", "1;0.3,0.2");//红色参数
        mSmokeModel->AddConfig("GreenParam", "1;0.25,0.2");//绿色参数
        mSmokeModel->AddConfig("BlueParam", "0;0.2");//蓝色参数
        mSmokeModel->AddConfig("AlphaParam", "4;0.2,0.0;0.0,0.0|0.2,0.2|1.0,0.0");//透明度参数
        mSmokeModel->AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mSmokeModel->AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mSmokeModel->AddConfig("SizeParam", "1;5,10");//尺寸参数
        mSmokeModel->AddConfig("MinLifeTime", "5");//最大生命周期
        mSmokeModel->AddConfig("MaxLifeTime", "5");//最小生命周期
        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr smokeZone = map->CreateParticleZone();//创建粒子区域
        smokeZone->AddConfig("ZoneType", "SphereZone");//区域类型
        smokeZone->AddConfig("Position", "0,0,0");//区域位置
        smokeZone->AddConfig("Radius", DoubleToString(1.2 * scale).c_str());//区域半径
        //设置粒子发射器
        ConfigOptionsCOMLib::IParticleEmitterPtr mSmokeEmitter = map->CreateParticleEmitter();//创建粒子发射器
        mSmokeEmitter->AddConfig("EmitterType", "SphericEmitter");//发射器类型
        mSmokeEmitter->AddConfig("Name", "SmokeEmitter");//发射器名称
        mSmokeEmitter->AddConfig("Direction", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY() * scale) + "," + DoubleToString(DirectVec->GetZ())).c_str());//发射方向 (0,1,0)
        mSmokeEmitter->AddConfig("MinAngle", "0");//最小角度
        mSmokeEmitter->AddConfig("MaxAngle", "1.57");//最大角度
        mSmokeEmitter->AddConfig("ParticleZone", smokeZone->GetConfig());//发射器区域
        mSmokeEmitter->AddConfig("Flow", "25");//发射器每秒发射粒子数
        mSmokeEmitter->AddConfig("MinForce", DoubleToString(0.5*scale).c_str());//最小推力
        mSmokeEmitter->AddConfig("MaxForce", DoubleToString(1.0*scale).c_str());//最大推力
        //设置粒子组
        ConfigOptionsCOMLib::IParticleGroupPtr mSmokeGroup = map->CreateParticleGroup();//创建粒子组
        mSmokeGroup->AddConfig("Name", "Smoke");//粒子名称,与其他类型粒子不能重名
        mSmokeGroup->AddConfig("Capacity", "1350");//容量
        mSmokeGroup->AddConfig("ParticleRender", mSmokeRenderer->GetConfig());//绘制参数配置
        mSmokeGroup->AddConfig("ParticleModel", mSmokeModel->GetConfig());//模板参数配置
        mSmokeGroup->AddConfig("ParticleEmitters", mSmokeEmitter->GetConfig());//粒子发射器配置
        mSmokeGroup->AddConfig("Gravity", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY() * scale) + "," + DoubleToString(DirectVec->GetZ())).c_str());//重力方向 (0.0,0.4*scale,0.0)
        mSmokeGroup->AddConfig("ImageUrl", (dataPath + "texture\\fire_alpha.png").c_str());//粒子纹理配置
        mSmokeGroup->AddConfig("BlendMode", "770,1,1");//混合模式
        mSmokeGroup->AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mSmokeGroup->AddConfig("DepthBuffer", "0,1");//深度缓存
        //图层配置
        ConfigOptionsCOMLib::ILayerOptionsPtr tlo = map->CreateLayerOptions("particle");//创建粒子图层
        tlo->AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo->AddConfig("ParticlePosition", (DoubleToString(longlatPos->GetX()) + "," + DoubleToString(longlatPos->GetY()) + "," + DoubleToString(longlatPos->GetZ())).c_str());//粒子图层坐标(经纬度)
        tlo->AddConfig("ParticleGroups", mFireGroup->GetConfig() + mSmokeGroup->GetConfig());//粒子组配置
        //tlo.AddConfig("BlendMode", "770, 1");
        BaseObjectCOMLib::ILayerObjectPtr particleFireLayer = map->CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[3] = particleFireLayer;
        map->AddLayer(particleFireLayer);//添加粒子图层
    }
}

void CParticleDlg::createHydraulicGun()
{
    if(layerMap[4] == NULL)
    {
        BaseObjectCOMLib::IPositionPtr mStartLLHPoint = map->CreatePosition(startPos->GetX(), startPos->GetY(), startPos->GetZ() + 1);
        BaseObjectCOMLib::IPositionPtr mStartWorldPoint = transformate->ConvertLongLatHeightToXYZ(mStartLLHPoint);

        BaseObjectCOMLib::IPositionPtr mEndLLHPoint = map->CreatePosition(endPos->GetX(), endPos->GetY(), endPos->GetZ() + 1);
        BaseObjectCOMLib::IPositionPtr mEndWorldPoint = transformate->ConvertLongLatHeightToXYZ(mEndLLHPoint);

        BaseObjectCOMLib::IPositionPtr DirectPos = transformate->ConvertLongLatHeightToXYZ(map->CreatePosition(mStartLLHPoint->GetX(), mStartLLHPoint->GetY(), 0));//取投影坐标
        BaseObjectCOMLib::IPositionPtr DirectVec = normalize(DirectPos->GetX(), DirectPos->GetY(), DirectPos->GetZ());//计算投影坐标单位向量
        BaseObjectCOMLib::IPositionPtr DirectVec2 = normalize(mEndWorldPoint->GetX() - mStartWorldPoint->GetX(), mEndWorldPoint->GetY() - mStartWorldPoint->GetY(), mEndWorldPoint->GetZ() - mStartWorldPoint->GetZ());//计算投影坐标单位向量

        double fXSpeed = (mStartWorldPoint->GetX() - mEndWorldPoint->GetX()) / 4.0;
        double fYSpeed = (mStartWorldPoint->GetY() - mEndWorldPoint->GetY()) * 5.0 / 12.0;
        double fZSpeed = (mStartWorldPoint->GetZ() - mEndWorldPoint->GetZ()) / 4.0;

        double mForce = sqrt(pow(fXSpeed, 2) + pow(fYSpeed, 2) + pow(fZSpeed, 2));

        BaseObjectCOMLib::IPositionPtr mDirection = normalize(fXSpeed, fYSpeed, fZSpeed);

        double mGravity = abs(fYSpeed / 5.0);
        double mSize = mForce / 15;

        ConfigOptionsCOMLib::IParticleRenderPtr particleRenderer = map->CreateParticleRender();//建粒子渲染类型
        particleRenderer->AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer->AddConfig("XScale", "0.03");//X轴缩放比例
        particleRenderer->AddConfig("YScale", "0.03");//Y轴缩放比例
        //particleRenderer->AddConfig("AtlasDimensionX", "2");                                                                        
        //particleRenderer->AddConfig("AtlasDimensionY", "2");                                                                        
        particleRenderer->AddConfig("TextureEnable", "true");//是否启用纹理

        ConfigOptionsCOMLib::IParticleModelPtr particleModel = map->CreateParticleModel();//创建粒子模板
        particleModel->AddConfig("RedParam", "0;1");//红色参数
        particleModel->AddConfig("GreenParam", "0;1");//绿色参数
        particleModel->AddConfig("BlueParam", "0;1");//蓝色参数
        particleModel->AddConfig("AlphaParam", "0;0.8");//透明参数
        particleModel->AddConfig("MinLifeTime", "8.5");//最小生命周期
        particleModel->AddConfig("MaxLifeTime", "8.5");//最大生命周期

        //设置粒子区域对象
        ConfigOptionsCOMLib::IParticleZonePtr zone = map->CreateParticleZone();//创建粒子区域
        zone->AddConfig("ZoneType", "SphereZone");//创建区域类型
        zone->AddConfig("Position", "1, 1, 1");//区域坐标
        zone->AddConfig("Radius", "0.2");    

        ConfigOptionsCOMLib::IParticleEmitterPtr particleEmitter = map->CreateParticleEmitter();//创建区域发射器            
        particleEmitter->AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter->AddConfig("Direction", (DoubleToString(DirectVec2->GetX()) + "," + DoubleToString(DirectVec2->GetY()) + "," + DoubleToString(DirectVec2->GetZ())).c_str());//发射方向(0,1,0)
        particleEmitter->AddConfig("MinAngle", "0.0");//最小角度
        particleEmitter->AddConfig("MaxAngle", (DoubleToString(0.02 * 3.14) + "").c_str());//最大角度
        //particleEmitter.AddConfig("MaxAngle", "0.0");//最大角度
        particleEmitter->AddConfig("ParticleZone", zone->GetConfig());//设置发射区域
        particleEmitter->AddConfig("Flow", "12000");//发射数量
        particleEmitter->AddConfig("MinForce","12.5");//最小推力
        particleEmitter->AddConfig("MaxForce","12.5");//最大推力

        ConfigOptionsCOMLib::IParticleZonePtr planeZone = map->CreateParticleZone();//创建粒子区域对象
        planeZone->AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone->AddConfig("Normal", (DoubleToString(DirectVec->GetX()) + "," + DoubleToString(DirectVec->GetY()) + "," + DoubleToString(DirectVec->GetZ())).c_str());//区域方向
        planeZone->AddConfig("Position", "0,-10,0");

        ConfigOptionsCOMLib::IParticleGroupPtr particleGroup = map->CreateParticleGroup();//创建粒子组
        particleGroup->AddConfig("Name", "HydraulicGun");//粒子名称,与其他类型粒子不能重名
        particleGroup->AddConfig("Capacity", "80000");//粒子最大数量
        particleGroup->AddConfig("ParticleRender", particleRenderer->GetConfig());//配置粒子渲染类型
        particleGroup->AddConfig("ParticleModel", particleModel->GetConfig());//配置粒子模板
        particleGroup->AddConfig("ParticleEmitters", particleEmitter->GetConfig());//配置粒子发射器

        particleGroup->AddConfig("Gravity", (DoubleToString(-DirectVec->GetX()*3) + "," + DoubleToString(-DirectVec->GetY()*3) + "," + DoubleToString(-DirectVec->GetZ()*3)).c_str());//重力方向
        particleGroup->AddConfig("ImageUrl", (dataPath + "/texture/point.bmp.dds").c_str());//资源路径
        particleGroup->AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup->AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup->AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试

        ConfigOptionsCOMLib::ILayerOptionsPtr tlo = map->CreateLayerOptions("particle");//创建粒子图层
        tlo->AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型
        tlo->AddConfig("ParticleGroups", particleGroup->GetConfig());//设置粒子组配置
        tlo->AddConfig("ParticlePosition", (DoubleToString(mStartLLHPoint->GetX()) + "," + DoubleToString(mStartLLHPoint->GetY()) + "," + DoubleToString(mStartLLHPoint->GetZ())).c_str());//粒子图层坐标(经纬度)
        BaseObjectCOMLib::ILayerObjectPtr particleGunLayer = map->CreateLayer("ParticleSystemLayer", tlo);    
        map->AddLayer(particleGunLayer);
        layerMap[4] = particleGunLayer;
    }
}

//区域大小控制
BaseObjectCOMLib::IPositionPtr CParticleDlg::record(double x, double y,double z){
    double length = sqrt(x * x + y * y + z * z );
    length = abs(length);
    double factor = (5.0 / length) + 1;
    double mx = x * factor;
    double my = y * factor;
    double mz = z * factor;
    return map->CreatePosition(mx, my, mz);
}

void  CParticleDlg::SplitString(const std::string& s,std::vector<std::string>& v,const std::string& c)
{
    std::string::size_type pos1,pos2;
    pos2 = s.find(c);
    pos1 = 0;
    while(std::string::npos !=pos2)
    {
        v.push_back(s.substr(pos1,pos2-pos1));
        pos1 = pos2 + c.size();
        pos2= s.find(c,pos1);
    }
    if(pos1 !=s.length())
    {
        v.push_back(s.substr(pos1));
    }
}

std::string CParticleDlg::DoubleToString(DOUBLE num)
{
    std::stringstream streamStd;
    streamStd << num;
    return streamStd.str();
}

int CParticleDlg::StringToInt(std::string str)
{
    int num;
    std::stringstream streamStd(str);
    streamStd >> num;
    return num;
}

C#调用

bool state = false;
string dataPath = "D:\\SDK\\Data\\";
ILayerObject[] layerMap = new ILayerObject[5];
double rainRatio = 0.5;
double sizeRatio = 1.0;
double rainscale = 3.0;
IParticleRender dropRender;
IParticleEmitter dropEmitter;
IParticleRender splashRender;
IPosition startPos;
IPosition endPos;
ILayerObject particleGunLayer;
double mSize = 1;
bool fountainState = false;
bool fireState = false;
bool hGFirstState = false;
bool hGSecondState = false;
private void createParticleLayer_Click(object sender, EventArgs e)
{
    Console.WriteLine("Text:" + comboBox1.SelectedItem.ToString());
    switch (comboBox1.SelectedItem.ToString())
    {
        case "雨":
            createRain(); break;
        case "雪":
            createSnow(); break;
        case "喷泉":
            fountainState = true; break;
        case "火焰":
            fireState = true; break;
        case "水枪":
            {
                if (layerMap[4] == null)
                {
                    hGFirstState = true;
                }
                break;
            }
        default:
            break;
    }
}

private void axVPSDKCtrl1_FireOnLButtonUp(object sender, AxSDKCtrlLib._IVPSDKCtrlEvents_FireOnLButtonUpEvent e)
{
    if(fountainState){
        createFountain(e.xPos + "," + e.yPos );
        fountainState = false;
    }
    if(fireState){
        createFire(e.xPos + "," + e.yPos);
        fireState = false;
    }
    if(hGFirstState){
        startPos = transformate.ScreenPosToWorldPos(e.xPos, e.yPos);//将屏幕坐标点转换成经纬度坐标
        hGFirstState = false;
        hGSecondState = true;
        MessageBox.Show("请点击下一个点!");
        return;
    }
    if(hGSecondState){
        endPos = transformate.ScreenPosToWorldPos(e.xPos, e.yPos);//将屏幕坐标点转换成经纬度坐标
        hGSecondState = false;
        createHydraulicGun();
    }
}

private void removeParticleLayer_Click(object sender, EventArgs e)
{
    Console.WriteLine("Text:" + comboBox1.SelectedItem.ToString());
    int index = 0;
    switch (comboBox1.SelectedItem.ToString())
    {
        case "雨":
            index= 0; break;
        case "雪":
            index= 1; break;
        case "喷泉":
           index= 2; break;
        case "火焰":
            index= 3; break;
        case "水枪":
            index = 4;
                break;  
        default:
            break;
    }
    if (layerMap[index]!=null)
    {
        map.RemoveLayer(layerMap[index]);
        layerMap[index] = null;
    }
    else
    {
        MessageBox.Show("图层为空,无法移除!");
    }
}

//创建雨效
private void createRain()
{
    if(layerMap[0] == null){
        var longlatPos = transformate.ScreenPosToWorldPos(1237 / 2, 663 / 2);//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        //建粒子渲染类型
        var rainRender = map.CreateParticleRender();
        rainRender.AddConfig("RenderType", "ParticleLineRender");//创建线粒子渲染类型, ParticleLineRender代表线粒子渲染类型
        rainRender.AddConfig("Width", param(1.0, 4.0) * sizeRatio);//线宽(0-10)
        rainRender.AddConfig("Length", "-0.02");//线长
        //建立粒子模板 param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        //第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        //第二个参数第二部分标识参数具体值
        //第二个参数第三部分标识差值参数, 竖线(|)分割
        var rainParticleModel = map.CreateParticleModel();
        rainParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        rainParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        rainParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        rainParticleModel.AddConfig("AlphaParam", "0;0.3");
        rainParticleModel.AddConfig("MassParam", "2;" + param(0.4, 0.8) + "," + param(0.8, 1.6));
        //非 param 参数
        rainParticleModel.AddConfig("Immortal", "true");//永生参数
        //设置粒子区域对象
        var rainZone = map.CreateParticleZone();//创建发射区区域
        rainZone.AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        rainZone.AddConfig("Radius", "200");//区域半径
        rainZone.AddConfig("Position", ZonePos.GetX() + "," + ZonePos.GetY() + "," + ZonePos.GetZ());//区域位置 / 基准位置
        rainZone.AddConfig("AutoPosition", "true");//自动视野
        rainZone.AddConfig("Position", worldPos.GetX() + "," + worldPos.GetY() + "," + worldPos.GetZ());//区域位置 / 基准位置
        //设置粒子发射器
        var rainEmitter = map.CreateParticleEmitter();//创建发射器
        rainEmitter.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter.AddConfig("Name", "RainEmitter"); //雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        //基础参数
        rainEmitter.AddConfig("ParticleZone", rainZone.GetConfig());//配置发射区域
        rainEmitter.AddConfig("Flow", param(0.0, 2000.0 * rainscale));//发射器每秒发射粒子数
        rainEmitter.AddConfig("MinForce", param(5.0, 10.0));//最小推力
        rainEmitter.AddConfig("MaxForce", param(5.0, 10.0));//最大推力
        //子类参数
        rainEmitter.AddConfig("Direction", (-1 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (-1 * DirectVec.GetZ()));//发射器方向 0,-1,0   
        rainEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter.AddConfig("MaxAngle", "0.157");//发射器最大偏移角
        //设置粒子组
        var rainGroup = map.CreateParticleGroup();//创建粒子组
        rainGroup.AddConfig("Name", "Rain");//粒子名称,与其他类型粒子不能重名
        rainGroup.AddConfig("Capacity", "8000");//粒子组粒子容量
        rainGroup.AddConfig("ParticleRender", rainRender.GetConfig());//配置粒子渲染器
        rainGroup.AddConfig("ParticleModel", rainParticleModel.GetConfig());//配置粒子模板
        rainGroup.AddConfig("ParticleEmitters", rainEmitter.GetConfig());//配置粒子发射器
        rainGroup.AddConfig("Friction", "0.7");//摩擦力系数
        rainGroup.AddConfig("Gravity", (-20 * rainscale * DirectVec.GetX()) + "," + (-20 * rainscale * DirectVec.GetY()) + "," + (-20 * rainscale * DirectVec.GetZ()));//重力方向
        rainGroup.AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        rainGroup.AddConfig("CustomUpdateType", 2);//粒子更新类型
        //rainGroup.AddConfig("CustomParticlePosition", DirectPos.GetX() + "," + DirectPos.GetY() + "," + DirectPos.GetZ());//粒子更新位置
        rainGroup.AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        //粒子渲染类型  水花效果
        dropRender = map.CreateParticleRender();//建粒子渲染类型
        dropRender.AddConfig("RenderType", "ParticlePointRender");//创建点粒子渲染类型, ParticlePointRender代表点粒子渲染类型
        dropRender.AddConfig("Size", (2.0 * sizeRatio).ToString());//点的大小
        //粒子模板
        var dropParticleModel = map.CreateParticleModel();
        dropParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        dropParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        dropParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        dropParticleModel.AddConfig("AlphaParam", "0;0.6");
        dropParticleModel.AddConfig("MassParam", "2;" + param(0.4, 0.8) + "," + param(3.0, 4.0));
        dropParticleModel.AddConfig("MinLifeTime", param(0.05, 0.3));//最小生命周期
        dropParticleModel.AddConfig("MaxLifeTime", param(0.1, 0.5));//最大生命周期
        //粒子发射器
        dropEmitter = map.CreateParticleEmitter();
        dropEmitter.AddConfig("EmitterType", "SphericEmitter");//发射器类型
        dropEmitter.AddConfig("Name", "DropEmitter");//发射器名称
        dropEmitter.AddConfig("MinForce", (param(0.1, 1.0)).ToString());//最小推力
        dropEmitter.AddConfig("MaxForce", (param(0.2, 2.0)).ToString());//最大推力
        dropEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射器方向
        dropEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        dropEmitter.AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        //设置粒子组
        var dropGroup = map.CreateParticleGroup();
        dropGroup.AddConfig("Name", "Drop");//粒子名称,与其他类型粒子不能重名
        dropGroup.AddConfig("Capacity", "16000");
        dropGroup.AddConfig("ParticleRender", dropRender.GetConfig());
        dropGroup.AddConfig("ParticleModel", dropParticleModel.GetConfig());
        dropGroup.AddConfig("ParticleEmitters", dropEmitter.GetConfig());
        dropGroup.AddConfig("Friction", "0.7");
        dropGroup.AddConfig("Gravity", (-2 * DirectVec.GetX()) + "," + (-2 * DirectVec.GetY()) + "," + (-2 * DirectVec.GetZ()));
        //爆炸效果
        //粒子渲染类型
        splashRender = map.CreateParticleRender();//建粒子渲染类型
        splashRender.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        splashRender.AddConfig("XScale", "0.1");//X轴缩放比例
        splashRender.AddConfig("YScale", "0.1");//Y轴缩放比例
        splashRender.AddConfig("TextureEnable", "true");//是否启用纹理

        var splashParticleModel = map.CreateParticleModel();
        splashParticleModel.AddConfig("RedParam", "0;" + param(1.0, 0.40));
        splashParticleModel.AddConfig("GreenParam", "0;" + param(1.0, 0.40));
        splashParticleModel.AddConfig("BlueParam", "0;" + param(1.0, 0.42));
        splashParticleModel.AddConfig("AlphaParam", "1;1.0,0.0");
        splashParticleModel.AddConfig("SizeParam", "3;0,0," + param(0.375, 2.25) + "," + param(0.75, 3.78));//粒子大小
        splashParticleModel.AddConfig("AngleParam", "2;0.0,6.283");//粒子角度 1表示参数随机生成
        splashParticleModel.AddConfig("MinLifeTime", param(0.2, 0.3));
        splashParticleModel.AddConfig("MaxLifeTime", param(0.4, 0.5));

        var splashGroup = map.CreateParticleGroup();
        splashGroup.AddConfig("Name", "Splash");//粒子名称,与其他类型粒子不能重名
        splashGroup.AddConfig("Capacity", "2400");
        splashGroup.AddConfig("ParticleRender", splashRender.GetConfig());
        splashGroup.AddConfig("ParticleModel", splashParticleModel.GetConfig());
        splashGroup.AddConfig("ImageUrl", dataPath + "\\waterdrops.bmp.dds");//配置纹理
        splashGroup.AddConfig("BlendMode", "770,1,1");//设置混合模式

        //设置粒子发射器
        var rainEmitter2 = map.CreateParticleEmitter();//创建发射器
        rainEmitter2.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        rainEmitter2.AddConfig("Name", "RainEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        rainEmitter2.AddConfig("MinForce", param(0.1, 1.0));//最小推力
        rainEmitter2.AddConfig("MaxForce", param(0.2, 2.0));//最大推力
        rainEmitter2.AddConfig("Direction", (DirectVec.GetX()) + "," + (DirectVec.GetY()) + "," + (DirectVec.GetZ()));//发射器方向 0,-1,0   
        rainEmitter2.AddConfig("MinAngle", "0");//发射器最小偏移角
        rainEmitter2.AddConfig("MaxAngle", "0.628");//发射器最大偏移角

        var tlo = map.CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticleGroups", rainGroup.GetConfig() + dropGroup.GetConfig() + splashGroup.GetConfig());//配置粒子组
        tlo.AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo.AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo.AddConfig("CustomUpdateEmitter", rainEmitter2.GetConfig());//更新中使用的发射器
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + longlatPos.GetZ());//粒子图层坐标(经纬度)
        var particleRainLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[0] = particleRainLayer;
        particleRainLayer.AddObserver();
        map.AddLayer(particleRainLayer);//添加粒子图层  
    }else{
        MessageBox.Show("图层已存在,请勿重复创建!");
    }
}

//创建雪效
private void createSnow()
{
    if (layerMap[1] == null)
    {
        var longlatPos = transformate.ScreenPosToWorldPos(1237 / 2, 663 / 2);//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        //建粒子渲染类型
        var snowRender = map.CreateParticleRender();
        snowRender.AddConfig("RenderType", "ParticleQuadRender");
        snowRender.AddConfig("XScale", 1.0);
        snowRender.AddConfig("YScale", 1.0);
        snowRender.AddConfig("TextureEnable", "true");
        snowRender.AddConfig("AtlasDimensionX", 2);
        snowRender.AddConfig("AtlasDimensionY", 2);
        //建立粒子模板
        //param 参数
        /*第一个参数标识参数生成方式
         *    RedParam                红色参数
         *    GreenParam                绿色参数
         *    BlueParam                蓝色参数
         *    AlphaParam                透明度
         *    SizeParam                大小参数
         *    MassParam                质量参数        
         *    AngleParam                粒子角度
         *    TextureIndexParam        纹理参数
         *    RotationSpeedParam        速度参数
         *    Custom0Param            保留1
         *    Custom1Param            保留2
         *    Custom2Param            保留3
        */
        //第二个参数三部分组成, 分号(;)分割
        /* 第二个参数第一部分标识生成方式
         *   0 为 无生成方式
         *     1 为 线性生成方式
         *   2 为 随机生成方式
         *   4 为 差值生成方式
        类型值取上述类型之和 */
        //第二个参数第二部分标识参数具体值
        //第二个参数第三部分标识差值参数, 竖线(|)分割
        var snowParticleModel = map.CreateParticleModel();
        snowParticleModel.AddConfig("RedParam", "0;1");
        snowParticleModel.AddConfig("GreenParam", "0;1");
        snowParticleModel.AddConfig("BlueParam", "0;1");
        snowParticleModel.AddConfig("MassParam", "2;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        snowParticleModel.AddConfig("AlphaParam", "1;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        snowParticleModel.AddConfig("SizeParam", "1;" + param(0.5, 0.6) + "," + param(0.8, 1.0));
        //非 param 参数
        snowParticleModel.AddConfig("Immortal", "true");//永生参数
        //设置粒子区域对象
        var snowZone = map.CreateParticleZone();//创建发射区区域
        snowZone.AddConfig("ZoneType", "SphereZone");//创建球形区域类型, SphereZone代表球形区域类型
        snowZone.AddConfig("Radius", "200");//区域半径
        snowZone.AddConfig("Position", ZonePos.GetX() + "," + ZonePos.GetY() + "," + ZonePos.GetZ());//区域位置 / 基准位置
        snowZone.AddConfig("AutoPosition", "true");//自动视野
        snowZone.AddConfig("Position", worldPos.GetX() + "," + worldPos.GetY() + "," + worldPos.GetZ());//区域位置 / 基准位置


        //设置粒子发射器
        var snowEmitter = map.CreateParticleEmitter();//创建发射器
        snowEmitter.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter.AddConfig("Name", "RainEmitter");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        //基础参数
        snowEmitter.AddConfig("ParticleZone", snowZone.GetConfig());//配置发射区域
        snowEmitter.AddConfig("Flow", param(0.0, 2000.0));//发射器每秒发射粒子数
        snowEmitter.AddConfig("MinForce", param(0.3, 0.5));//最小推力
        snowEmitter.AddConfig("MaxForce", param(0.5, 0.7));//最大推力
        //子类参数
        snowEmitter.AddConfig("Direction", (-1 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (-1 * DirectVec.GetZ()));//发射器方向 0,-1,0   
        snowEmitter.AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter.AddConfig("MaxAngle", "0.157");//发射器最大偏移角

        //设置粒子组
        var snowGroup = map.CreateParticleGroup();//创建粒子组
        snowGroup.AddConfig("Name", "Snow");//粒子名称,与其他类型粒子不能重名
        snowGroup.AddConfig("Capacity", "8000");//粒子组粒子容量
        snowGroup.AddConfig("ParticleRender", snowRender.GetConfig());//配置粒子渲染器
        snowGroup.AddConfig("ParticleModel", snowParticleModel.GetConfig());//配置粒子模板
        snowGroup.AddConfig("ParticleEmitters", snowEmitter.GetConfig());//配置粒子发射器
        snowGroup.AddConfig("Friction", "0.7");//摩擦力系数
        snowGroup.AddConfig("Gravity", (-10 * DirectVec.GetX()) + "," + (-10 * DirectVec.GetY()) + "," + (-10 * DirectVec.GetZ()));//重力方向
        snowGroup.AddConfig("CustomUpdate", "true");//粒子更新开启 雨效雪效开启
        snowGroup.AddConfig("CustomUpdateType", 2);//粒子更新类型
        //snowGroup.AddConfig("CustomParticlePosition", DirectPos.GetX() + "," + DirectPos.GetY() + "," + DirectPos.GetZ());//粒子更新位置
        snowGroup.AddConfig("CustomParticlePosition", "0,0,30");//粒子更新位置(高度)
        snowGroup.AddConfig("ImageUrl", dataPath + "//SnowLarge.bmp.dds");//配置纹理
        snowGroup.AddConfig("BlendMode", "770,1,1");//设置混合模式
        snowGroup.AddConfig("DepthBuffer", "0,1");
        snowGroup.AddConfig("AlphaTest", "516,0.5,0,1");
        snowGroup.AddConfig("TextureEnv", "0,8448,1");
        snowGroup.AddConfig("TextureEnvFilter", "1,1");
        //设置粒子发射器
        var snowEmitter2 = map.CreateParticleEmitter();//创建发射器
        snowEmitter2.AddConfig("EmitterType", "SphericEmitter");//创建球形发射器,SphericEmitter代表球形发射器
        snowEmitter2.AddConfig("Name", "snowEmitter2");//雨粒子发射器名字,可取任意,但唯一,后期修改针对名字
        snowEmitter2.AddConfig("MinForce", param(0.1, 1.0));//最小推力
        snowEmitter2.AddConfig("MaxForce", param(0.2, 2.0));//最大推力
        snowEmitter2.AddConfig("Direction", (DirectVec.GetX()) + "," + (DirectVec.GetY()) + "," + (DirectVec.GetZ()));//发射器方向 0,-1,0   
        snowEmitter2.AddConfig("MinAngle", "0");//发射器最小偏移角
        snowEmitter2.AddConfig("MaxAngle", "0.628");//发射器最大偏移角
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层,给配置起个名称,任意名称
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticleGroups", snowGroup.GetConfig());//配置粒子组
        tlo.AddConfig("AlphaTest", "516,0.5,0,1");//设置alpha测试
        tlo.AddConfig("BlendMode", "770,771,1");//设置混合模式
        tlo.AddConfig("CustomUpdateEmitter", snowEmitter2.GetConfig());//更新中使用的发射器
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + longlatPos.GetZ());//粒子图层坐标(经纬度)
        var particleSnowLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[1] = particleSnowLayer;
        particleSnowLayer.AddObserver();
        map.AddLayer(particleSnowLayer);//添加粒子图层    
    }
    else
    {
        MessageBox.Show("图层已存在,请勿重复创建!");
    }
}

//创建喷泉
private void createFountain(string pos){
    if(layerMap[2] == null){
        var screenPos = pos.Split(',');
        var longlatPos = transformate.ScreenPosToWorldPos(int.Parse(screenPos[0]), int.Parse(screenPos[1]));//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());

        var mHeight = 1.0;            
        var mAngle = 3.14/2.0;            
        var mSplashHeight = 0.0;    

        var mGravityScale = 1.0;    
        var mAlphaScale = 1.0;        
        var mParticleNumScale = 1.0;

        var g = 9.8 * mGravityScale;
        var upTime = Math.Sqrt(2.0 * mHeight / g);
        var downTime = 1.05 * Math.Sqrt(2.0 * (mHeight - mSplashHeight) / g);
        var lifeTime = upTime + downTime;
        var force = upTime * g / Math.Cos(mAngle/2.0);
        var scale = Math.Sqrt(mHeight * 2.0 * upTime * force * Math.Sin(mAngle/2.0)) * 0.35;

        //创建粒子渲染类型
        //水滴样式
        IParticleRender particleRenderer;
        //Warning: 部分硬件不支持点粒子,使用四边形粒子代替(TODO)
        particleRenderer = map.CreateParticleRender();//建粒子渲染类型
        particleRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer.AddConfig("XScale", scale.ToString());//X轴缩放比例
        particleRenderer.AddConfig("YScale", scale.ToString());//Y轴缩放比例
        particleRenderer.AddConfig("TextureEnable", "true");//是否启用纹理
        particleRenderer.AddConfig("AtlasDimensionX", 2.ToString());
        particleRenderer.AddConfig("AtlasDimensionY", 2.ToString());
        //水滴颜色
        //建立粒子模板
        var particleModel = map.CreateParticleModel();//创建粒子模板
        particleModel.AddConfig("RedParam", "0;0.9,1.0,0.9,1.0");//红色参数
        particleModel.AddConfig("GreenParam", "0;0.9,1.0,0.9,1.0");//绿色参数
        particleModel.AddConfig("BlueParam", "0;0.9,1.0,0.9,1.0");    
        particleModel.AddConfig("TextureIndexParam", "0;0.0,4.0");    
        particleModel.AddConfig("AlphaParam", "4;3;0.0,0.06|0.6,0.2|0.85,0.08|1.0,0.04");//透明参数
        particleModel.AddConfig("SizeParam", "4;4;0.0,0.05|0.5,0.1|1.0,0.08");    
        particleModel.AddConfig("MinLifeTime", lifeTime + 3);//最小生命周期
        particleModel.AddConfig("MaxLifeTime", lifeTime + 3.5);//最大生命周期

        //喷泉圆锥发射区域
        //设置粒子区域对象        
        var pointZone = map.CreateParticleZone();//创建粒子区域
        pointZone.AddConfig("ZoneType", "PointZone");//创建点区域类型, PointZone代表点区域类型
        pointZone.AddConfig("Position", "0,0,0");//创建区域位置
        //设置粒子发射器
        var particleEmitter = map.CreateParticleEmitter();//创建区域发射器            
        particleEmitter.AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射方向(0,1,0)
        particleEmitter.AddConfig("MinAngle", 0.10 * 3.14 + "");//最小角度
        particleEmitter.AddConfig("MaxAngle", 0.15 * 3.14 + "");//最大角度
        particleEmitter.AddConfig("ParticleZone", pointZone.GetConfig());//设置发射区域
        particleEmitter.AddConfig("Flow", 800 * mParticleNumScale);//发射数量(TODO: 中断发射)
        particleEmitter.AddConfig("MinForce", 1.5);//最小推力
        particleEmitter.AddConfig("MaxForce", 1.5);//最大推力
        //喷泉水花地面反弹
        //设置粒子区域对象
        var PlaneDirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var PlaneDirectVec = normalize(PlaneDirectPos.GetX(), PlaneDirectPos.GetY(), PlaneDirectPos.GetZ());//计算投影坐标单位向量
        var planeZone = map.CreateParticleZone();//创建粒子区域对象
        planeZone.AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone.AddConfig("Normal", PlaneDirectVec.GetX() + "," + PlaneDirectVec.GetY() + "," + PlaneDirectVec.GetZ());//区域方向
        planeZone.AddConfig("Position", "0, -1, 0");//区域位置 (TODO: 不生效)
        //设置修改器
        var particleModifier = map.CreateParticleModifier();//创建修改器
        particleModifier.AddConfig("ModifierType", "ObstacleModifier");//修改器类型
        particleModifier.AddConfig("ParticleZone", planeZone.GetConfig());//影响区域
        particleModifier.AddConfig("Trigger", "8");//触发信号(INTERSECT_ZONE)
        particleModifier.AddConfig("BouncingRatio", "0.2");//反弹系数
        particleModifier.AddConfig("Friction", "1.0");//速度因子
        //设置粒子组
        var particleGroup = map.CreateParticleGroup();//创建粒子组
        particleGroup.AddConfig("Name", "Fountain");//粒子名称,与其他类型粒子不能重名
        particleGroup.AddConfig("Capacity", "5000");//粒子发射数量
        particleGroup.AddConfig("ParticleRender", particleRenderer.GetConfig());//配置粒子渲染类型
        particleGroup.AddConfig("ParticleModel", particleModel.GetConfig());//配置粒子模板
        particleGroup.AddConfig("ParticleEmitters", particleEmitter.GetConfig());//配置粒子发射器
        particleGroup.AddConfig("ParticleModifiers", particleModifier.GetConfig());//配置粒子修改器
        particleGroup.AddConfig("Gravity", (-DirectVec.GetX()) + "," + (-DirectVec.GetY()) + "," + (-DirectVec.GetZ()));//重力方向
        particleGroup.AddConfig("ImageUrl", dataPath + "\\fire_alpha.png");//资源路径
        particleGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        //粒子图层配置
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型
        tlo.AddConfig("ParticleGroups", particleGroup.GetConfig());//设置粒子组配置
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ() + 2));//粒子图层坐标(经纬度)
        var particleFountainLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建喷泉粒子图层
        layerMap[2] = particleFountainLayer;
        map.AddLayer(particleFountainLayer);//添加粒子图层
    }else{
        MessageBox.Show("图层已存在,请勿重复创建!");
    }
}

//创建烟火
private void createFire(string pos){
    if(layerMap[3] == null){
        var screenPos = pos.Split(',');
        var longlatPos = transformate.ScreenPosToWorldPos(int.Parse(screenPos[0]), int.Parse(screenPos[1]));//将屏幕坐标点转换成经纬度坐标
        var worldPos = transformate.ConvertLongLatHeightToXYZ(longlatPos);//经纬度转场景坐标
        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var RecordPos = record(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());//配置区域
        var ZoneXYZPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(longlatPos.GetX(), longlatPos.GetY(), 20));//取投影坐标
        var ZonePos = map.CreatePosition(ZoneXYZPos.GetX() - worldPos.GetX(), ZoneXYZPos.GetY() - worldPos.GetY(), ZoneXYZPos.GetZ() - worldPos.GetZ());
        var scale = mSize / 1.4;
        if (Math.Abs(scale - 0.0) < 1.0e-6){
            scale = 1.0;
        }
        //火焰效果粒子组
        //创建粒子渲染类型
        var mFireRenderer = map.CreateParticleRender();//建粒子渲染类型
        mFireRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mFireRenderer.AddConfig("XScale", 0.3 * scale);//X轴缩放比例
        mFireRenderer.AddConfig("YScale", 0.3 * scale);//Y轴缩放比例
        mFireRenderer.AddConfig("TextureEnable", "true");//是否启用纹理
        mFireRenderer.AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mFireRenderer.AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        //建立粒子模板
        var mFireModel = map.CreateParticleModel();//创建粒子模板
        mFireModel.AddConfig("RedParam", "3;0.8,0.9,0.8,0.9");//红色参数
        mFireModel.AddConfig("GreenParam", "3;0.5,0.6,0.5,0.6");//绿色参数
        mFireModel.AddConfig("BlueParam", "0;0.3");//蓝色参数
        mFireModel.AddConfig("AlphaParam", "1;0.4,0.0");//透明参数
        mFireModel.AddConfig("SizeParam", "4;;0.5,2.0,5.0|1.0,0.0");//粒子大小
        mFireModel.AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mFireModel.AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mFireModel.AddConfig("MinLifeTime", 1);//最小生命周期
        mFireModel.AddConfig("MaxLifeTime", 1.5);//最大生命周期
        //设置粒子区域对象
        var zone1 = map.CreateParticleZone();//创建粒子区域
        zone1.AddConfig("ZoneType", "SphereZone");//创建区域类型
        zone1.AddConfig("Position", (0 * DirectVec.GetX()) + "," + (-1 * DirectVec.GetY()) + "," + (0 * DirectVec.GetZ()));//区域坐标
        zone1.AddConfig("Radius", 0.5 * scale);//区域半径
        var direct1 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0, 1, 0);
        //设置粒子发射器
        var mFireEmitter1 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter1.AddConfig("EmitterType", "StraightEmitter");//粒子发射器类型
        mFireEmitter1.AddConfig("Name", "mFireEmitter1");//发射器名称
        mFireEmitter1.AddConfig("Direction", (DirectVec.GetX() * direct1) + "," + (DirectVec.GetY() * direct1) + "," + (DirectVec.GetZ() * direct1));//发射方向 (0,1,0)
        //mFireEmitter1.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//发射方向 (0,1,0)
        mFireEmitter1.AddConfig("ParticleZone", zone1.GetConfig());//发射器区域
        mFireEmitter1.AddConfig("Flow", 40);//发射数量
        mFireEmitter1.AddConfig("MinForce", 1.0 * scale);//最小推力
        mFireEmitter1.AddConfig("MaxForce", 2.5 * scale);//最大推力
        //设置粒子区域对象
        var zone2 = map.CreateParticleZone();//创建粒子区域
        zone2.AddConfig("ZoneType", "SphereZone");//区域类型
        zone2.AddConfig("Position", (0.15 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (0.075 * DirectVec.GetZ()));//区域位置
        zone2.AddConfig("Radius", 0.1 * scale);//区域半径
        var direct2 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0, 0.6, 0);
        //设置粒子发射器
        var mFireEmitter2 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter2.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter2.AddConfig("Name", "mFireEmitter2");//发射器名称
        mFireEmitter2.AddConfig("Direction", (DirectVec.GetX() * direct2) + "," + (DirectVec.GetY() * direct2) + "," + (DirectVec.GetZ() * direct2));//发射器方向
        mFireEmitter2.AddConfig("ParticleZone", zone2.GetConfig());//发射器区域
        mFireEmitter2.AddConfig("Flow", 15);//发射数量
        mFireEmitter2.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter2.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //设置粒子区域对象
        var zone3 = map.CreateParticleZone();//创建粒子区域
        zone3.AddConfig("ZoneType", "SphereZone");//创建粒子区域类型
        zone3.AddConfig("Position", (-0.375 * DirectVec.GetX()) + "," + (-1.15 * DirectVec.GetY()) + "," + (-0.375 * DirectVec.GetZ()));//区域坐标位置
        zone3.AddConfig("Radius", 0.3 * scale);//区域半径
        var direct3 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), -0.6, 0.8, -0.8);
        //设置粒子发射器
        var mFireEmitter3 = map.CreateParticleEmitter();//创建发射器
        mFireEmitter3.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter3.AddConfig("Name", "mFireEmitter3");//发射器名称
        mFireEmitter3.AddConfig("Direction", (DirectVec.GetX() * direct3) + "," + (DirectVec.GetY() * direct3) + "," + (DirectVec.GetZ() * direct3));//发射器方向
        mFireEmitter3.AddConfig("ParticleZone", zone3.GetConfig());//发射区域
        mFireEmitter3.AddConfig("Flow", 15);//粒子数量
        mFireEmitter3.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter3.AddConfig("MaxForce", 1.5 * scale);//最大推力

        //设置粒子区域对象
        var zone4 = map.CreateParticleZone();//创建粒子区域
        zone4.AddConfig("ZoneType", "SphereZone");//区域类型
        zone4.AddConfig("Position", (-0.255 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (0.225 * DirectVec.GetZ()));//粒子区域位置
        zone4.AddConfig("Radius", 0.2 * scale);//区域半径

        var direct4 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), -0.8, 0.5, 0.2);
        //设置粒子发射器
        var mFireEmitter4 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter4.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter4.AddConfig("Name", "mFireEmitter4");//发射器名称
        mFireEmitter4.AddConfig("Direction", (DirectVec.GetX() * direct4) + "," + (DirectVec.GetY() * direct4) + "," + (DirectVec.GetZ() * direct4));//发射器方向
        mFireEmitter4.AddConfig("ParticleZone", zone4.GetConfig());//发射器区域
        mFireEmitter4.AddConfig("Flow", 10);//发射器每秒发射粒子数
        mFireEmitter4.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter4.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //设置粒子区域对象
        var zone5 = map.CreateParticleZone();//创建区域对象
        zone5.AddConfig("ZoneType", "SphereZone");//区域类型
        zone5.AddConfig("Position", (-0.075 * DirectVec.GetX()) + "," + (-1.2 * DirectVec.GetY()) + "," + (-0.3 * DirectVec.GetZ()));//区域位置
        zone5.AddConfig("Radius", 0.2 * scale);//区域半径

        var direct5 = 1 - vectorDirection(DirectVec.GetX(), DirectVec.GetY(), DirectVec.GetZ(), 0.1, 0.8, -1.0);
        //设置粒子发射器
        var mFireEmitter5 = map.CreateParticleEmitter();//创建粒子发射器
        mFireEmitter5.AddConfig("EmitterType", "StraightEmitter");//发射器类型
        mFireEmitter5.AddConfig("Name", "mFireEmitter5");//发射器名称
        mFireEmitter5.AddConfig("Direction", (DirectVec.GetX() * direct5) + "," + (DirectVec.GetY() * direct5) + "," + (DirectVec.GetZ() * direct5));//发射器方向
        mFireEmitter5.AddConfig("ParticleZone", zone5.GetConfig());//发射器区域
        mFireEmitter5.AddConfig("Flow", 10);//发射器每秒发射粒子数
        mFireEmitter5.AddConfig("MinForce", 0.5 * scale);//最小推力
        mFireEmitter5.AddConfig("MaxForce", 1.5 * scale);//最大推力
        //设置粒子组
        var mFireGroup = map.CreateParticleGroup();//创建粒子组
        mFireGroup.AddConfig("Name", "Fire");//粒子名称,与其他类型粒子不能重名
        mFireGroup.AddConfig("Capacity", "1350");//粒子组粒子容量
        mFireGroup.AddConfig("ParticleRender", mFireRenderer.GetConfig());//粒子组绘制配置
        mFireGroup.AddConfig("ParticleModel", mFireModel.GetConfig());//粒子组模板配置
        mFireGroup.AddConfig("ParticleEmitters", mFireEmitter1.GetConfig() + mFireEmitter2.GetConfig() + mFireEmitter3.GetConfig() + mFireEmitter4.GetConfig() + mFireEmitter5.GetConfig());//粒子组发射器配置
        //mFireGroup.AddConfig("Gravity", 0.0 + "," + 3.0 * scale + "," + 0.0);//重力方向
        mFireGroup.AddConfig("Gravity", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//重力方向
        mFireGroup.AddConfig("ImageUrl", dataPath + "texture\\fire.bmp.dds");//粒子纹理
        mFireGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        mFireGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mFireGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        //烟雾效果粒子组
        //创建粒子渲染类型
        var mSmokeRenderer = map.CreateParticleRender();//建粒子渲染类型
        mSmokeRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型
        mSmokeRenderer.AddConfig("XScale", 0.3 * scale);//X轴缩放比例
        mSmokeRenderer.AddConfig("YScale", 0.3 * scale);//Y轴缩放比例
        mSmokeRenderer.AddConfig("TextureEnable", "true");//是否启用纹理
        mSmokeRenderer.AddConfig("AtlasDimensionX", "2");//纹理切割x向切割数
        mSmokeRenderer.AddConfig("AtlasDimensionY", "2");//纹理切割y向切割数
        //建立粒子模板
        var mSmokeModel = map.CreateParticleModel();//创建粒子模板
        mSmokeModel.AddConfig("RedParam", "1;0.3,0.2");//红色参数
        mSmokeModel.AddConfig("GreenParam", "1;0.25,0.2");//绿色参数
        mSmokeModel.AddConfig("BlueParam", "0;0.2");//蓝色参数
        mSmokeModel.AddConfig("AlphaParam", "4;0.2,0.0;0.0,0.0|0.2,0.2|1.0,0.0");//透明度参数
        mSmokeModel.AddConfig("AngleParam", "3;0.0,6.28,0.0,6.28");//角度参数
        mSmokeModel.AddConfig("TextureIndexParam", "2;0,4.0");//纹理参数
        mSmokeModel.AddConfig("SizeParam", "1;5,10");//尺寸参数
        mSmokeModel.AddConfig("MinLifeTime", 5);//最大生命周期
        mSmokeModel.AddConfig("MaxLifeTime", 5);//最小生命周期
        //设置粒子区域对象
        var smokeZone = map.CreateParticleZone();//创建粒子区域
        smokeZone.AddConfig("ZoneType", "SphereZone");//区域类型
        smokeZone.AddConfig("Position", "0,0,0");//区域位置
        smokeZone.AddConfig("Radius", 1.2 * scale);//区域半径
        //设置粒子发射器
        var mSmokeEmitter = map.CreateParticleEmitter();//创建粒子发射器
        mSmokeEmitter.AddConfig("EmitterType", "SphericEmitter");//发射器类型
        mSmokeEmitter.AddConfig("Name", "SmokeEmitter");//发射器名称
        mSmokeEmitter.AddConfig("Direction", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//发射方向 (0,1,0)
        mSmokeEmitter.AddConfig("MinAngle", "0");//最小角度
        mSmokeEmitter.AddConfig("MaxAngle", "1.57");//最大角度
        mSmokeEmitter.AddConfig("ParticleZone", smokeZone.GetConfig());//发射器区域
        mSmokeEmitter.AddConfig("Flow", 25);//发射器每秒发射粒子数
        mSmokeEmitter.AddConfig("MinForce", 0.5*scale);//最小推力
        mSmokeEmitter.AddConfig("MaxForce", 1.0*scale);//最大推力
        //设置粒子组
        var mSmokeGroup = map.CreateParticleGroup();//创建粒子组
        mSmokeGroup.AddConfig("Name", "Smoke");//粒子名称,与其他类型粒子不能重名
        mSmokeGroup.AddConfig("Capacity", "1350");//容量
        mSmokeGroup.AddConfig("ParticleRender", mSmokeRenderer.GetConfig());//绘制参数配置
        mSmokeGroup.AddConfig("ParticleModel", mSmokeModel.GetConfig());//模板参数配置
        mSmokeGroup.AddConfig("ParticleEmitters", mSmokeEmitter.GetConfig());//粒子发射器配置
        mSmokeGroup.AddConfig("Gravity", DirectVec.GetX() + "," + DirectVec.GetY() * scale + "," + DirectVec.GetZ());//重力方向 (0.0,0.4*scale,0.0)
        mSmokeGroup.AddConfig("ImageUrl", dataPath + "\\fire_alpha.png");//粒子纹理配置
        mSmokeGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        mSmokeGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试
        mSmokeGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        //图层配置
        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型, ParticleSystemLayerOptions代表粒子图层数据配置
        tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ()  ));//粒子图层坐标(经纬度)
        tlo.AddConfig("ParticleGroups", mFireGroup.GetConfig() + mSmokeGroup.GetConfig());//粒子组配置
        //tlo.AddConfig("BlendMode", "770, 1");
        var particleFireLayer = map.CreateLayer("ParticleSystemLayer", tlo);//创建雨效粒子图层,第一项参数必须为ParticleSystemLayer
        layerMap[3] = particleFireLayer;
        map.AddLayer(particleFireLayer);//添加粒子图层
    }else{
        MessageBox.Show("图层已存在,请勿重复创建!");
    }
}

//创建水枪
private void createHydraulicGun()
{
    if (layerMap[4] == null)
    {
        var mStartLLHPoint = map.CreatePosition(startPos.GetX(), startPos.GetY(), startPos.GetZ() + 1);
        var mStartWorldPoint = transformate.ConvertLongLatHeightToXYZ(mStartLLHPoint);

        var mEndLLHPoint = map.CreatePosition(endPos.GetX(), endPos.GetY(), endPos.GetZ() + 1);
        var mEndWorldPoint = transformate.ConvertLongLatHeightToXYZ(mEndLLHPoint);

        var DirectPos = transformate.ConvertLongLatHeightToXYZ(map.CreatePosition(mStartLLHPoint.GetX(), mStartLLHPoint.GetY(), 0));//取投影坐标
        var DirectVec = normalize(DirectPos.GetX(), DirectPos.GetY(), DirectPos.GetZ());//计算投影坐标单位向量
        var DirectVec2 = normalize(mEndWorldPoint.GetX() - mStartWorldPoint.GetX(), mEndWorldPoint.GetY() - mStartWorldPoint.GetY(), mEndWorldPoint.GetZ() - mStartWorldPoint.GetZ());//计算投影坐标单位向量

        var fXSpeed = (mStartWorldPoint.GetX() - mEndWorldPoint.GetX()) / 4.0;
        var fYSpeed = (mStartWorldPoint.GetY() - mEndWorldPoint.GetY()) * 5.0 / 12.0;
        var fZSpeed = (mStartWorldPoint.GetZ() - mEndWorldPoint.GetZ()) / 4.0;

        var mForce = Math.Sqrt(Math.Pow(fXSpeed, 2) + Math.Pow(fYSpeed, 2) + Math.Pow(fZSpeed, 2));

        var mDirection = normalize(fXSpeed, fYSpeed, fZSpeed);

        var mGravity = Math.Abs(fYSpeed / 5.0);
        var mSize = mForce / 15;

        var particleRenderer = map.CreateParticleRender();//建粒子渲染类型
        particleRenderer.AddConfig("RenderType", "ParticleQuadRender");//创建四边形粒子渲染类型, ParticleQuadRenderer代表四边形粒子渲染类型
        particleRenderer.AddConfig("XScale", "0.03");//X轴缩放比例
        particleRenderer.AddConfig("YScale", "0.03");//Y轴缩放比例
        //particleRenderer.AddConfig("AtlasDimensionX", "2");                                                                        
        //particleRenderer.AddConfig("AtlasDimensionY", "2");                                                                        
        particleRenderer.AddConfig("TextureEnable", "true");//是否启用纹理

        var particleModel = map.CreateParticleModel();//创建粒子模板
        particleModel.AddConfig("RedParam", "0;1");//红色参数
        particleModel.AddConfig("GreenParam", "0;1");//绿色参数
        particleModel.AddConfig("BlueParam", "0;1");//蓝色参数
        particleModel.AddConfig("AlphaParam", "0;0.8");//透明参数
        particleModel.AddConfig("MinLifeTime", "8.5");//最小生命周期
        particleModel.AddConfig("MaxLifeTime", "8.5");//最大生命周期

        //设置粒子区域对象
        var zone = map.CreateParticleZone();//创建粒子区域
        //zone.AddConfig("ZoneType", "PointZone");//创建区域类型
        zone.AddConfig("ZoneType", "SphereZone");//创建区域类型
        //zone.AddConfig("Position", (1 * mStartWorldPoint.GetX()) + "," + (1 * mStartWorldPoint.GetY()) + "," + (1 * mStartWorldPoint.GetZ()));//区域坐标
        zone.AddConfig("Position", "1, 1, 1");//区域坐标
        zone.AddConfig("Radius", 0.2);

        var particleEmitter = map.CreateParticleEmitter();//创建区域发射器            
        particleEmitter.AddConfig("EmitterType", "SphericEmitter");//创建发射器类型
        particleEmitter.AddConfig("Direction", DirectVec2.GetX() + "," + DirectVec2.GetY() + "," + DirectVec2.GetZ());//发射方向(0,1,0)
        particleEmitter.AddConfig("MinAngle", "0.0");//最小角度
        particleEmitter.AddConfig("MaxAngle", 0.02 * 3.14 + "");//最大角度
        //particleEmitter.AddConfig("MaxAngle", "0.0");//最大角度
        particleEmitter.AddConfig("ParticleZone", zone.GetConfig());//设置发射区域
        particleEmitter.AddConfig("Flow", "12000");//发射数量
        particleEmitter.AddConfig("MinForce", "12.5");//最小推力
        particleEmitter.AddConfig("MaxForce", "12.5");//最大推力


        var planeZone = map.CreateParticleZone();//创建粒子区域对象
        planeZone.AddConfig("ZoneType", "PlaneZone");//创建平面区域类型, PlaneZone代表平面区域类型
        planeZone.AddConfig("Normal", DirectVec.GetX() + "," + DirectVec.GetY() + "," + DirectVec.GetZ());//区域方向
        //planeZone.AddConfig("Position", "" + ModifierPos.GetX() - mStartWorldPoint.GetX() + "," + ModifierPos.GetY() - mStartWorldPoint.GetY() 
        //+ "," + ModifierPos.GetZ() - mStartWorldPoint.GetZ());//区域位置 
        planeZone.AddConfig("Position", "0,-10,0");


        var particleGroup = map.CreateParticleGroup();//创建粒子组
        particleGroup.AddConfig("Name", "HydraulicGun");//粒子名称,与其他类型粒子不能重名
        particleGroup.AddConfig("Capacity", "80000");//粒子最大数量
        particleGroup.AddConfig("ParticleRender", particleRenderer.GetConfig());//配置粒子渲染类型
        particleGroup.AddConfig("ParticleModel", particleModel.GetConfig());//配置粒子模板
        particleGroup.AddConfig("ParticleEmitters", particleEmitter.GetConfig());//配置粒子发射器

        particleGroup.AddConfig("Gravity", (-DirectVec.GetX() * 3) + "," + (-DirectVec.GetY() * 3) + "," + (-DirectVec.GetZ() * 3));//重力方向
        particleGroup.AddConfig("ImageUrl", dataPath + "\\point.bmp.dds");//资源路径
        particleGroup.AddConfig("BlendMode", "770,1,1");//混合模式
        particleGroup.AddConfig("DepthBuffer", "0,1");//深度缓存
        particleGroup.AddConfig("AlphaTest", "516,0.5,0,1");//alpha测试

        var tlo = map.CreateLayerOptions("particle");//创建粒子图层
        tlo.AddConfig("LayerOptionsName", "ParticleSystemLayerOptions");//创建配置类型
        tlo.AddConfig("ParticleGroups", particleGroup.GetConfig());//设置粒子组配置
        //tlo.AddConfig("ParticlePosition", longlatPos.GetX() + "," + longlatPos.GetY() + "," + (longlatPos.GetZ() + 2));//粒子图层坐标(经纬度)
        tlo.AddConfig("ParticlePosition", mStartLLHPoint.GetX() + "," + mStartLLHPoint.GetY() + "," + (mStartLLHPoint.GetZ()));//粒子图层坐标(经纬度)
        particleGunLayer = map.CreateLayer("ParticleSystemLayer", tlo);
        map.AddLayer(particleGunLayer);
        layerMap[4] = particleGunLayer;
    }
    else
    {
        MessageBox.Show("图层已存在,请勿重复创建!");
    }
}

//取单位向量用于控制方向
private IPosition normalize(double x, double y, double z)
{
    var length = Math.Sqrt(x * x + y * y + z * z );
    var mx = x / length;
    var my = y / length;
    var mz = z / length;
    return map.CreatePosition(mx, my, mz);
}

//区域大小控制
private IPosition record(double x, double y, double z){
    var length = Math.Sqrt(x * x + y * y + z * z);
    var factor = (5.0 / length) + 1;
    var mx = x * factor;
    var my = y * factor;
    var mz = z * factor;
    return map.CreatePosition(mx, my, mz);
}

private double vectorDirection(double x1, double y1, double z1, double x2, double y2, double z2)
{
    var vec1 = Math.Sqrt(x1 * x1 + y1 * y1 + z1 * z1);
    var vec2 = Math.Sqrt(x2 * x2 + y2 * y2 + z2 * z2);
    var tmp = x1 * x2 + y1 * y2 + z1 * z2;
    return tmp / (vec1 * vec2);
}

private double param(double min, double max)
{
    return min + rainRatio * (max - min);
}

results matching ""

    No results matching ""