Example #1
0
void Scene::AddRootNode(Entity *node, const FilePath &rootNodePath)
{
    ProxyNode * proxyNode = new ProxyNode();
    proxyNode->SetNode(node);
    
    rootNodes[rootNodePath.GetAbsolutePathname()] = proxyNode;
    proxyNode->SetName(rootNodePath.GetAbsolutePathname());
}
Example #2
0
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;
}
    virtual void apply(ProxyNode& node)
    {
        // Transfer ownership of pools.
        _options->setUserData( node.getUserData() );
        node.setUserData(NULL);

        for (unsigned int pos=0; pos<node.getNumFileNames(); pos++)
        {
            std::string filename = node.getFileName(pos);

            // read external
            osg::ref_ptr<osg::Node> external = osgDB::readNodeFile(filename,_options.get());
            if (external.valid())
            {
                if (_cloneExternalReferences)
                    external = dynamic_cast<osg::Node*>(external->clone(osg::CopyOp(osg::CopyOp::DEEP_COPY_NODES)));

                node.addChild(external.get());
            }
        }
    }
Example #4
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;
}