1. 程式人生 > >skyline粒子效果xml獲取

skyline粒子效果xml獲取

lee 對象 null user xml文件 rate ble explorer pos

skyline的粒子效果是有一堆復雜的xml配置而成,代碼創建的時候需要根據xml來生成對象,鑒於xml格式官方並沒詳細提供,可以先用terraexplorer手動創建一個粒子效果對象,再用代碼去找到這個對象,獲取對象中的xml文件信息,具體的代碼如下(C#版本):

 //查找對象
 string _itemid = _sgworld.ProjectTree.FindItem(@"粒子效果\效果");
            if (!string.IsNullOrEmpty(_itemid))
            {
            //找到轉換對象
                var _teObj = _sgworld.ProjectTree.GetObject(_itemid);
                ITerrainEffect70 _teffect = _teObj as ITerrainEffect70;
                 //獲取對象中的xml信息
                ITerrainLabel70 _label = _teObj as ITerrainLabel70;
                 string _effectXml = _teffect.EffectXML;
                //根據文本信息,設置xml中的屬性
                 string _effnew = "$$PARTICLE$$UserDefine: <?xml version='1.0' encoding='UTF-8'?><Particle ID='Custom'><ParticleEmitter ID='ring' NumParticles='355' Texture='smoke.png'><Emitter Rate='157' Shape='One' SpeedShape='One' Scale='0,0,0' Speed='0.04,-0.01,-0.04' /><Cycle Value='1' /><Sort Value='1' /><Render Value='Horizontal' /><Gravity Value='2, 0, 0' /><Force Value='0' OverrideRotation='0' /><Position Value='0, 0, 0' /><Life Value='3.75' /><Speed Value='0.31' /><Color Value='20,255,255,255' /><Size Value='1.2,1.2' /><Drag Value='0' /><Blend Type='' /><Fade FadeIn='0.69' FadeOut='0.78' MaxFade='0.2' /></ParticleEmitter></Particle>";
                //創建動態效果
                 var _pos = _sgworld.Window.CenterPixelToWorld(WorldPointType.WPT_TERRAIN).Position;
                 var _teff1 = _sgworld.Creator.CreateEffect(_sgworld.Creator.CreatePosition(_pos.X, _pos.Y, 100, AltitudeTypeCode.ATC_TERRAIN_RELATIVE), _effnew);
                  
            }


skyline粒子效果xml獲取