| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // Urho3D editor scene handling
- Scene@ editorScene;
- string sceneResourcePath;
- void createScene()
- {
- // Create a scene with default values, these will be overridden when loading scenes
- @editorScene = engine.createScene("GraphicsTest", BoundingBox(-1000.0, 1000.0), 8, true);
- }
- void setResourcePath(string newPath)
- {
- if (newPath == sceneResourcePath)
- return;
- cache.releaseAllResources(false);
- // Remove the old scene resource path if any. However make sure that CoreData path never gets removed
- if ((!sceneResourcePath.empty()) && (sceneResourcePath.find("CoreData") < 0))
- cache.removeResourcePath(sceneResourcePath);
- cache.addResourcePath(newPath);
- sceneResourcePath = newPath;
- }
- void loadScene(string fileName)
- {
- // Always load the scene from the filesystem, not from resource paths
- if (!fileExists(fileName))
- {
- logError("No such scene " + fileName);
- return;
- }
- // Clear the old scene
- editorScene.removeAllEntities();
- // Add the new resource path
- setResourcePath(getPath(fileName));
- File file(fileName, FILE_READ);
- if (getExtension(fileName) == ".xml")
- editorScene.loadXML(file);
- else
- editorScene.load(file);
- }
|