コード例 #1
0
ファイル: Scene.cpp プロジェクト: galek/dava.framework
Entity *Scene::GetRootNode(const FilePath &rootNodePath)
{
	ProxyNodeMap::const_iterator it = rootNodes.find(FILEPATH_MAP_KEY(rootNodePath));
	if (it != rootNodes.end())
	{
        ProxyNode * node = it->second;
		return node->GetNode();
	}
    
    if(rootNodePath.IsEqualToExtension(".sce"))
    {
        SceneFile *file = new SceneFile();
        file->SetDebugLog(true);
        file->LoadScene(rootNodePath, this);
        SafeRelease(file);
    }
    else if(rootNodePath.IsEqualToExtension(".sc2"))
    {
        uint64 startTime = SystemTimer::Instance()->AbsoluteMS();
        SceneFileV2 *file = new SceneFileV2();
        file->EnableDebugLog(false);
        SceneFileV2::eError loadResult = file->LoadScene(rootNodePath, this);
        SafeRelease(file);
				
        uint64 deltaTime = SystemTimer::Instance()->AbsoluteMS() - startTime;
        Logger::FrameworkDebug("[GETROOTNODE TIME] %dms (%ld)", deltaTime, deltaTime);

        if (loadResult != SceneFileV2::ERROR_NO_ERROR)
        {
            return 0;
        }
    }
    
	it = rootNodes.find(FILEPATH_MAP_KEY(rootNodePath));
	if (it != rootNodes.end())
	{
        ProxyNode * node = it->second;
        //int32 nowCount = node->GetNode()->GetChildrenCountRecursive();
		return node->GetNode();
	}
    return 0;
}
コード例 #2
0
Entity *Scene::GetRootNode(const FilePath &rootNodePath)
{
//    ProxyNode * proxyNode = dynamic_cast<ProxyNode*>(scenes->FindByName(rootNodePath));
//    if (proxyNode)
//    {
//        return proxyNode->GetNode();
//    }
//    
//    String ext = FileSystem::Instance()->GetExtension(rootNodePath);
//    if(ext == ".sce")
//    {
//        SceneFile *file = new SceneFile();
//        file->SetDebugLog(true);
//        file->LoadScene(rootNodePath, this);
//        SafeRelease(file);
//    }
//    else if(ext == ".sc2")
//    {
//        SceneFileV2 *file = new SceneFileV2();
//        file->EnableDebugLog(true);
//        file->LoadScene(rootNodePath.c_str(), this);
//        SafeRelease(file);
//    }
//
//    proxyNode = dynamic_cast<ProxyNode*>(scenes->FindByName(rootNodePath));
//    if (proxyNode)
//    {
//        return proxyNode->GetNode();
//    }
//    return 0;
    
	Map<String, ProxyNode*>::const_iterator it;
	it = rootNodes.find(rootNodePath.GetAbsolutePathname());
	if (it != rootNodes.end())
	{
        ProxyNode * node = it->second;
		return node->GetNode();
	}
    
    if(rootNodePath.IsEqualToExtension(".sce"))
    {
        SceneFile *file = new SceneFile();
        file->SetDebugLog(true);
        file->LoadScene(rootNodePath, this);
        SafeRelease(file);
    }
    else if(rootNodePath.IsEqualToExtension(".sc2"))
    {
        uint64 startTime = SystemTimer::Instance()->AbsoluteMS();
        SceneFileV2 *file = new SceneFileV2();
        file->EnableDebugLog(false);
        file->LoadScene(rootNodePath, this);
        SafeRelease(file);
        uint64 deltaTime = SystemTimer::Instance()->AbsoluteMS() - startTime;
        Logger::Info("[GETROOTNODE TIME] %dms (%ld)", deltaTime, deltaTime);
    }
    
	it = rootNodes.find(rootNodePath.GetAbsolutePathname());
	if (it != rootNodes.end())
	{
        ProxyNode * node = it->second;
        //int32 nowCount = node->GetNode()->GetChildrenCountRecursive();
		return node->GetNode();
	}
    return 0;
}
コード例 #3
0
int32 ScenePreviewControl::OpenScene(const FilePath &pathToFile)
{
    ReleaseScene();
    RecreateScene();
    
    int32 retError = SceneFileV2::ERROR_NO_ERROR;
    if(pathToFile.IsEqualToExtension(".sce"))
    {
        SceneFile *file = new SceneFile();
        file->SetDebugLog(true);
        if(!file->LoadScene(pathToFile, editorScene))
        {
            retError = ERROR_CANNOT_OPEN_FILE;
        }
        
        SafeRelease(file);
    }
    else if(pathToFile.IsEqualToExtension(".sc2"))
    {
        SceneFileV2 *file = new SceneFileV2();
        file->EnableDebugLog(true);
        retError = file->LoadScene(pathToFile, editorScene);
        SafeRelease(file);
    }
    else
    {
        retError = ERROR_WRONG_EXTENSION;
    }
    
    if(SceneFileV2::ERROR_NO_ERROR == retError)
    {
        rootNode = editorScene->GetRootNode(pathToFile);
        if(rootNode)
        {
            currentScenePath = pathToFile;
            editorScene->AddNode(rootNode);
            
            needSetCamera = true;
            Camera *cam = editorScene->GetCamera(0);
            if(!cam)
            {
                Camera * cam = new Camera();
                //cam->SetDebugFlags(Entity::DEBUG_DRAW_ALL);
                cam->SetUp(Vector3(0.0f, 0.0f, 1.0f));
                cam->SetPosition(Vector3(0.0f, 0.0f, 0.0f));
                cam->SetTarget(Vector3(0.0f, 1.0f, 0.0f));
                
                cam->SetupPerspective(70.0f, 320.0f / 480.0f, 1.0f, 5000.0f); 
                

                
                ScopedPtr<Entity> node(new Entity());
                node->SetName("preview-camera");
                node->AddComponent(new CameraComponent(cam));
                editorScene->AddNode(node);
                editorScene->AddCamera(cam);
                editorScene->SetCurrentCamera(cam);
                cameraController->SetScene(editorScene);
                
                SafeRelease(cam);
                
                sceCamera = false;
            }
            else
            {
                sceCamera = true;
            }
        }
    }
    
    SceneValidator::Instance()->ValidateSceneAndShowErrors(editorScene);
    
    return retError;
}