/// <summary> /// Lädt ein Modell aus einer Datei /// </summary> /// <param name="name">Name des Modells</param> /// <param name="filename">Datei des Modells</param> /// <param name="callerName"></param> public static void LoadModelFromFile(string name, string filename, [CallerMemberName] string callerName = "") { if (callerName != "Prepare") { HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromFile()", "This method may only be called from the Prepare() method."); return; } if (KWEngine.Models.ContainsKey(name.Trim())) { HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromFile()", "Model name already exists."); return; } GeoModel m = SceneImporter.LoadModel(filename, true, SceneImporter.AssemblyMode.File); if (m != null) { name = name.Trim(); m.Name = name; lock (KWEngine.Models) { KWEngine.Models.Add(name, m); } } }
internal static void InitializeModels() { Models.Add("KWCube", SceneImporter.LoadModel("kwcube.obj", false, SceneImporter.AssemblyMode.Internal)); Models.Add("KWCube6", SceneImporter.LoadModel("kwcube6.obj", false, SceneImporter.AssemblyMode.Internal)); KWRect = SceneImporter.LoadModel("kwrect.obj", false, SceneImporter.AssemblyMode.Internal); Models.Add("KWSphere", SceneImporter.LoadModel("kwsphere.obj", false, SceneImporter.AssemblyMode.Internal)); KWStar = SceneImporter.LoadModel("star.obj", false, SceneImporter.AssemblyMode.Internal); Models.Add("KWStar", KWStar); KWHeart = SceneImporter.LoadModel("heart.obj", false, SceneImporter.AssemblyMode.Internal); Models.Add("KWHeart", KWHeart); KWSkull = SceneImporter.LoadModel("skull.obj", false, SceneImporter.AssemblyMode.Internal); Models.Add("KWSkull", KWSkull); KWDollar = SceneImporter.LoadModel("dollar.obj", false, SceneImporter.AssemblyMode.Internal); Models.Add("KWDollar", KWDollar); CoordinateSystem = SceneImporter.LoadModel("csystem.obj", false, SceneImporter.AssemblyMode.Internal); CoordinateSystemX = SceneImporter.LoadModel("csystemX.obj", false, SceneImporter.AssemblyMode.Internal); CoordinateSystemY = SceneImporter.LoadModel("csystemY.obj", false, SceneImporter.AssemblyMode.Internal); CoordinateSystemZ = SceneImporter.LoadModel("csystemZ.obj", false, SceneImporter.AssemblyMode.Internal); GHitbox = SceneImporter.LoadModel("Hitbox.obj", false, SceneImporter.AssemblyMode.Internal); for (int i = 0; i < Explosion.Axes.Length; i++) { Explosion.Axes[i] = Vector3.Normalize(Explosion.Axes[i]); } }
/// <summary> /// Lädt ein Modell aus einer Datei /// </summary> /// <param name="name">Name des Modells</param> /// <param name="filename">Datei des Modells</param> /// <param name="callerName"></param> public static void LoadModelFromFile(string name, string filename, [CallerMemberName] string callerName = "") { if (callerName != "Prepare") { throw new Exception("Models may only be loaded in the world's Prepare() method."); } if (KWEngine.Models.ContainsKey(name.Trim())) { throw new Exception("A model with the name " + name + " already exists."); } GeoModel m = SceneImporter.LoadModel(filename, true, SceneImporter.AssemblyMode.File); name = name.Trim(); m.Name = name; lock (KWEngine.Models) { KWEngine.Models.Add(name, m); } }
/// <summary> /// Lädt ein Modell aus den eingebetteten Ressourcen /// </summary> /// <param name="name">Name des Modells</param> /// <param name="path">Pfad zum Modell inkl. Dateiname</param> /// <param name="flipTextureCoordinates">UV-Map umdrehen (Standard: true)</param> /// <param name="callerName"></param> public static void LoadModelFromAssembly(string name, string path, bool flipTextureCoordinates = true, [CallerMemberName] string callerName = "") { if (callerName != "Prepare") { HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromAssembly()", "This method may only be called from the Prepare() method."); return; } if (KWEngine.Models.ContainsKey(name.Trim())) { HelperGeneral.ShowErrorAndQuit("KWEngine::LoadModelFromAssembly()", "Model name already exists."); return; } GeoModel m = SceneImporter.LoadModel(path, flipTextureCoordinates, SceneImporter.AssemblyMode.User); name = name.Trim(); m.Name = name; lock (KWEngine.Models) { KWEngine.Models.Add(name, m); } }