/// <summary> /// Metoda se postara o nacteni vsech zdroju z xml do sceny /// </summary> /// <param name="url">Cesta k xml popisujicimu scenu</param> public void LoadSceneFromXml(String url) { sceneManager.Clear(); Logger.AddInfo("Nacitani data.xml"); data = new DataControl(device, sceneManager.GetSharedPool()); List <Entity> entity = data.LoadXML(url); Type objectType; Object[] par; ConstructorInfo[] constructorInfo; ParameterInfo[] parameters; Assembly asm = Assembly.GetExecutingAssembly(); foreach (Entity obj in entity) { List <Parametr> entityParameters = obj.GetParametrs(); if (obj.Type == "Microsoft.DirectX.Direct3D.Effect") { foreach (Parametr v in entityParameters) { sceneManager.AddEffect(v.name, v.value as Effect); } continue; } objectType = asm.GetType(obj.Type); constructorInfo = objectType.GetConstructors(); List <Object> objPar = new List <object>(); foreach (ConstructorInfo constructor in constructorInfo) { objPar.Clear(); parameters = constructor.GetParameters(); foreach (ParameterInfo param in parameters) { if (param.ParameterType.ToString() == "Microsoft.DirectX.Direct3D.Device") { objPar.Add(device); } else if (param.ParameterType.ToString() == "WiccanRede.Scene.SceneManager") { objPar.Add(sceneManager); } else { Parametr obj2 = obj[param.Name]; if (obj2 != null) { objPar.Add(obj2.value); } else { objPar.Add(null); } } } } par = objPar.ToArray(); Effect shader = null; foreach (Parametr p in entityParameters) { if (p.type == "Microsoft.DirectX.Direct3D.Effect") { shader = p.value as Effect; } else if (p.name.ToLower() == "shader") { shader = sceneManager[p.value as String]; } } String name = obj.Type; if (obj["name"] != null) { name = obj["name"].value as String; } bool shadowEmitter = true; if (obj["shadowEmitter"] != null) { shadowEmitter = (bool)obj["shadowEmitter"].value; } sceneManager.AddObject(name, Activator.CreateInstance(objectType, par) as GeneralObject, shader, shadowEmitter); } }