示例#1
0
void resetGameLoadMapAddActors( GameModel & game, PathGraph & pathgraph, GameView & view, GameViewSound & sound, ActorControllerKeyboard * & keyboardController, std::map< std::string, ActorControllerAI * > & aiControllers, std::map< std::string, float > & globalVariables, float gametime, const std::string & filename ) {
	// delete ai controllers
	for( std::map< std::string, ActorControllerAI * >::iterator iter = aiControllers.begin( ); iter != aiControllers.end( ); iter++ ) {
		delete iter->second;
	}
	aiControllers.clear( );

	// reset game
	resetGame( game, pathgraph, view, sound );
	setGameVars( game, globalVariables );

	// load map
	loadMap( game, pathgraph, view, sound, globalVariables, filename );
	view.initBrushTextures( );

	// add players
	//addPlayer( game, keyboardController, globalVariables, gametime, "Player" );
	addActor( game, keyboardController, globalVariables, gametime, "Player" );
	for( int i = 0; i < 3; i++ ) {
		aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ] = new ActorControllerAI( &game, pathgraph );
		//addAI( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) );
		addActor( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) );
	}
	view.setCamera( &game.getActors( ).front( ) );
	sound.setCamera( &game.getActors( ).front( ) );
}
示例#2
0
void MainWindow::emitAddActor()
{
    connect(this,SIGNAL(addActor(QString,QDate)),db,SLOT(addActor(QString,QDate)));
    emit addActor(ui->actorNameLineEdit->text(),ui->actorDateEdit->date());
    disconnect(this,SIGNAL(addActor(QString,QDate)),db,SLOT(addActor(QString,QDate)));
    ui->statusBar->showMessage("Actor added",3000);
    refreshUi();
}
Cross::Cross(QObject *parent) : MyScene(parent)
{
    back = new Background(":street.png");

//    north = new Street(UP,7000);
//    south = new Street(DOWN,8000);
//    east = new Street(IZQ,1500);
//    west = new Street(DER,1000);

    north = new Street(UP,600);
    south = new Street(DOWN,800);
    east = new Street(IZQ,750);
    west = new Street(DER,700);

//    north = new Street(UP,400);
//    south = new Street(DOWN,300);
//    east = new Street(IZQ,250);
//    west = new Street(DER,200);

    logs = new Stack<Log*>();

    addActor(back);

    addActor(north);
    addActor(south);
    addActor(east);
    addActor(west);

    cross_n_1 = NULL;
    cross_n_2 = NULL;
    cross_s_1 = NULL;
    cross_s_2 = NULL;
    cross_e_1 = NULL;
    cross_e_2 = NULL;
    cross_w_1 = NULL;
    cross_w_2 = NULL;

    n1=false;
    n2=false;
    s1=false;
    s2=false;
    e1=false;
    e2=false;
    w1=false;
    w2=false;

    frame=0;
    change_semaphore = 100*20;
    time_accident = 0;
    activo=true;
    crossing=false;
    accident = false;
    quit_time=1000;
    crachesPos = new QPointF(538.762,250.705);
    srand(time(NULL));
}
示例#4
0
文件: game.cpp 项目: elemel/crust
 void Game::initMonsters()
 {
     if (dungeonGenerator_.getRoomBoxCount()) {
         Vector2 position = dungeonGenerator_.getRoomBox(0).getCenter();
         playerActor_ = addActor(actorFactory_->createMonster(position));
     }
 }
示例#5
0
void SceneManager::addChunk(Chunk *chunk) {
	Actor **chunkActors = chunk->getActors();
	int numActors = chunk->getNumActors();
	for (int i=0; i<numActors; i++) {
		Actor *newActor = new Actor();
		*newActor = *chunkActors[i];
		addActor(newActor);
	}

	PhysicsShape **chunkPhysics = chunk->getPhysics();
	int numPhysics = chunk->getNumPhysics();
	for (int i=0; i<numPhysics; i++) {
		PhysicsShape *newPhysics = new PhysicsShape(BOX);
		*newPhysics = *chunkPhysics[i];
		if (newPhysics->getShapeType() == BOX) {
			newPhysics->setModel(new string("Cube"));
		} else if (newPhysics->getShapeType() == SPHERE) {
			newPhysics->setModel(new string("Sphere"));
		} else if (newPhysics->getShapeType() == CYLINDER) {
			newPhysics->setModel(new string("Cylinder"));
		}
		newPhysics->setMaterial(new string("Physics"));
		addPhysicsShape(newPhysics);
	}

	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			sceneTiles->setTileMode(i,j,chunk->getTileMode(i,j));
		}
	}
}
示例#6
0
文件: World.cpp 项目: hef/siggame
World::World()
{
	pShipModel = new ModelSceneNode(OBJ2Model::file("spaceShip.obj"));
	Actor* pRock = new AsteroidActor
	(
		"Asteroid_1",
		pShipModel,
		Vector3f( -1, -3, 0 ),
		Vector3f( 1, 1.5, 0 ),
		Vector3f( 0, 0, 0 ),
		Vector3f( -1, 3, 15 )
	);
	addActor( pRock );

	pRock = new AsteroidActor
	(
		"Asteroid_2",
		pShipModel,
		Vector3f( -10, -30, 0 ),
		Vector3f( 5, -2.5, 0 ),
		Vector3f( 0, 0, 0 ),
		Vector3f( 105, -5, 5 )
	);

	addActor( pRock );

	pRock = new AsteroidActor
	(
		"Asteroid_3",
		pShipModel,
		Vector3f( 100, -30, 0 ),
		Vector3f( -3, .5, 0 ),
		Vector3f( 0, 0, 0 ),
		Vector3f( -12, 2, -6 )
	);

	addActor( pRock );

	Actor* pPlayer = new PlayerActor
	(
		"Player_1",
		pShipModel,
		Vector3f(0,0,0),
		Vector3f(0,0,0)
	);
	addActor( pPlayer );
}
示例#7
0
文件: scene.cpp 项目: wilkie/apsis
Apsis::World::Scene::Scene(const Apsis::Registry::Scene& scene) {
  for (unsigned int i = 0; i < scene.actorCount(); i++) {
    addActor(scene.actor(i), scene.actorX(i), scene.actorY(i));
  }

  for (unsigned int i = 0; i < scene.mapCount(); i++) {
    addMap(scene.map(i));
  }
}
示例#8
0
/*
 * Actually commit the operation against our data structures
 */
void LevelManager::onPostMove(Moveable& obj, Position old) {
    auto actor = m_actorsID[obj.getID()];
    removeActor(old);
    addActor(actor);

    auto current = actor->getPosition();
    if (current != old) {
	runTriggers(actor, old);
    }
}
示例#9
0
文件: game.cpp 项目: elemel/crust
 void Game::initBlocks()
 {
     Box2 paddedBounds = bounds_;
     paddedBounds.pad(2.0f);
     for (int i = 0; i < voronoiDiagram_.getPolygonCount(); ++i) {
         Polygon2 polygon = voronoiDiagram_.getPolygon(i);
         if (contains(paddedBounds, polygon)) {
             addActor(actorFactory_->createBlock(polygon));
         }
     }
 }
示例#10
0
/*
addObject function.
Adds an object with information from the server.


*/
void ObjectManager::addObject(NetworkObject networkObject) {
    switch (networkObject.type) {
    case ObjectName::ACTOR:
        // Note: b2d coordinaten of sfml? b2d lijkt logisch..
        addActor(networkObject.x, networkObject.y);

        break;
    default:
        break;
    }

}
示例#11
0
文件: World.cpp 项目: hef/siggame
void World::tick( double dt )
{
	vector< Actor* >::iterator i;
	for( i = actors.begin(); i != actors.end(); ++i )
	{
		( *i )->tick( dt );
	}
	// Add actors to the vector of actors
	for( i = actorsToAdd.begin(); i != actorsToAdd.end(); ++i )
	{
		addActor( *i );
	}
	actorsToAdd.clear(); // Remove them from the temp vector when done
}
示例#12
0
//===========================================================================//
void Engine::loadMap(const std::string& filename)
{
    reset();
    const std::string pathname(mConfig.dataDir + "/maps/" + filename + ".json");
    Logger::info("Loading map: " + pathname);
    const JSONMap map(pathname);
    for (const auto& actor : map.actors)
    {
        Actor& created = addActor(actor.filename);
        created.setPosition(actor.position);
        //created.setRotation(actor.rotation);
    }

    // Tell all the actors everything is loaded
    mScript.init();
}
void SJArcScene::loadActors()
{
	//Value& actorList = m_jsonValue["Actors"];
	//int count = actorList.IsNull() ? 0 : actorList.Size();
	//for (int i = 0; i < count; i++)
	//{
	//	CCLog("enter loadactors");
	//	Value& data = actorList[i];
	//	const char* res = data["res"].GetString();
	//	float height = data["height"].GetDouble();
	//	float rotate = data["speedcoef"].GetDouble();
	//	float ownAngle = data["ownangle"].GetDouble();

	//	SJActor* actor = SJActor::createActor(res, height, rotate);
	//	actor->setRotation(data["angle"].GetDouble());
	//	actor->setOrigAngle(data["angle"].GetDouble());
	//	actor->setFlipX(data["flip"].GetBool());
	//	actor->setOwnAngle(ownAngle);
	//	actor->setType(data["type"].GetString());
	//	setActorName(actor, data["name"].IsNull() ? NULL : data["name"].GetString());
	//	addActor(actor, data["z"].GetInt(), m_actorCount);
	//}

	Json*array = Json_getItem(m_jsonRoot,"Actors");
	int count = Json_getSize(array);
	for(int i = 0; i < count; i++)
	{
		Json*object = Json_getItemAt(array,i);
		const char* res = Json_getString(object,"res","");
		float height = Json_getFloat(object,"height",0);
		float rotate = Json_getFloat(object,"speedcoef",0);
		float ownAngle = Json_getFloat(object,"ownangle",0);

		SJActor* actor = SJActor::createActor(res, height, rotate);
		actor->setRotation(Json_getFloat(object,"angle",0));
		actor->setOrigAngle(Json_getFloat(object,"angle",0));
		actor->setFlipX(Json_getBool(object,"flip",false));
		actor->setOwnAngle(ownAngle);
		actor->setType(Json_getString(object,"type",0));
		setActorName(actor, Json_getString(object,"name",NULL));
		addActor(actor, Json_getInt(object,"z",0), m_actorCount);
	}
	//for(int i = 0;i < m_saveNames.size();i++)
	//{		
	//	CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo(m_saveNames[i].c_str());
	//}
}
示例#14
0
void OgreApplication::updateNodes(std::list<std::shared_ptr<OgreActor> > newActors, std::list<std::shared_ptr<DiffActor> > diffActor)
{

    for(std::shared_ptr<OgreActor> actor : newActors){
        addActor(actor);
    }

    for (std::shared_ptr<DiffActor> actor : diffActor)
    {
        Ogre::SceneNode *node;
        try {
          node = getSceneManager()->getSceneNode(actor->nodeName());
          node->setPosition(toOgreVector3(actor->position()));
          node->setOrientation(toOgreQuaternion(actor->orientation()));
        }
        catch (Ogre::ItemIdentityException e){
            std::cerr << "OgreApplication::updateNodes, warning: Node " << actor->nodeName() << " was not found. DiffActor was ignored." << std::endl;
        }
    }
}
示例#15
0
文件: grid.cpp 项目: 5irius/pcl
// Operators
// -----------------------------------------------------------------------------
Grid::Grid (std::string name, int size/*=10*/, double spacing/*=1.0*/) :
    Object (name)
{
  grid_ = vtkSmartPointer<vtkRectilinearGrid>::New ();
  grid_actor_ = vtkSmartPointer<vtkActor>::New ();

  vtkSmartPointer<vtkDataSetMapper> grid_mapper = vtkSmartPointer<vtkDataSetMapper>::New ();

  vtkSmartPointer<vtkDoubleArray> xz_array = vtkSmartPointer<vtkDoubleArray>::New ();
  vtkSmartPointer<vtkDoubleArray> y_array = vtkSmartPointer<vtkDoubleArray>::New ();

  size++;

  // Create a grid
  grid_->SetDimensions (size, 1, size);

  // Fill arrays
  for (int i = -size / 2; i <= size / 2; i++)
    xz_array->InsertNextValue ((double)i * spacing);
  y_array->InsertNextValue (0.0);

  grid_->SetXCoordinates (xz_array);
  grid_->SetYCoordinates (y_array);
  grid_->SetZCoordinates (xz_array);

#if VTK_MAJOR_VERSION <= 5
  grid_mapper->SetInputConnection (grid_->GetProducerPort ());
#else
  grid_mapper->SetInputData(grid_);
#endif

  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New ();
  grid_actor_->SetMapper (grid_mapper);

  grid_actor_->GetProperty ()->SetRepresentationToWireframe ();
  grid_actor_->GetProperty ()->SetColor (0.5, 0.5, 0.5);
  grid_actor_->GetProperty ()->SetLighting (false);

  addActor (grid_actor_);
}
示例#16
0
// Operators
// -----------------------------------------------------------------------------
OutofcoreCloud::OutofcoreCloud (std::string name, boost::filesystem::path& tree_root) :
    Object (name), display_depth_ (1), points_loaded_ (0), data_loaded_(0), render_camera_(NULL), lod_pixel_threshold_(10000)
{

  // Create the pcd reader thread once for all outofcore nodes
  if (OutofcoreCloud::pcd_reader_thread.get() == NULL)
  {
//    OutofcoreCloud::pcd_reader_thread = boost::shared_ptr<boost::thread>(new boost::thread(&OutofcoreCloud::pcdReaderThread, this));
    OutofcoreCloud::pcd_reader_thread = boost::shared_ptr<boost::thread>(new boost::thread(&OutofcoreCloud::pcdReaderThread));
  }


  octree_.reset (new OctreeDisk (tree_root, true));
  octree_->getBoundingBox (bbox_min_, bbox_max_);

  voxel_actor_ = vtkSmartPointer<vtkActor>::New ();

  updateVoxelData ();

  cloud_actors_ = vtkSmartPointer<vtkActorCollection>::New ();

  addActor (voxel_actor_);
}
示例#17
0
void OgreApplication::createScene(std::list<std::shared_ptr<OgreActor> > actors)
{
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
    mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

    for(std::shared_ptr<OgreActor> actor : actors){
        addActor(actor);
    }

    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);

    Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        plane, 1500, 1500, 20, 20, true, 1, 500, 500, Ogre::Vector3::UNIT_Z);

    Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);

    entGround->setMaterialName("Examples/Rockwall");
    entGround->setCastShadows(false);

    Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
    directionalLight->setDiffuseColour(Ogre::ColourValue(0.75, 0.75, 0.75));
    directionalLight->setSpecularColour(Ogre::ColourValue(1.0, 1.0, 1.0));
    directionalLight->setDirection(Ogre::Vector3( 0, -1, -1 ));

    Ogre::Vector3 sunPosition(15, 15, -90);
    Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
    pointLight->setType(Ogre::Light::LT_POINT);
    pointLight->setPosition(sunPosition);
    pointLight->setDiffuseColour(1.0, 1.0, 1.0);
    pointLight->setSpecularColour(1.0, 1.0, 1.0);

    Ogre::SceneNode *sunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("SUN_NODE");
    sunNode->setPosition(sunPosition);
    sunNode->attachObject(mSceneMgr->createParticleSystem("SUN_PARTICLE", "Space/Sun"));
}
示例#18
0
 void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){
       Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
        // std::cout << "Adding node with name" << node->getName();
     addActor (node->getName(), model, node->getPosition());
 }
示例#19
0
OSG::NodeTransitPtr initVTK(void)
{
    OSG::NodeUnrecPtr returnValue = NULL;

    OSG::Char8 *szDataRoot = getenv("VTK_DATA_ROOT");

    if(szDataRoot == NULL)
    {
        fprintf(stderr, "VTK_DATA_ROOT not set\n");
        exit(0);
    }

    std::string szFilename;

    szFilename.assign(szDataRoot);
    szFilename += "/Data/office.binary.vtk";

    vtkStructuredGridReader *reader = vtkStructuredGridReader::New();

    reader->SetFileName(szFilename.c_str());
    reader->Update();

#if 0
    OSG::Real64 length = reader->GetOutput()->GetLength();

    OSG::Real64 maxVelocity = 
        reader->GetOutput()->GetPointData()->GetVectors()->GetMaxNorm();

    OSG::Real64 maxTime = 35.0 * length / maxVelocity;
#endif


    returnValue = OSG::Node::create();

    returnValue->setCore(OSG::Group::create());

    // Create source for streamtubes
    vtkPointSource *seeds = vtkPointSource::New();
    seeds->SetRadius(0.15);
    seeds->SetCenter(0.1, 2.1, 0.5);
    seeds->SetNumberOfPoints(6);

    vtkRungeKutta4 *integ = vtkRungeKutta4::New();
    vtkStreamLine *streamer = vtkStreamLine::New();
    streamer->SetInputConnection(reader->GetOutputPort());
#if VTK_MAJOR_VERSION >= 6
    streamer->SetSourceData(seeds->GetOutput());
#else
    streamer->SetSource(seeds->GetOutput());
#endif
    streamer->SetMaximumPropagationTime(500);
    streamer->SetStepLength(0.5);
    streamer->SetIntegrationStepLength(0.05);
    streamer->SetIntegrationDirectionToIntegrateBothDirections();
    streamer->SetIntegrator(integ);

    // The tube is wrapped around the generated streamline. By varying the
    // radius by the inverse of vector magnitude, we are creating a tube
    // whose radius is proportional to mass flux (in incompressible flow).
    vtkTubeFilter *streamTube = vtkTubeFilter::New();
    streamTube->SetInputConnection(streamer->GetOutputPort());
    streamTube->SetRadius(0.02);
    streamTube->SetNumberOfSides(12);
    streamTube->SetVaryRadiusToVaryRadiusByVector();
    vtkPolyDataMapper *mapStreamTube = vtkPolyDataMapper::New();
    mapStreamTube->SetInputConnection(streamTube->GetOutputPort());
    mapStreamTube->SetScalarRange(
        reader->GetOutput()->GetPointData()->GetScalars()->GetRange());
    vtkActor *streamTubeActor = vtkActor::New();
    streamTubeActor->SetMapper(mapStreamTube);
    streamTubeActor->GetProperty()->BackfaceCullingOn();

    addActor(returnValue, streamTubeActor);


    vtkStructuredGridGeometryFilter *table1 = 
        vtkStructuredGridGeometryFilter::New();

    table1->SetInputConnection(reader->GetOutputPort());
    table1->SetExtent(11, 15, 7, 9, 8, 8);

    vtkPolyDataNormals *normTable1 = vtkPolyDataNormals::New();
    normTable1->SetInputConnection(table1->GetOutputPort());

    vtkPolyDataMapper *mapTable1 = vtkPolyDataMapper::New();
    mapTable1->SetInputConnection(normTable1->GetOutputPort());
    mapTable1->ScalarVisibilityOff();
    
    vtkActor *table1Actor = vtkActor::New();
    table1Actor->SetMapper(mapTable1);
    table1Actor->GetProperty()->SetColor(.59, .427, .392);

    addActor(returnValue, table1Actor);



    vtkStructuredGridGeometryFilter *table2 = 
        vtkStructuredGridGeometryFilter::New();
    table2->SetInputConnection(reader->GetOutputPort());
    table2->SetExtent(11, 15, 10, 12, 8, 8);

    vtkPolyDataNormals *normTable2 = vtkPolyDataNormals::New();
    normTable2->SetInputConnection(table2->GetOutputPort());

    vtkPolyDataMapper *mapTable2 = vtkPolyDataMapper::New();
    mapTable2->SetInputConnection(normTable2->GetOutputPort());
    mapTable2->ScalarVisibilityOff();
    
    vtkActor *table2Actor = vtkActor::New();
    table2Actor->SetMapper(mapTable2);
    table2Actor->GetProperty()->SetColor(.59, .427, .392);

    addActor(returnValue, table2Actor);



    vtkStructuredGridGeometryFilter *FilingCabinet1 = 
        vtkStructuredGridGeometryFilter::New();

    FilingCabinet1->SetInputConnection(reader->GetOutputPort());
    FilingCabinet1->SetExtent(15, 15, 7, 9, 0, 8);

    vtkPolyDataNormals *normFilingCabinet1 = vtkPolyDataNormals::New();
    normFilingCabinet1->SetInputConnection(FilingCabinet1->GetOutputPort());

    vtkPolyDataMapper *mapFilingCabinet1 = vtkPolyDataMapper::New();
    mapFilingCabinet1->SetInputConnection(normFilingCabinet1->GetOutputPort());
    mapFilingCabinet1->ScalarVisibilityOff();

    vtkActor *FilingCabinet1Actor = vtkActor::New();
    FilingCabinet1Actor->SetMapper(mapFilingCabinet1);
    FilingCabinet1Actor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, FilingCabinet1Actor);



    vtkStructuredGridGeometryFilter *FilingCabinet2 = 
        vtkStructuredGridGeometryFilter::New();
    FilingCabinet2->SetInputConnection(reader->GetOutputPort());
    FilingCabinet2->SetExtent(15, 15, 10, 12, 0, 8);

    vtkPolyDataNormals *normFilingCabinet2 = vtkPolyDataNormals::New();
    normFilingCabinet2->SetInputConnection(FilingCabinet2->GetOutputPort());

    vtkPolyDataMapper *mapFilingCabinet2 = vtkPolyDataMapper::New();
    mapFilingCabinet2->SetInputConnection(normFilingCabinet2->GetOutputPort());
    mapFilingCabinet2->ScalarVisibilityOff();

    vtkActor *FilingCabinet2Actor = vtkActor::New();
    FilingCabinet2Actor->SetMapper(mapFilingCabinet2);
    FilingCabinet2Actor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, FilingCabinet2Actor);



    vtkStructuredGridGeometryFilter *bookshelf1Top = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1Top->SetInputConnection(reader->GetOutputPort());
    bookshelf1Top->SetExtent(13, 13, 0, 4, 0, 11);

    vtkPolyDataNormals *normbookshelf1Top = vtkPolyDataNormals::New();
    normbookshelf1Top->SetInputConnection(bookshelf1Top->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1Top = vtkPolyDataMapper::New();
    mapBookshelf1Top->SetInputConnection(normbookshelf1Top->GetOutputPort());
    mapBookshelf1Top->ScalarVisibilityOff();

    vtkActor *bookshelf1TopActor = vtkActor::New();
    bookshelf1TopActor->SetMapper(mapBookshelf1Top);
    bookshelf1TopActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf1TopActor);


    
    vtkStructuredGridGeometryFilter *bookshelf1Bottom = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1Bottom->SetInputConnection(reader->GetOutputPort());
    bookshelf1Bottom->SetExtent(20, 20, 0, 4, 0, 11);

    vtkPolyDataNormals *normbookshelf1Bottom = vtkPolyDataNormals::New();
    normbookshelf1Bottom->SetInputConnection(
        bookshelf1Bottom->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1Bottom = vtkPolyDataMapper::New();
    mapBookshelf1Bottom->SetInputConnection(
        normbookshelf1Bottom->GetOutputPort());
    mapBookshelf1Bottom->ScalarVisibilityOff();

    vtkActor *bookshelf1BottomActor = vtkActor::New();
    bookshelf1BottomActor->SetMapper(mapBookshelf1Bottom);
    bookshelf1BottomActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf1BottomActor);



    vtkStructuredGridGeometryFilter *bookshelf1Front = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1Front->SetInputConnection(reader->GetOutputPort());
    bookshelf1Front->SetExtent(13, 20, 0, 0, 0, 11);

    vtkPolyDataNormals *normbookshelf1Front = vtkPolyDataNormals::New();
    normbookshelf1Front->SetInputConnection(bookshelf1Front->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1Front = vtkPolyDataMapper::New();
    mapBookshelf1Front->SetInputConnection(
        normbookshelf1Front->GetOutputPort());
    mapBookshelf1Front->ScalarVisibilityOff();

    vtkActor *bookshelf1FrontActor = vtkActor::New();
    bookshelf1FrontActor->SetMapper(mapBookshelf1Front);
    bookshelf1FrontActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf1FrontActor);



    vtkStructuredGridGeometryFilter *bookshelf1Back = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1Back->SetInputConnection(reader->GetOutputPort());
    bookshelf1Back->SetExtent(13, 20, 4, 4, 0, 11);

    vtkPolyDataNormals *normbookshelf1Back = vtkPolyDataNormals::New();
    normbookshelf1Back->SetInputConnection(bookshelf1Back->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1Back = vtkPolyDataMapper::New();
    mapBookshelf1Back->SetInputConnection(normbookshelf1Back->GetOutputPort());
    mapBookshelf1Back->ScalarVisibilityOff();

    vtkActor *bookshelf1BackActor = vtkActor::New();
    bookshelf1BackActor->SetMapper(mapBookshelf1Back);
    bookshelf1BackActor->GetProperty()->SetColor(.8, .8, .6);
    
    addActor(returnValue, bookshelf1BackActor);



    vtkStructuredGridGeometryFilter *bookshelf1LHS = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1LHS->SetInputConnection(reader->GetOutputPort());
    bookshelf1LHS->SetExtent(13, 20, 0, 4, 0, 0);

    vtkPolyDataNormals *normbookshelf1LHS = vtkPolyDataNormals::New();
    normbookshelf1LHS->SetInputConnection(bookshelf1LHS->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1LHS = vtkPolyDataMapper::New();
    mapBookshelf1LHS->SetInputConnection(normbookshelf1LHS->GetOutputPort());
    mapBookshelf1LHS->ScalarVisibilityOff();

    vtkActor *bookshelf1LHSActor = vtkActor::New();
    bookshelf1LHSActor->SetMapper(mapBookshelf1LHS);
    bookshelf1LHSActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf1LHSActor);



    vtkStructuredGridGeometryFilter *bookshelf1RHS = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf1RHS->SetInputConnection(reader->GetOutputPort());
    bookshelf1RHS->SetExtent(13, 20, 0, 4, 11, 11);

    vtkPolyDataNormals *normbookshelf1RHS = vtkPolyDataNormals::New();
    normbookshelf1RHS->SetInputConnection(bookshelf1RHS->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf1RHS = vtkPolyDataMapper::New();
    mapBookshelf1RHS->SetInputConnection(normbookshelf1RHS->GetOutputPort());
    mapBookshelf1RHS->ScalarVisibilityOff();

    vtkActor *bookshelf1RHSActor = vtkActor::New();
    bookshelf1RHSActor->SetMapper(mapBookshelf1RHS);
    bookshelf1RHSActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf1RHSActor);



    vtkStructuredGridGeometryFilter *bookshelf2Top = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2Top->SetInputConnection(reader->GetOutputPort());
    bookshelf2Top->SetExtent(13, 13, 15, 19, 0, 11);

    vtkPolyDataNormals *normbookshelf2Top = vtkPolyDataNormals::New();
    normbookshelf2Top->SetInputConnection(bookshelf2Top->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2Top = vtkPolyDataMapper::New();
    mapBookshelf2Top->SetInputConnection(normbookshelf2Top->GetOutputPort());
    mapBookshelf2Top->ScalarVisibilityOff();

    vtkActor *bookshelf2TopActor = vtkActor::New();
    bookshelf2TopActor->SetMapper(mapBookshelf2Top);
    bookshelf2TopActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf2TopActor);


    vtkStructuredGridGeometryFilter *bookshelf2Bottom = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2Bottom->SetInputConnection(reader->GetOutputPort());
    bookshelf2Bottom->SetExtent(20, 20, 15, 19, 0, 11);

    vtkPolyDataNormals *normbookshelf2Bottom = vtkPolyDataNormals::New();
    normbookshelf2Bottom->SetInputConnection(
        bookshelf2Bottom->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2Bottom = vtkPolyDataMapper::New();
    mapBookshelf2Bottom->SetInputConnection(
        normbookshelf2Bottom->GetOutputPort());
    mapBookshelf2Bottom->ScalarVisibilityOff();

    vtkActor *bookshelf2BottomActor = vtkActor::New();
    bookshelf2BottomActor->SetMapper(mapBookshelf2Bottom);
    bookshelf2BottomActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf2BottomActor);



    vtkStructuredGridGeometryFilter *bookshelf2Front = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2Front->SetInputConnection(reader->GetOutputPort());
    bookshelf2Front->SetExtent(13, 20, 15, 15, 0, 11);

    vtkPolyDataNormals *normbookshelf2Front = vtkPolyDataNormals::New();
    normbookshelf2Front->SetInputConnection(bookshelf2Front->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2Front = vtkPolyDataMapper::New();
    mapBookshelf2Front->SetInputConnection(
        normbookshelf2Front->GetOutputPort());
    mapBookshelf2Front->ScalarVisibilityOff();

    vtkActor *bookshelf2FrontActor = vtkActor::New();
    bookshelf2FrontActor->SetMapper(mapBookshelf2Front);
    bookshelf2FrontActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf2FrontActor);



    vtkStructuredGridGeometryFilter *bookshelf2Back = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2Back->SetInputConnection(reader->GetOutputPort());
    bookshelf2Back->SetExtent(13, 20, 19, 19, 0, 11);

    vtkPolyDataNormals *normbookshelf2Back = vtkPolyDataNormals::New();
    normbookshelf2Back->SetInputConnection(bookshelf2Back->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2Back = vtkPolyDataMapper::New();
    mapBookshelf2Back->SetInputConnection(normbookshelf2Back->GetOutputPort());
    mapBookshelf2Back->ScalarVisibilityOff();

    vtkActor *bookshelf2BackActor = vtkActor::New();
    bookshelf2BackActor->SetMapper(mapBookshelf2Back);
    bookshelf2BackActor->GetProperty()->SetColor(.8, .8, .6);
    
    addActor(returnValue, bookshelf2BackActor);



    vtkStructuredGridGeometryFilter *bookshelf2LHS = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2LHS->SetInputConnection(reader->GetOutputPort());
    bookshelf2LHS->SetExtent(13, 20, 15, 19, 0, 0);

    vtkPolyDataNormals *normbookshelf2LHS = vtkPolyDataNormals::New();
    normbookshelf2LHS->SetInputConnection(bookshelf2LHS->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2LHS = vtkPolyDataMapper::New();
    mapBookshelf2LHS->SetInputConnection(normbookshelf2LHS->GetOutputPort());
    mapBookshelf2LHS->ScalarVisibilityOff();
    vtkActor *bookshelf2LHSActor = vtkActor::New();
    bookshelf2LHSActor->SetMapper(mapBookshelf2LHS);
    bookshelf2LHSActor->GetProperty()->SetColor(.8, .8, .6);

    addActor(returnValue, bookshelf2LHSActor);



    vtkStructuredGridGeometryFilter *bookshelf2RHS = 
        vtkStructuredGridGeometryFilter::New();
    bookshelf2RHS->SetInputConnection(reader->GetOutputPort());
    bookshelf2RHS->SetExtent(13, 20, 15, 19, 11, 11);

    vtkPolyDataNormals *normbookshelf2RHS = vtkPolyDataNormals::New();
    normbookshelf2RHS->SetInputConnection(bookshelf2RHS->GetOutputPort());

    vtkPolyDataMapper *mapBookshelf2RHS = vtkPolyDataMapper::New();
    mapBookshelf2RHS->SetInputConnection(normbookshelf2RHS->GetOutputPort());
    mapBookshelf2RHS->ScalarVisibilityOff();

    vtkActor *bookshelf2RHSActor = vtkActor::New();
    bookshelf2RHSActor->SetMapper(mapBookshelf2RHS);
    bookshelf2RHSActor->GetProperty()->SetColor(.8, .8, .6);
    
    addActor(returnValue, bookshelf2RHSActor);



    vtkStructuredGridGeometryFilter *window = 
        vtkStructuredGridGeometryFilter::New();
    window->SetInputConnection(reader->GetOutputPort());
    window->SetExtent(20, 20, 6, 13, 10, 13);

    vtkPolyDataNormals *normWindow = vtkPolyDataNormals::New();
    normWindow->SetInputConnection(window->GetOutputPort());

    vtkPolyDataMapper *mapWindow = vtkPolyDataMapper::New();
    mapWindow->SetInputConnection(normWindow->GetOutputPort());
    mapWindow->ScalarVisibilityOff(); 

    vtkActor *windowActor = vtkActor::New();
    windowActor->SetMapper(mapWindow);
    windowActor->GetProperty()->SetColor(.3, .3, .5);
    
    addActor(returnValue, windowActor);



    vtkStructuredGridGeometryFilter *outlet = 
        vtkStructuredGridGeometryFilter::New();
    outlet->SetInputConnection(reader->GetOutputPort());
    outlet->SetExtent(0, 0, 9, 10, 14, 16);

    vtkPolyDataNormals *normoutlet = vtkPolyDataNormals::New();
    normoutlet->SetInputConnection(outlet->GetOutputPort());

    vtkPolyDataMapper *mapOutlet = vtkPolyDataMapper::New();
    mapOutlet->SetInputConnection(normoutlet->GetOutputPort());
    mapOutlet->ScalarVisibilityOff();
    vtkActor *outletActor = vtkActor::New();
    outletActor->SetMapper(mapOutlet);
    outletActor->GetProperty()->SetColor(0, 0, 0);

    addActor(returnValue, outletActor);



    vtkStructuredGridGeometryFilter *inlet = 
        vtkStructuredGridGeometryFilter::New();
    inlet->SetInputConnection(reader->GetOutputPort());
    inlet->SetExtent(0, 0, 9, 10, 0, 6);

    vtkPolyDataNormals *norminlet = vtkPolyDataNormals::New();
    norminlet->SetInputConnection(inlet->GetOutputPort());

    vtkPolyDataMapper *mapInlet = vtkPolyDataMapper::New();
    mapInlet->SetInputConnection(norminlet->GetOutputPort());

    mapInlet->ScalarVisibilityOff();
    vtkActor *inletActor = vtkActor::New();
    inletActor->SetMapper(mapInlet);
    inletActor->GetProperty()->SetColor(0, 0, 0);



    vtkStructuredGridOutlineFilter *outline = 
        vtkStructuredGridOutlineFilter::New();
    
    outline->SetInputConnection(reader->GetOutputPort());
    
    vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
    mapOutline->SetInputConnection(outline->GetOutputPort());
    
    vtkActor *outlineActor = vtkActor::New();
    
    outlineActor->SetMapper(mapOutline);
    outlineActor->GetProperty()->SetColor(0, 0, 0);
    
    addActor(returnValue, outlineActor);

    OSG::Thread::getCurrentChangeList()->dump();

    return OSG::NodeTransitPtr(returnValue);
}
bool NxuPhysicsExport::Write(NxJoint *j,const char *userProperties,const char *id)
{
	bool ret = false;

	NxSceneDesc *current = getCurrentScene();

	CustomCopy cc(mCollection,current);

	NxJointDesc *joint = 0;

	switch ( j->getType() )
	{
		case NX_JOINT_PRISMATIC:
			if ( 1 )
			{
				::NxPrismaticJointDesc d1;
				NxPrismaticJoint *sj = j->isPrismaticJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxPrismaticJointDesc *desc = new NxPrismaticJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_REVOLUTE:
			if ( 1 )
			{
				::NxRevoluteJointDesc d1;
				NxRevoluteJoint *sj = j->isRevoluteJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxRevoluteJointDesc *desc = new NxRevoluteJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_CYLINDRICAL:
			if ( 1 )
			{
				::NxCylindricalJointDesc d1;
				NxCylindricalJoint *sj = j->isCylindricalJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxCylindricalJointDesc *desc = new NxCylindricalJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_SPHERICAL:
			if ( 1 )
			{
				::NxSphericalJointDesc d1;
				NxSphericalJoint *sj = j->isSphericalJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxSphericalJointDesc *desc = new NxSphericalJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_POINT_ON_LINE:
			if ( 1 )
			{
				::NxPointOnLineJointDesc d1;
				NxPointOnLineJoint *sj = j->isPointOnLineJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxPointOnLineJointDesc *desc = new NxPointOnLineJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_POINT_IN_PLANE:
			if ( 1 )
			{
				::NxPointInPlaneJointDesc d1;
				NxPointInPlaneJoint *sj = j->isPointInPlaneJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxPointInPlaneJointDesc *desc = new NxPointInPlaneJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_DISTANCE:
			if ( 1 )
			{
				::NxDistanceJointDesc d1;
				NxDistanceJoint *sj = j->isDistanceJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxDistanceJointDesc *desc = new NxDistanceJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_PULLEY:
			if ( 1 )
			{
				::NxPulleyJointDesc d1;
				NxPulleyJoint *sj = j->isPulleyJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxPulleyJointDesc *desc = new NxPulleyJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_FIXED:
			if ( 1 )
			{
				::NxFixedJointDesc d1;
				NxFixedJoint *sj = j->isFixedJoint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxFixedJointDesc *desc = new NxFixedJointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		case NX_JOINT_D6:
			if ( 1 )
			{
				::NxD6JointDesc d1;
				NxD6Joint *sj = j->isD6Joint();
				sj->saveToDesc(d1);
				addActor( d1.actor[0] );
				addActor( d1.actor[1] );
				NxD6JointDesc *desc = new NxD6JointDesc;
				desc->copyFrom(d1,cc);
				joint = static_cast<NxJointDesc *>(desc);
			}
			break;
		default:
			break;

	}


	//Add	Limits
	// in	addition,	we also	have to	write	out	its	limit	planes!
	j->resetLimitPlaneIterator();
	if (j->hasMoreLimitPlanes())
	{
		// write limit point
		joint->mOnActor2 = j->getLimitPoint(joint->mPlaneLimitPoint);

		NxArray< NxPlaneInfoDesc *> plist;


		// write the plane normals
		while	(j->hasMoreLimitPlanes())
		{
			NxPlaneInfoDesc *pInfo	=	new	NxPlaneInfoDesc();
#if NX_SDK_VERSION_NUMBER >= 272
			j->getNextLimitPlane(pInfo->mPlaneNormal,	pInfo->mPlaneD, &pInfo->restitution);
#else
			j->getNextLimitPlane(pInfo->mPlaneNormal,	pInfo->mPlaneD);
#endif
			plist.push_back(pInfo);
		}

		if ( plist.size() )
		{
			for (int i=plist.size()-1; i>=0; i--)
			{
				NxPlaneInfoDesc *p = plist[i];
				joint->mPlaneInfo.pushBack(p);
			}
		}

	}


	if ( joint )
	{
		if ( id )
		{
			joint->mId = id;
		}
		else
		{
      char scratch[512];
      sprintf(scratch,"Joint_%d", current->mJoints.size());
      joint->mId = getGlobalString(scratch);
      joint->mUserProperties = getGlobalString(userProperties);
    }
		current->mJoints.push_back(joint);
		ret = true;
	}

  return ret;
}
示例#21
0
void TBFE::changeMap(std::string MapName)
{
  actors.resize(0);
  Current_Map.loadMap(MapName);
  addActor(Main_Player);
};
示例#22
0
void
OutofcoreCloud::render (vtkRenderer* renderer)
{
  vtkSmartPointer<vtkCamera> active_camera = renderer->GetActiveCamera ();

  Scene *scene = Scene::instance ();
  Camera *camera = scene->getCamera (active_camera);

  if (render_camera_ != NULL && render_camera_->getName() == camera->getName ())
  {
    renderer->ComputeAspect ();
    //double *aspect = renderer->GetAspect ();
    int *size = renderer->GetSize ();

    OctreeDisk::BreadthFirstIterator breadth_first_it (*octree_);
    breadth_first_it.setMaxDepth(display_depth_);

    double frustum[24];
    camera->getFrustum(frustum);

    Eigen::Vector3d eye = camera->getPosition();
    Eigen::Matrix4d view_projection_matrix = camera->getViewProjectionMatrix();
    //Eigen::Matrix4d view_projection_matrix = projection_matrix * model_view_matrix;//camera->getViewProjectionMatrix();

    cloud_actors_->RemoveAllItems ();

    while ( *breadth_first_it !=0 )
    {
      OctreeDiskNode *node = *breadth_first_it;

      Eigen::Vector3d min_bb, max_bb;
      node->getBoundingBox(min_bb, max_bb);

      // Frustum culling
      if (pcl::visualization::cullFrustum(frustum, min_bb, max_bb) == pcl::visualization::PCL_OUTSIDE_FRUSTUM)
      {
        breadth_first_it.skipChildVoxels();
        breadth_first_it++;
        continue;
      }

      // Bounding box lod projection
      float coverage = pcl::visualization::viewScreenArea(eye, min_bb, max_bb, view_projection_matrix, size[0], size[1]);
      if (coverage <= lod_pixel_threshold_)
      {
        breadth_first_it.skipChildVoxels();
      }

//      for (int i=0; i < node->getDepth(); i++)
//        std::cout << " ";
//      std::cout << coverage << "-" << pcd_file << endl;//" : " << (coverage > (size[0] * size[1])) << endl;

      std::string pcd_file = node->getPCDFilename ().string ();

      cloud_data_cache_mutex.lock();

      PcdQueueItem pcd_queue_item(pcd_file, coverage);

      // If we can lock the queue add another item
      if (pcd_queue_mutex.try_lock())
      {
        pcd_queue.push(pcd_queue_item);
        pcd_queue_mutex.unlock();
      }

      if (cloud_data_cache.hasKey(pcd_file))
      {
        //std::cout << "Has Key for: " << pcd_file << std::endl;
        if (cloud_actors_map_.find (pcd_file) == cloud_actors_map_.end ())
        {

          vtkSmartPointer<vtkActor> cloud_actor = vtkSmartPointer<vtkActor>::New ();
          CloudDataCacheItem *cloud_data_cache_item = &cloud_data_cache.get(pcd_file);

#if VTK_RENDERING_BACKEND_OPENGL_VERSION < 2
          vtkSmartPointer<vtkVertexBufferObjectMapper> mapper = vtkSmartPointer<vtkVertexBufferObjectMapper>::New ();
          mapper->SetInput (cloud_data_cache_item->item);
#else
          vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
          // Usually we choose between SetInput and SetInputData based on VTK version. But OpenGL ≥ 2 automatically
          // means VTK version is ≥ 6.3
          mapper->SetInputData (cloud_data_cache_item->item);
#endif

          cloud_actor->SetMapper (mapper);
          cloud_actor->GetProperty ()->SetColor (0.0, 0.0, 1.0);
          cloud_actor->GetProperty ()->SetPointSize (1);
          cloud_actor->GetProperty ()->SetLighting (false);

          cloud_actors_map_[pcd_file] = cloud_actor;
        }

        if (!hasActor (cloud_actors_map_[pcd_file]))
        {
          points_loaded_ += cloud_actors_map_[pcd_file]->GetMapper ()->GetInput ()->GetNumberOfPoints ();
          data_loaded_ += cloud_actors_map_[pcd_file]->GetMapper ()->GetInput ()->GetActualMemorySize();
        }

        //std::cout << "Adding Actor: " << pcd_file << std::endl;

        cloud_actors_->AddItem (cloud_actors_map_[pcd_file]);
        addActor (cloud_actors_map_[pcd_file]);
      }

      cloud_data_cache_mutex.unlock();

      breadth_first_it++;
    }

    // We're done culling, notify the pcd_reader thread the queue is read
    pcd_queue_ready.notify_one();

    std::vector<vtkActor*> actors_to_remove;
    {
      actors_to_remove.clear ();
      actors_->InitTraversal ();
      for (vtkIdType i = 0; i < actors_->GetNumberOfItems (); i++)
      {
        vtkActor* actor = actors_->GetNextActor ();
        if (actor != voxel_actor_.GetPointer ())
        {
          bool actor_found = false;
          cloud_actors_->InitTraversal ();
          for (vtkIdType j = 0; j < cloud_actors_->GetNumberOfItems (); j++)
          {
            vtkActor* cloud_actor = cloud_actors_->GetNextActor ();
            if (actor == cloud_actor)
            {
              actor_found = true;
              break;
            }
          }

          if (!actor_found)
          {
            actors_to_remove.push_back (actor);
          }
        }
      }
    }

    for (size_t i = 0; i < actors_to_remove.size (); i++)
    {
      points_loaded_ -= actors_to_remove.back ()->GetMapper ()->GetInput ()->GetNumberOfPoints ();
      data_loaded_ -= actors_to_remove.back ()->GetMapper ()->GetInput ()->GetActualMemorySize();
      removeActor (actors_to_remove.back ());
      actors_to_remove.pop_back ();
    }
  }

  Object::render(renderer);
}
void Player::createActor(Coordinate3D<int> loc, int hitpoints){
	addActor(std::shared_ptr<BoardActor>(new BoardActor(loc, *this, hitpoints)));
}
示例#24
0
	Phy2dActor* Phy2dWorld::createActor()
	{
		Phy2dActor *actor = new Phy2dActor(this);
		addActor(actor);
		return actor;
	}
示例#25
0
int SceneManager::addPhysicsShape(PhysicsShape *physicsShape) {
	int id = addActor(physicsShape);
	physicsShapes[0][id] = physicsShape;
	return id;
}
示例#26
0
void AttributeContainer::addActor(size_t id) {
	return addActor(id, _defaultValue);
}
示例#27
0
void Cross::cross_cars()
{
    if(!accident)
    {
        int segs;
        if(east->semaphore->isActivo())
        {
            // west - east
            if(!cross_e_1)
            {
                cross_e_1 = east->cola1->pop();
                if(cross_e_1){
                    segs = cross_e_1->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!east->ableToCross(segs))cross_e_1->setVXY(segs-1);
                    addActor(cross_e_1);
                    cross_e_1->movingON();
                }
            }

            if(!cross_e_2)
            {
                cross_e_2 = east->cola2->pop();
                if(cross_e_2){
                    segs = cross_e_2->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!east->ableToCross(segs))cross_e_2->setVXY(segs-1);
                    addActor(cross_e_2);
                    cross_e_2->movingON();
                }
            }

            //east - west
            if(!cross_w_1)
            {
                cross_w_1 = west->cola1->pop();
                if(cross_w_1){
                    segs = cross_w_1->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!west->ableToCross(segs))cross_w_1->setVXY(segs-1);
                    addActor(cross_w_1);
                    cross_w_1->movingON();

                }
            }

            if(!cross_w_2)
            {
                cross_w_2 = west->cola2->pop();
                if(cross_w_2){
                    segs = cross_w_2->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!west->ableToCross(segs))cross_w_2->setVXY(segs-1);
                    addActor(cross_w_2);
                    cross_w_2->movingON();
                }
            }
        }else{
            //Bus puede cruzar en rojo
            int can_Cross;
            //east
            if(!cross_e_1)
            {
                cross_e_1 = east->cola1->first();
                if(cross_e_1!=NULL && cross_e_1->type == BUS &&
                        !cross_e_1->checked)
                {
                    cross_e_1->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_e_1 = east->cola1->pop();
                        segs = cross_e_1->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_e_1);
                        cross_e_1->movingON();

                        checkColisions(east,cross_e_1,&e1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
                    }else{
                        cross_e_1 = NULL;
                    }
                }else{
                    cross_e_1 = NULL;
                }
            }else{
                if(cross_e_1->type == BUS)
                    checkColisions(east,cross_e_1,&e1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
            }
            if(!cross_e_2)
            {
                cross_e_2 = east->cola2->first();
                if(cross_e_2!=NULL && cross_e_2->type == BUS &&
                        !cross_e_2->checked)
                {
                    cross_e_2->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_e_2 = east->cola2->pop();
                        segs = cross_e_2->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_e_2);
                        cross_e_2->movingON();

                        checkColisions(east,cross_e_2,&e2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
                    }else{
                        cross_e_2 = NULL;
                    }
                }else{
                    cross_e_2 = NULL;
                }
            }else{
                if(cross_e_2->type == BUS)
                    checkColisions(east,cross_e_2,&e2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
            }

            //west
            if(!cross_w_1)
            {
                cross_w_1 = west->cola1->first();
                if(cross_w_1!=NULL && cross_w_1->type == BUS &&
                        !cross_w_1->checked)
                {
                    cross_w_1->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_w_1 = west->cola1->pop();
                        segs = cross_w_1->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_w_1);
                        cross_w_1->movingON();

                        checkColisions(west,cross_w_1,&w1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
                    }else{
                        cross_w_1 = NULL;
                    }
                }else{
                    cross_w_1 = NULL;
                }
            }else{
                if(cross_w_1->type == BUS)
                    checkColisions(west,cross_w_1,&w1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
            }
            if(!cross_w_2)
            {
                cross_w_2 = west->cola2->first();
                if(cross_w_2!=NULL && cross_w_2->type == BUS &&
                        !cross_w_2->checked)
                {
                    cross_w_2->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_w_2 = west->cola2->pop();
                        segs = cross_w_2->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_w_2);
                        cross_w_2->movingON();

                        checkColisions(west,cross_w_2,&w2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
                    }else{
                        cross_w_2 = NULL;
                    }
                }else{
                    cross_w_2 = NULL;
                }
            }else{
                if(cross_w_2->type == BUS)
                    checkColisions(west,cross_w_2,&w2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2);
            }
        }

        if(north->semaphore->isActivo()){
            //south - north
            if(!cross_n_1)
            {
                cross_n_1 = north->cola1->pop();
                if(cross_n_1){
                    segs = cross_n_1->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!north->ableToCross(segs))cross_n_1->setVXY(segs-1);
                    addActor(cross_n_1);
                    cross_n_1->movingON();
                }
            }

            if(!cross_n_2)
            {
                cross_n_2 = north->cola2->pop();
                if(cross_n_2){
                    segs = cross_n_2->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!north->ableToCross(segs))cross_n_2->setVXY(segs-1);
                    addActor(cross_n_2);
                    cross_n_2->movingON();
                }
            }

            //north - south
            if(!cross_s_1)
            {
                cross_s_1 = south->cola1->pop();
                if(cross_s_1){
                    segs = cross_s_1->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!south->ableToCross(segs))cross_s_1->setVXY(segs-1);
                    addActor(cross_s_1);
                    cross_s_1->movingON();
                }
            }

            if(!cross_s_2)
            {
                cross_s_2 = south->cola2->pop();
                if(cross_s_2){
                    segs = cross_s_2->setMoving();
                    cout<<"Segs: "<<segs<<endl;
                    if(!south->ableToCross(segs))cross_s_2->setVXY(segs-1);
                    addActor(cross_s_2);
                    cross_s_2->movingON();
                }
            }
        }else{
            //Bus puede cruzar en rojo 2
            int can_Cross;
            //north
            if(!cross_n_1)
            {
                cross_n_1 = north->cola1->first();
                if(cross_n_1!=NULL && cross_n_1->type == BUS &&
                        !cross_n_1->checked)
                {
                    cross_n_1->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_n_1 = north->cola1->pop();
                        segs = cross_n_1->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_n_1);
                        cross_n_1->movingON();

                        checkColisions(north,cross_n_1,&n1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
                    }else{
                        cross_n_1 = NULL;
                    }
                }else{
                    cross_n_1 = NULL;
                }
            }else{
                if(cross_n_1->type == BUS)
                    checkColisions(north,cross_n_1,&n1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
            }
            if(!cross_n_2)
            {
                cross_n_2 = north->cola2->first();
                if(cross_n_2!=NULL && cross_n_2->type == BUS &&
                        !cross_n_2->checked)
                {
                    cross_n_2->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_n_2 = north->cola2->pop();
                        segs = cross_n_2->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_n_2);
                        cross_n_2->movingON();

                        checkColisions(north,cross_n_2,&n2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
                    }else{
                        cross_n_2 = NULL;
                    }
                }else{
                    cross_n_2 = NULL;
                }
            }else{
                if(cross_n_2->type == BUS)
                    checkColisions(north,cross_n_2,&n2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
            }

            //south
            if(!cross_s_1)
            {
                cross_s_1 = south->cola1->first();
                if(cross_s_1!=NULL && cross_s_1->type == BUS &&
                        !cross_s_1->checked)
                {
                    cross_s_1->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_s_1 = south->cola1->pop();
                        segs = cross_s_1->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_s_1);
                        cross_s_1->movingON();

                        checkColisions(south,cross_s_1,&s1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
                    }else{
                        cross_s_1 = NULL;
                    }
                }else{
                    cross_s_1 = NULL;
                }
            }else{
                if(cross_s_1->type == BUS)
                    checkColisions(south,cross_s_1,&s1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
            }
            if(!cross_s_2)
            {
                cross_s_2 = south->cola2->first();
                if(cross_s_2!=NULL && cross_s_2->type == BUS &&
                        !cross_s_2->checked)
                {
                    cross_s_2->checked=true;
                    //srand(time(NULL));
                    can_Cross = rand()%11;
                    cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl;
                    if(crossInRed[can_Cross])
                    {
                        cross_s_2 = south->cola2->pop();
                        segs = cross_s_2->setMoving();
                        cout<<"Segs: "<<segs<<endl;
                        addActor(cross_s_2);
                        cross_s_2->movingON();

                        checkColisions(south,cross_s_2,&s2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
                    }else{
                        cross_s_2 = NULL;
                    }
                }else{
                    cross_s_2 = NULL;
                }
            }else{
                if(cross_s_2->type == BUS)
                    checkColisions(south,cross_s_2,&s2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2);
            }
        }
    }
    //east
    if(cross_e_1)
    {
        cross_e_1->logica();
        float x = cross_e_1->position().x();
        float xf = east->posPilas[0]->x();
        if(xf>x)
        {
            removeActor(cross_e_1);
//            cross_e_1->movingOFF();
            east->pila1->push(cross_e_1);
            cross_e_1=NULL;
        }
    }
    if(cross_e_2)
    {
        cross_e_2->logica();
        float x = cross_e_2->position().x();
        float xf = east->posPilas[1]->x();
        if(xf>x)
        {
            removeActor(cross_e_2);
//            cross_e_2->movingOFF();
            east->pila2->push(cross_e_2);
            cross_e_2=NULL;
        }
    }

    //west
    if(cross_w_1)
    {
        cross_w_1->logica();
        float x = cross_w_1->position().x();
        float xf = west->posPilas[0]->x();
        if(xf<x + cross_w_1->imagen->width())
        {
            removeActor(cross_w_1);
//            cross_w_1->movingOFF();
            west->pila1->push(cross_w_1);
            cross_w_1=NULL;
        }
    }
    if(cross_w_2)
    {
        cross_w_2->logica();
        float x = cross_w_2->position().x();
        float xf = west->posPilas[1]->x();
        if(xf<x + cross_w_2->imagen->width())
        {
            removeActor(cross_w_2);
//            cross_w_2->movingOFF();
            west->pila2->push(cross_w_2);
            cross_w_2=NULL;
        }
    }

    //north
    if(cross_n_1)
    {
        cross_n_1->logica();
        float y = cross_n_1->position().y();
        float yf = north->posPilas[0]->y();
        if(yf>y)
        {
            removeActor(cross_n_1);
//            cross_n_1->movingOFF();
            north->pila1->push(cross_n_1);
            cross_n_1=NULL;
        }
    }
    if(cross_n_2)
    {
        cross_n_2->logica();
        float y = cross_n_2->position().y();
        float yf = north->posPilas[1]->y();
        if(yf>y)
        {
            removeActor(cross_n_2);
//            cross_n_2->movingOFF();
            north->pila2->push(cross_n_2);
            cross_n_2=NULL;
        }
    }

    //south
    if(cross_s_1)
    {
        cross_s_1->logica();
        float y = cross_s_1->position().y();
        float yf = south->posPilas[0]->y();
        if(yf<y + cross_s_1->imagen->height())
        {
            removeActor(cross_s_1);
//            cross_s_1->movingOFF();
            south->pila1->push(cross_s_1);
            cross_s_1=NULL;
        }
    }
    if(cross_s_2)
    {
        cross_s_2->logica();
        float y = cross_s_2->position().y();
        float yf = south->posPilas[1]->y();
        if(yf<y + cross_s_2->imagen->height())
        {
            removeActor(cross_s_2);
//            cross_s_2->movingOFF();
            south->pila2->push(cross_s_2);
            cross_s_2=NULL;
        }
    }

    if(cross_e_1 || cross_e_2 ||
       cross_w_1 || cross_w_2 ||
       cross_n_1 || cross_n_2 ||
       cross_s_1 || cross_s_2)
    {
        crossing=true;
    }else{
        crossing=false;
    }
}