/// <summary> /// Przygotowuje bitmapę oraz scenę. /// </summary> /// <param name="view"></param> public Zadanie1(IZadanie1 view) { _view = view; _view.Loaded += OnLoaded; _bmp = new BufferedBitmap(750, 450); _device = new Device(_bmp, new Bresenham(), new LiangBarskyClipping()); _scene = new Scene { Camera = new Camera { Position = Vector3.Zero, LookDirection = Vector3.UnitZ, FieldOfView = 60 } }; _scene = SceneImporter.LoadJsonFile(Path.Combine("Resources", "scene.unity.babylon")); // Przypisujemy płaszczyźnie kolor szary, aby mieć punkt odniesienia do "podłogi". _scene.Meshes.First(m => m.Name == "Plane").Color = Colors.DarkGrey; _fpsCounter.StatsChanged += UpdateDebugInfo; }
public override bool Export(ProjectAssetContainer container, string dirPath) { string folderPath = Path.Combine(dirPath, Object.AssetsKeyWord, OcclusionCullingSettings.SceneKeyWord); string sceneSubPath = GetSceneName(container); string fileName = $"{sceneSubPath}.unity"; string filePath = Path.Combine(folderPath, fileName); folderPath = Path.GetDirectoryName(filePath); if (!DirectoryUtils.Exists(folderPath)) { DirectoryUtils.CreateVirtualDirectory(folderPath); } AssetExporter.Export(container, Components, filePath); SceneImporter sceneImporter = new SceneImporter(); Meta meta = new Meta(sceneImporter, GUID); ExportMeta(container, meta, filePath); string sceneName = Path.GetFileName(sceneSubPath); string subFolderPath = Path.Combine(folderPath, sceneName); if (OcclusionCullingData != null) { OcclusionCullingData.Initialize(container, m_occlusionCullingSettings); ExportAsset(container, OcclusionCullingData, subFolderPath); } return(true); }
// Prepares the bitmap and the scene. public SceneViewModel(ISceneViewModel view) { _view = view; _view.Loaded += OnLoaded; _bmp = new BufferedBitmap(750, 450); _device = new Device(_bmp, new Bresenham(), new LiangBarskyClipping()); _scene = new Scene { Camera = new Camera { Position = Vector3.Zero, LookDirection = Vector3.UnitZ, FieldOfView = 60 } }; _scene = SceneImporter.LoadJsonFile(Path.Combine("Resources", "scene.unity.babylon")); _scene.Meshes.First(m => m.Name == "Plane").Color = Engine.Utilities.Colors.DarkGrey; //_scene.Meshes.Add(new Cube()); //_scene.Meshes.Add(new Sphere()); //_scene.Meshes.Add(new Cone()); //_scene.Meshes.Add(new Tube()); }
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") { 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); } } }
public static void GenerateUncompressedRom(string filename) { List <int> keepscenes = KeepScenes(); SceneImporter.ImportToUncompressedRom(filename, ORom.Build.N0, "dr2", keepscenes); CRC.Write(filename); }
public static void Init(TestContext context) { // Loads COLLADA document for testing XmlDocument apcDocument = TestBase.LoadDocument("APC_animation.DAE"); // Requires geometry to create mesh instances GeometryImporter geometryImporter = new GeometryImporter(); geometryImporter.Import(apcDocument.DocumentElement, apcModel); SceneImporter importer = new SceneImporter(); importer.Import(apcDocument.DocumentElement, apcModel); }
/// <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); } }
public override bool Export(ProjectAssetContainer container, string dirPath) { TryInitialize(container); string folderPath = Path.Combine(dirPath, Object.AssetsName, "Scene"); string sceneSubPath = GetSceneName(container); string fileName = $"{sceneSubPath}.unity"; string filePath = Path.Combine(folderPath, fileName); folderPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } AssetExporter.Export(container, Components, filePath); SceneImporter sceneImporter = new SceneImporter(); Meta meta = new Meta(sceneImporter, GUID); ExportMeta(container, meta, filePath); string sceneName = Path.GetFileName(sceneSubPath); string subFolderPath = Path.Combine(folderPath, sceneName); if (OcclusionCullingData != null) { ExportAsset(container, OcclusionCullingData, subFolderPath); } if (LightingDataAsset != null) { ExportAsset(container, LightingDataAsset, subFolderPath); } if (NavMeshData != null) { ExportAsset(container, NavMeshData, subFolderPath); } return(true); }
public override bool Export(ProjectAssetContainer container, string dirPath) { string folderPath = Path.Combine(dirPath, Object.AssetsKeyWord, OcclusionCullingSettings.SceneKeyWord); string sceneSubPath = GetSceneName(container); string fileName = $"{sceneSubPath}.unity"; string filePath = Path.Combine(folderPath, fileName); if (IsDuplicate(container)) { if (FileUtils.Exists(filePath)) { Logger.Log(LogType.Warning, LogCategory.Export, $"Duplicate scene '{sceneSubPath}' has been found. Skipping"); return(false); } } folderPath = Path.GetDirectoryName(filePath); if (!DirectoryUtils.Exists(folderPath)) { DirectoryUtils.CreateVirtualDirectory(folderPath); } AssetExporter.Export(container, Components, filePath); SceneImporter sceneImporter = new SceneImporter(); Meta meta = new Meta(sceneImporter, GUID); ExportMeta(container, meta, filePath); string sceneName = Path.GetFileName(sceneSubPath); string subFolderPath = Path.Combine(folderPath, sceneName); if (OcclusionCullingData != null) { OcclusionCullingData.Initialize(container, m_occlusionCullingSettings); ExportAsset(container, OcclusionCullingData, subFolderPath); } return(true); }
/// <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); } }
void Update() { m_usdFile = m_usdFile.Replace("\"", ""); if (!System.IO.Path.IsPathRooted(m_usdFile)) { m_usdFile = Application.dataPath + "/" + m_usdFile; } if (string.IsNullOrEmpty(m_usdFile)) { if (m_scene == null) { return; } m_scene.Close(); m_scene = null; UnloadGameObjects(); return; } // Is the stage already loaded? if (m_scene != null && m_scene.FilePath == m_usdFile && m_lastTime == m_usdTime) { return; } try { // Does the path exist? if (!System.IO.File.Exists(m_usdFile)) { throw new System.IO.FileNotFoundException(m_usdFile); } m_lastTime = m_usdTime; // Clear out the old scene. UnloadGameObjects(); // Import the new scene. m_scene = Scene.Open(m_usdFile); if (m_scene == null) { throw new Exception("Failed to import"); } // Set the time at which to read samples from USD. m_scene.Time = m_usdTime; // When converting right handed (USD) to left handed (Unity), there are two options: // // 1) Add an inversion at the root of the scene, leaving the points right-handed. // 2) Convert all transforms and points to left-handed (deep change of basis). // // Option (2) is more computationally expensive, but results in fewer down stream // surprises. var importOptions = new SceneImportOptions(); importOptions.changeHandedness = m_changeHandedness; importOptions.materialMap.DisplayColorMaterial = m_material; importOptions.enableGpuInstancing = m_enableGpuInstancing; // The root object at which the USD scene will be reconstructed. // It may need a Z-up to Y-up conversion and a right- to left-handed change of basis. var rootXf = new GameObject("root"); rootXf.transform.SetParent(this.transform, worldPositionStays: false); m_primMap = SceneImporter.BuildScene(m_scene, rootXf, importOptions, new PrimMap(), composingSubtree: false); // Ensure the file and the identifier match. m_usdFile = m_scene.FilePath; } catch { enabled = false; throw; } }
void Start() { SceneImporter importer = new SceneImporter(scene_path); importer.Retrieve(); }
private static void DumpRooms(string filename) { List <int> keepscenes = KeepScenes(); SceneImporter.DumpScenesAndRooms(new ORom(filename, ORom.Build.MQP), "mqp", keepscenes); }