Esempio n. 1
0
UndoUtil::UndoUtil(ScenePtr pScene)
{
  if (pScene.isnull())
    m_pUM=NULL;
  else
    m_pUM = pScene->getUndoMgr();
}
Esempio n. 2
0
    /**
        Loads data from a PDB file (command line parameter --pdb-file)
    */
    void _loadPDBFile()
    {
        // Load PDB File
        GeometryParameters& geometryParameters =
            _parametersManager->getGeometryParameters();
        BRAYNS_INFO << "Loading PDB file " << geometryParameters.getPDBFile()
                    << std::endl;
        ProteinLoader proteinLoader( geometryParameters );
        if( !proteinLoader.importPDBFile( geometryParameters.getPDBFile(),
                                          Vector3f( 0, 0, 0 ), 0,
                                          *_engine->getScene()))
        {
            BRAYNS_ERROR << "Failed to import "
                         << geometryParameters.getPDBFile() << std::endl;
        }

        ScenePtr scene = _engine->getScene();
        for( size_t i = 0; i < scene->getMaterials().size( ); ++i )
        {
            float r,g,b;
            proteinLoader.getMaterialKd( i, r, g, b );
            MaterialPtr material = scene->getMaterials()[i];
            material->setColor( Vector3f( r, g, b ));
        }
    }
bool SceneSyncState::FillRequest(entity_id_t id)
{
    changeRequest_.Reset(id);

    if (scene_.expired())
        return false;
    ScenePtr scenePtr = scene_.lock();
    if (!scenePtr.get())
    {
        LogError("SceneSyncState::FillRequest(id): Scene is null!");
        return false;
    }

    EntityPtr entityPtr = scenePtr->GetEntity(id);
    if (!entityPtr.get())
        return false;

    // We trust the SyncManager mechanisms to stop local entities from ever getting here.
    // Print anyways if something starts to leak so at least we notice it here.
    if (!entityPtr->IsReplicated())
        LogError("SceneSyncState::FillRequest(id): Entity " + QString::number(id) + " should not be replicated!");
    changeRequest_.SetEntity(entityPtr.get());

    return true;
}
void SceneSyncState::AddPendingEntity(entity_id_t id)
{
    if (!isServer_)
        return;

    if (scene_.expired())
        return;
    ScenePtr scenePtr = scene_.lock();
    if (!scenePtr.get())
    {
        LogError("SceneSyncState::FillPendingComponents(id): Scene is null!");
        return;
    }

    EntityPtr entityPtr = scenePtr->GetEntity(id);
    if (!entityPtr.get())
    {
        LogError("SceneSyncState::FillPendingComponents(id): Entity is null, cannot fill components!");
        return;
    }
    if (entityPtr->Components().empty())
        return;
        
    if (!HasPendingEntity(id))
        pendingEntities_.push_back(id);
}
Esempio n. 5
0
void MqoSceneExporter::write()
{
  MqoDisplayContext *pmqodc = MB_NEW MqoDisplayContext();

  ScenePtr pScene = getClient();

  CameraPtr pCam = getCamera();
  qlib::ensureNotNull(pCam.get());

  // Main stream
  qlib::OutStream *pOutMqo = createOutStream();

  pmqodc->init(pOutMqo);
  
  pmqodc->setGradSteps(m_nGradSteps);
  pmqodc->setClipZ(m_bUseClipZ);
  pmqodc->setPerspective(m_bPerspective);
  pmqodc->setBgColor(pScene->getBgColor());

  pmqodc->setZoom(pCam->getZoom());
  pmqodc->setSlabDepth(pCam->getSlabDepth());
  pmqodc->setViewDist(pCam->getCamDist());

  pmqodc->loadIdent();
  pmqodc->rotate(pCam->m_rotQuat);
  pmqodc->translate(-(pCam->m_center));
  
  pScene->display(pmqodc);

  delete pmqodc;

  // cleanup the created streams
  pOutMqo->close();
  delete pOutMqo;
}
Esempio n. 6
0
void Client::HandleLoginReply(kNet::MessageConnection* /*source*/, const char *data, size_t numBytes)
{
    DataDeserializer dd(data, numBytes);
    MsgLoginReply msg;
    msg.DeserializeFrom(dd);

    // Read optional protocol version
    // Server can downgrade what we sent, but never upgrade
    serverUserConnection_->protocolVersion = ProtocolOriginal;
    if (dd.BytesLeft())
        serverUserConnection_->protocolVersion = (NetworkProtocolVersion)dd.ReadVLE<kNet::VLE8_16_32>();

    if (msg.success)
    {
        loginstate_ = LoggedIn;
        client_id_ = msg.userID;
        LogInfo("Logged in successfully");
        
        // Note: create scene & send info of login success only on first connection, not on reconnect
        if (!reconnect_)
        {
            // The connection is now live for use by eg. SyncManager
            serverUserConnection_->connection = MessageConnection();

            // Create a non-authoritative scene for the client
            ScenePtr scene = framework_->Scene()->CreateScene("TundraClient", true, false);

            owner_->SyncManager()->RegisterToScene(scene);
            
            UserConnectedResponseData responseData;
            if (msg.loginReplyData.size() > 0)
            {
                String responseDataStr((const char *)&msg.loginReplyData[0], (int)msg.loginReplyData.size());
                responseData.responseDataXml = new Urho3D::XMLFile(context_);
                responseData.responseDataXml->FromString(responseDataStr);
            }

            Connected.Emit(&responseData);
        }
        else
        {
            // If we are reconnecting, empty the scene, as the server will send everything again anyway
            // Note: when we move to unordered communication, we must guarantee that the server does not send
            // any scene data before the login reply

            ScenePtr scene = framework_->Scene()->SceneByName("TundraClient");
            if (scene)
                scene->RemoveAllEntities(true, AttributeChange::LocalOnly);
        }
        reconnect_ = true;
    }
    else
    {
        String response((const char *)&msg.loginReplyData[0], (int)msg.loginReplyData.size());
        if (!response.Empty())
            SetLoginProperty("LoginFailed", response);
        DoLogout(true);
    }
}
Esempio n. 7
0
 void setMaterials(
     const MaterialType materialType,
     const size_t nbMaterials )
 {
     ScenePtr scene = _engine->getScene();
     scene->setMaterials( materialType, nbMaterials );
     scene->commit( );
 }
Esempio n. 8
0
UndoUtil::UndoUtil(qlib::uid_t nSceneID)
{
  ScenePtr pScene = SceneManager::getSceneS(nSceneID);
  if (pScene.isnull())
    m_pUM=NULL;
  else
    m_pUM = pScene->getUndoMgr();
}
Esempio n. 9
0
  void Viewport::deleteObject()
  {
    ScenePtr scene = m_gl_widget->scene();
    if (!scene) return;

    foreach (ObjectPtr obj, scene->selection())
      scene->remove(obj);
  }
Esempio n. 10
0
 void GLWidget::sceneChange(ScenePtr s)
 {
   m_scene = s;
   if (s) {
     setFormat(s->glFormat());
     s->resize(size().width(), size().height());
   }
 }
Esempio n. 11
0
void TimeLine::_create_test() 
{
	ScenePtr scene = std::make_shared<Scene>(project_);
	scene->_create_test();
	scenes_.push_back(scene);

	//CompositorPtr show(new SdlShowCompositor(renderer));
	//comps_.push_back(show);
}
Esempio n. 12
0
bool SceneIO::processSceneTrajectory(rapidxml::xml_node<char>* sceneXMLNode, ScenePtr scene )
{
	THROW_VR_EXCEPTION_IF(!sceneXMLNode || !scene, "NULL data in processSceneTrajectory");

	std::vector<RobotPtr> robs = scene->getRobots();
	TrajectoryPtr o = BaseIO::processTrajectory(sceneXMLNode, robs);
	if (!o)
		return false;

	scene->registerTrajectory(o);
	return true;
}
Esempio n. 13
0
///////////////////////////////////////////////////////////////////////////////
// Open a zone that should be under the root.
// 
ScenePtr SceneManager::OpenScene( SceneGraph::Viewport* viewport, Document* document, tstring& error )
{
    ScenePtr scene = NewScene( viewport, document );
    if ( !scene->Load( document->GetPath() ) )
    {
        error = TXT( "Failed to load scene from " ) + document->GetPath().Get() + TXT( "." );
        RemoveScene( scene );
        scene = NULL;
    }

    return scene;
}
Esempio n. 14
0
bool VolComputer::process(const ScenePtr scene){
  if(!scene || scene->empty()){
    __result = 0;
    return false;
  }
  real_t volume = 0;
  for(Scene::const_iterator _it=scene->begin();
      _it!=scene->end();
      _it++)
    if((*_it)->apply(*this))
      volume+=__result;
  __result = volume;
  return true;
}
Esempio n. 15
0
void Engine::loadScene(const std::string & path) {
    try {
        ScenePtr scene = ModelLoader::loadScene(path);
        scene->init();

        cout << scene->toString() << endl;

        m_camera = scene->getCamera();
        m_camera->setScreenSize(m_screenSize.x, m_screenSize.y);

        m_renderer->setScene(std::move(scene));
    } catch (const std::exception &e) {
        std::cout << "Impossible de charger la scène : " << e.what() << std::endl;
    }

}
		void SceneDirector::push(ScenePtr scene, PushType::Type pushType)
		{
			assert(scene != NULL);
			
			if(getDelegate())
			{
				getDelegate()->onSceneWillBeAddedToStack(this, *scene);
			}
			
			_scenes.push_back(ScenePair(scene, pushType));
			
			if(getDelegate())
			{
				getDelegate()->onSceneHasBeenAddedToStack(this, *scene);
			}
			
			if(getDelegate())
			{
				getDelegate()->onSceneWillBeInitialized(this, *scene);
			}
			
			// initialize the scene
			scene->initialize();
			
			if(getDelegate())
			{
				getDelegate()->onSceneHasBeenInitialized(this, *scene);
			}
		}
Esempio n. 17
0
void ModelLoader::processNode(const aiScene *aiscene, ScenePtr &scene, aiNode * node, SceneObjectPtr &object, glm::mat4 accTransform) {
	//Transform
	object->transform = aiToGLM(node->mTransformation);
	accTransform = accTransform * object->transform;
	//Name
	object->name = node->mName.C_Str();
	//Mesh
	object->meshes.reserve(node->mNumMeshes);
	for (int i = 0; i < node->mNumMeshes; i++) {
		aiMesh *mesh = aiscene->mMeshes[node->mMeshes[i]];
		object->meshes.push_back(MeshPtr(new ModelMesh));
		processMesh(aiscene, scene, mesh, object->meshes.back(), accTransform);

		//Bounding box
		object->bBox.fitWithAddingBbox(object->meshes.back()->bBox);
	}

	//Children
	for (int i = 0; i < node->mNumChildren; i++) {
		//Création d'un enfant
		SceneObjectPtr &newObject = object->createChild();
		//Parent
		newObject->parent = object.get();
		newObject->scene = scene.get();

		processNode(aiscene, scene, node->mChildren[i], newObject, accTransform);

		//Bounding Box
		object->bBox.fitWithAddingBbox(newObject->bBox);
	}
}
Esempio n. 18
0
PhysicsWorld::PhysicsWorld(const ScenePtr &scene, bool isClient) :
    scene_(scene),
    collisionConfiguration_(0),
    collisionDispatcher_(0),
    broadphase_(0),
    solver_(0),
    world_(0),
    physicsUpdatePeriod_(1.0f / 60.0f),
    maxSubSteps_(6), // If fps is below 10, we start to slow down physics
    isClient_(isClient),
    runPhysics_(true),
    drawDebugManuallySet_(false),
    useVariableTimestep_(false),
    debugDrawMode_(0),
    cachedOgreWorld_(0)
{
#include "DisableMemoryLeakCheck.h"
    collisionConfiguration_ = new btDefaultCollisionConfiguration();
    collisionDispatcher_ = new btCollisionDispatcher(collisionConfiguration_);
    broadphase_ = new btDbvtBroadphase();
    solver_ = new btSequentialImpulseConstraintSolver();
    world_ = new btDiscreteDynamicsWorld(collisionDispatcher_, broadphase_, solver_, collisionConfiguration_);
    world_->setDebugDrawer(this);
    world_->setInternalTickCallback(TickCallback, (void*)this, false);
#include "EnableMemoryLeakCheck.h"

    if (scene->GetFramework()->HasCommandLineParameter("--variablephysicsstep"))
        useVariableTimestep_ = true;
}
Esempio n. 19
0
    void render( const RenderInput& renderInput,
                 RenderOutput& renderOutput )
    {
        reshape( renderInput.windowSize );

        _engine->preRender();

        _engine->getCamera()->set(
            renderInput.position, renderInput.target, renderInput.up );

#if(BRAYNS_USE_DEFLECT || BRAYNS_USE_REST)
        if( !_extensionPluginFactory )
            _intializeExtensionPluginFactory( );
        _extensionPluginFactory->execute( );
#endif

        ScenePtr scene = _engine->getScene();
        CameraPtr camera = _engine->getCamera();
        FrameBufferPtr frameBuffer = _engine->getFrameBuffer();
        const Vector2i& frameSize = frameBuffer->getSize();

        if( _parametersManager->getRenderingParameters().getSunOnCamera() )
        {
            LightPtr sunLight = scene->getLight( 0 );
            DirectionalLight* sun =
                dynamic_cast< DirectionalLight* > ( sunLight.get() );
            if( sun )
            {
                sun->setDirection( camera->getTarget() - camera->getPosition() );
                scene->commitLights();
            }
        }

        camera->commit();
        _render( );

        uint8_t* colorBuffer = frameBuffer->getColorBuffer( );
        size_t size =
            frameSize.x( ) * frameSize.y( ) * frameBuffer->getColorDepth( );
        renderOutput.colorBuffer.assign( colorBuffer, colorBuffer + size );

        float* depthBuffer = frameBuffer->getDepthBuffer( );
        size = frameSize.x( ) * frameSize.y( );
        renderOutput.depthBuffer.assign( depthBuffer, depthBuffer + size );

        _engine->postRender();
    }
Esempio n. 20
0
void ScreenViewController::render_scene(const CanvasPtr &canvas, const ScenePtr &scene)
{
	using namespace uicore;

	canvas->end();

	GraphicContextPtr gc = canvas->gc();

	Pointf viewport_pos = Vec2f(canvas->transform() * Vec4f(0.0f, 0.0f, 0.0f, 1.0f));
	Sizef viewport_size = gc->size();
	Size viewport_size_i = Size(viewport_size);

	scene->set_viewport(viewport_size_i);
	scene->render(gc);

	canvas->begin();
}
Esempio n. 21
0
void initGraphics()
{
    trackball(curquat, 0.0, 0.0, 0.0, 0.0);

#ifdef __APPLE__
    // Seems to be needed on Apple platforms using Intel
	// integrated graphics but not elsewhere
    // If you're getting unexpected seg faults on Apple,
    // comment this out and recompile
	// If you're not seeing the mesh on a Windows box that
	// uses Intel integrated graphics, try enabling this
	// for your machine
    glEnableClientState(GL_COLOR_ARRAY);
#endif
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnable(GL_DEPTH_TEST);
    glPixelStorei(GL_PACK_ALIGNMENT, 1);  // avoid GL's dumb default of 4
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);  // avoid GL's dumb default of 4
    glClearColor(0.1, 0.1, 0.2, 0.0);

    scene = ScenePtr(new Scene(Camera(40, 1, 0.1, 100),
                               View(eye_vector,
                                    at_vector,
                                    up_vector))); 

    material = MaterialPtr(new Material());
    // A little hacky - pick initial values from menu items
    materialMenu(0);
    bumpyMenu(0);
    decalMenu(0);
    envMapMenu(0);

    Mesh2DPtr mesh2d = Mesh2DPtr(new Mesh2D(float2(0,0), float2(1,1), int2(4,4)));

    TorusPtr torus = TorusPtr(new Torus(Transform(), material));
    scene->addObject(torus);

    light = LightPtr(new Light());
    light->setCenter(float3(0,0,0));
    light->setRadius(3.5);
    light->setAngleInDegrees(60.0);
    // A little hacky - pick initial value from menu item
    lightMenu(1);
    scene->addLight(light);
}
Esempio n. 22
0
bool InterestManager::CheckRelevance(UserConnectionPtr conn, Entity* changed_entity, SceneWeakPtr scene_, bool headless)
{
    PROFILE(Interest_Management);

    ScenePtr scene = scene_.lock();

    if (!scene)
        return true;

    EC_Placeable *entity_location = changed_entity->GetComponent<EC_Placeable>().get();

    if(!conn->syncState->locationInitialized || !entity_location) //If the client hasn't informed the server about the orientation yet, do not proceed
        return true;

    bool accepted = false;  //By default, we assume that the update will be rejected

    Quat client_orientation = conn->syncState->clientOrientation.Normalized();

    params_.client_position = conn->syncState->clientLocation;      //Client location vector
    params_.entity_position = entity_location->transform.Get().pos; //Entitys location vector

    float3 d = params_.client_position - params_.entity_position;
    float3 v = params_.entity_position - params_.client_position;   //Calculate the vector between the player and the changed entity by substracting their location vectors
    float3 f = client_orientation.Mul(scene->ForwardVector());      //Calculate the forward vector of the client

    params_.headless = headless;
    params_.dot = v.Dot(f);                                          //Finally the dot product is calculated so we know if the entity is in front of the player or not
    params_.distance = d.LengthSq();
    params_.scene = scene;
    params_.changed_entity = changed_entity;
    params_.connection = conn;
    params_.relAccepted = false;

    if(activeFilter_ != 0)
        accepted = activeFilter_->Filter(params_);

    if(accepted)
    {
        UpdateLastUpdatedEntity(params_.connection, params_.changed_entity->Id());
        return true;
    }
    else
        return false;
}
Esempio n. 23
0
void Client::HandleLoginReply(MessageConnection* /*source*/, const MsgLoginReply& msg)
{
    if (msg.success)
    {
        loginstate_ = LoggedIn;
        client_id_ = msg.userID;
        ::LogInfo("Logged in successfully");
        
        // Note: create scene & send info of login success only on first connection, not on reconnect
        if (!reconnect_)
        {
            // Create a non-authoritative scene for the client
            ScenePtr scene = framework_->Scene()->CreateScene("TundraClient", true, false);

//            framework_->Scene()->SetDefaultScene(scene);
            owner_->GetSyncManager()->RegisterToScene(scene);
            
            UserConnectedResponseData responseData;
            if (msg.loginReplyData.size() > 0)
                responseData.responseData.setContent(QByteArray((const char *)&msg.loginReplyData[0], (int)msg.loginReplyData.size()));

            emit Connected(&responseData);
        }
        else
        {
            // If we are reconnecting, empty the scene, as the server will send everything again anyway
            // Note: when we move to unordered communication, we must guarantee that the server does not send
            // any scene data before the login reply

            ScenePtr scene = framework_->Scene()->GetScene("TundraClient");
            if (scene)
                scene->RemoveAllEntities(true, AttributeChange::LocalOnly);
        }
        reconnect_ = true;
    }
    else
    {
        QString response(QByteArray((const char *)&msg.loginReplyData[0], (int)msg.loginReplyData.size()));
        if (!response.isEmpty())
            SetLoginProperty("LoginFailed", response);
        DoLogout(true);
    }
}
Esempio n. 24
0
    void _setDefaultCamera()
    {
        ScenePtr scene = _engine->getScene();
        CameraPtr camera = _engine->getCamera();
        FrameBufferPtr frameBuffer = _engine->getFrameBuffer();
        const Vector2i& frameSize = frameBuffer->getSize();

        const Boxf& worldBounds = scene->getWorldBounds();
        const Vector3f& target = worldBounds.getCenter();
        const Vector3f& diag = worldBounds.getSize();
        Vector3f position = target;
        position.z() -= diag.z();

        const Vector3f up = Vector3f( 0.f, 1.f, 0.f );
        camera->setInitialState( position, target, up );
        camera->setAspectRatio(
            static_cast< float >( frameSize.x()) /
            static_cast< float >( frameSize.y()));
    }
Esempio n. 25
0
Window::Window(RootObjectWeakPtr root)
       : BaseObject(root)
{
    _type = "window";

    ScenePtr scene = dynamic_pointer_cast<Scene>(root.lock());
    GlWindowPtr w = scene->getNewSharedWindow();
    if (w.get() == nullptr)
        return;

    _window = w;
    _isInitialized = setProjectionSurface();
    if (!_isInitialized)
        Log::get() << Log::WARNING << "Window::" << __FUNCTION__ << " - Error while creating the Window" << Log::endl;
    else
        Log::get() << Log::MESSAGE << "Window::" << __FUNCTION__ << " - Window created successfully" << Log::endl;

    _viewProjectionMatrix = glm::ortho(-1.f, 1.f, -1.f, 1.f);

    setEventsCallbacks();
    registerAttributes();
    showCursor(false);

    // Get the default window size and position
    glfwGetWindowPos(_window->get(), &_windowRect[0], &_windowRect[1]);
    glfwGetFramebufferSize(_window->get(), &_windowRect[2], &_windowRect[3]);

    // Create the render FBO
    glGetError();
    glGenFramebuffers(1, &_renderFbo);
    setupRenderFBO();

    glBindFramebuffer(GL_FRAMEBUFFER, _renderFbo);
    GLenum _status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if (_status != GL_FRAMEBUFFER_COMPLETE)
        Log::get() << Log::WARNING << "Window::" << __FUNCTION__ << " - Error while initializing render framebuffer object: " << _status << Log::endl;
    else
        Log::get() << Log::MESSAGE << "Window::" << __FUNCTION__ << " - Render framebuffer object successfully initialized" << Log::endl;
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // And the read framebuffer
    setupReadFBO();
}
Esempio n. 26
0
void LessonCube::update(float dt)
{
    g_scene->update(dt);
    
    static float rotation = 0.0f;
    rotation += 0.1f*dt*1000;
    
    //----------- compute mvpMatrix ---------------------
    
    GameObject* cube1 = g_scene->getRoot()->getChildByTag(Tag_Cube1);
    Quaternion qx, qy;
    qx.fromAxisAngle(Vector3(1,0,0), -rotation * 0.25f);
    qy.fromAxisAngle(Vector3(0,1,0), rotation);
    cube1->getTransform()->setRotation(qy*qx);
    
    GameObject* camera = g_scene->getCurrentCamera();
    
    camera->getTransform()->setPosition(10*sin(degreeToRadian(rotation*2)), 0, 10*cos(degreeToRadian(rotation*2)));
}
Esempio n. 27
0
int main ()
{
  printf ("Results of material_test:\n");
  
  try
  {
    IDriver* bullet_driver = DriverManager::FindDriver (DRIVER_NAME);

    if (!bullet_driver)
      throw xtl::format_operation_exception ("", "Can't find driver '%s'", DRIVER_NAME);

    ScenePtr scene (bullet_driver->CreateScene (), false);

    ShapePtr sphere_shape (bullet_driver->CreateSphereShape (1.f), false);

    RigidBodyPtr body1 (scene->CreateRigidBody (sphere_shape.get (), 1), false),
                 body2 (scene->CreateRigidBody (sphere_shape.get (), 1), false);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    body2->Material ()->SetFriction (0.3f);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    MaterialPtr material (bullet_driver->CreateMaterial (), false);

    body1->SetMaterial (material.get ());
    body2->SetMaterial (material.get ());

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    material->SetFriction (0.25f);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
Esempio n. 28
0
bool SceneIO::processSceneManipulationObject(rapidxml::xml_node<char>* sceneXMLNode, ScenePtr scene, const std::string& basePath )
{
	THROW_VR_EXCEPTION_IF(!sceneXMLNode, "NULL data in processSceneManipulationObject");

	ManipulationObjectPtr o = ObjectIO::processManipulationObject(sceneXMLNode,basePath);
	if (!o)
		return false;

	scene->registerManipulationObject(o);
	return true;
}
Esempio n. 29
0
bool SceneIO::processSceneObstacle(rapidxml::xml_node<char>* sceneXMLNode, ScenePtr scene, const std::string& basePath )
{
	THROW_VR_EXCEPTION_IF(!sceneXMLNode, "NULL data in processSceneObstacle");

	ObstaclePtr o = ObjectIO::processObstacle(sceneXMLNode,basePath);
	if (!o)
		return false;

	scene->registerObstacle(o);
	return true;
}
Esempio n. 30
0
///////////////////////////////////////////////////////////////////////////////
// Callback for when the path of a scene changes.  Since the scene manager 
// stores the scenes by their paths, the internal list has to be updated.
// 
void SceneManager::DocumentPathChanged( const DocumentPathChangedArgs& args )
{
    M_SceneSmartPtr::iterator found = m_Scenes.find( args.m_OldPath );
    if ( found != m_Scenes.end() )
    {
        // Hold a reference to the scene while we re-add it to the list, otherwise
        // it will get deleted.
        ScenePtr scene = found->second;

        // remove the scene
        m_Scenes.erase( found );

        // change the path of the scene
        scene->SetPath( args.m_Document->GetPath() );

        // re-insert w/ new path
        Helium::StdInsert<M_SceneSmartPtr>::Result inserted = m_Scenes.insert( M_SceneSmartPtr::value_type( scene->GetPath().Get(), scene ) );
        HELIUM_ASSERT( inserted.second );
    }
}