当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectManager::addObject方法代码示例

本文整理汇总了C++中ObjectManager::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectManager::addObject方法的具体用法?C++ ObjectManager::addObject怎么用?C++ ObjectManager::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectManager的用法示例。


在下文中一共展示了ObjectManager::addObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createGame

void taeRuleset::createGame() {
    Game* game = Game::getGame();
    ObjectManager* obm = game->getObjectManager();
    ObjectTypeManager* obtm = game->getObjectTypeManager();

    //Create ship design category
    Category* cat = new Category();
    cat->setName("Ships");
    cat->setDescription("Ship components");
    game->getDesignStore()->addCategory(cat);
    
    //Create properties
    createProperties();

    //Create components
    createComponents();

    //Create resources
    setupResources();

    uint32_t obT_Universe = obtm->getObjectTypeByName("Universe");
    uint32_t obT_Galaxy = obtm->getObjectTypeByName("Galaxy");

    //Create the universe
    IGObject* universe = obm->createNewObject();
    obtm->setupObject(universe, obT_Universe);
    Universe* theUniverse = (Universe*)(universe->getObjectBehaviour());
    theUniverse->setSize(1000000000000ll);
    universe->setName("The Universe");
    theUniverse->setPosition(Vector3d(0ll,0ll,0ll));
    obm->addObject(universe);

    //Create the galaxy
    IGObject* gal = obm->createNewObject();
    obtm->setupObject(gal, obT_Galaxy);
    EmptyObject* galob = (EmptyObject*)(gal->getObjectBehaviour());
    galob->setSize(100000000000ll);
    gal->setName("The Fertile Galaxy");
    galob->setPosition(Vector3d(0ll, -6000ll, 0ll));
    gal->addToParent(universe->getID());
    obm->addObject(gal);

    string path = string(Settings::getSettings()->get("board_path"));
    Logger::getLogger()->debug(path.c_str());
    
    createBoard(path, gal->getID());
    
    Logger::getLogger()->info("TaE created");
}
开发者ID:AfrazHussain,项目名称:tpserver-cpp,代码行数:49,代码来源:tae.cpp

示例2: QDBusAbstractAdaptor

// DeviceInterface
DeviceInterface::DeviceInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent)
    : QDBusAbstractAdaptor(parent)
    , m_mediaPlayer(0)
{
    setPath(path);
    setObjectParent(parent);
    setProperties(properties);
    setName(QStringLiteral("org.bluez.Device1"));

    // Alias needs special handling
    setAlias(properties.value(QStringLiteral("Alias")).toString());

    // Create Input1
    if (properties.contains(QStringLiteral("Input"))) {
        const QVariantMap &inputProps = qdbus_cast<QVariantMap>(properties.value(QStringLiteral("Input")));
        InputInterface *input = new InputInterface(path, inputProps, parent);

        ObjectManager *manager = ObjectManager::self();
        manager->addObject(input);

        QVariantMap props = properties;
        props.remove(QStringLiteral("Input"));
        setProperties(props);
    }
}
开发者ID:KDE,项目名称:bluez-qt,代码行数:26,代码来源:deviceinterface.cpp

示例3: GameObject

Entity::Entity(float x, float y, float sx, float sy, float a, std::string sp)
    : GameObject(x,y,sx,sy,a){
    objectmanagerId = 0;
    texture = 0;
    sprite = sp;
    //ResourceManager *resourceManager = Global::getInstance()->resourceManager;
    //texture = resourceManager->loadTexture(sprite.c_str());
    //Now we need to add ourselves to the object manager

    ObjectManager *objectManager = Global::getInstance()->objectManager;
    objectmanagerId = objectManager->addObject(this);
}
开发者ID:hflw,项目名称:Blackpyre-Engine,代码行数:12,代码来源:Entity.cpp

示例4: connectMediaPlayer

void DeviceInterface::connectMediaPlayer()
{
    const QVariantMap &properties = qdbus_cast<QVariantMap>(Object::property(QStringLiteral("MediaPlayer")));
    const QDBusObjectPath &path = properties.value(QStringLiteral("Path")).value<QDBusObjectPath>();
    QVariantMap props = properties;
    props.remove(QStringLiteral("Path"));

    MediaPlayerObject *mediaPlayerObj = new MediaPlayerObject(path);
    m_mediaPlayer = new MediaPlayerInterface(path, props, mediaPlayerObj);

    ObjectManager *manager = ObjectManager::self();
    manager->addObject(m_mediaPlayer);
    manager->addAutoDeleteObject(mediaPlayerObj);

    m_connectedUuids.append(MediaPlayerUuid);
}
开发者ID:KDE,项目名称:bluez-qt,代码行数:16,代码来源:deviceinterface.cpp

示例5: Keyboard


//.........这里部分代码省略.........
	case 'v':

		dirX = -2;
		dirY = 4;
		dirZ = -2;


		for(int i = 0; i < 4; ++i)
		{
			for(int j= 0; j < 4; ++j)
			{
				for(int k =0; k < 4; ++k)
				{
					frag = CreateFragments(vec3((float)k * 10.0f-10.f, (float)i * 10.0f + 5.0f + 20.0f, (float)j * 10.0f-10.0f), 10.0f);

					++nbObjects;

					//cout << ++countSphere << " - x: " << k* 5.0f << "   y: " << i* 5.0f + 5.0f<< "   z: " << j* 5.0f << endl;

					LO = -3.0f;
					HI = 3.0f;

					r = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));
					g = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

					b = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

					frag->setWireframeMode(false);
					frag->getComponents()->getGravity()->setUseGravity(true);
					frag->getComponents()->getRigidBody()->addRigidBody(RIGID_GENERIC, *frag->getListOfVertices(), *frag->getListOfIndexes(), frag->getCenterOfObject(), true);
					frag->getComponents()->getRigidBody()->setDisplayRigidBody(true);
					frag->getComponents()->getRigidBody()->activateRigidBody(true);
					frag->getComponents()->getGravity()->setBounciness(frag->getMass(), frag->getMass()/5550);
					frag->getComponents()->getGravity()->setResistance(frag->getMass(), frag->getMass() / 1.01f);
					frag->setAlternateFacesAndNormals(true);
					frag->getComponents()->getGravity()->setGravity(9.8f);
					
					switch(j)
					{
					case 0:
						frag->setColor(0.61f, 0.44f, 0.13f, 1.0f);
						break;
					case 1:
						frag->setColor(0.77f, 0.56f, 0.16f, 1.0f);
						break;
					case 2:
						frag->setColor(0.86f, 0.72f, 0.43f, 1.0f);
						break;
					case 3:
						frag->setColor(0.91f, 0.79f, 0.58f, 1.0f);
						break;
					default:
						frag->setColor(r, g, b, 1.0f);
						break;
					}

					LO = 1.0f;
					HI = 2.0f;

					x = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));
					y = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

					z = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

					frag->getComponents()->getGravity()->addForce(vec3(dirX * -x, dirY* - y, dirZ *-z), frag->getVelocity(), 1.0);

					++dirX;
					dirX =(dirX ==0?1:dirX);

					objectManager.addObject(frag);
				}

				dirX = -2;
			}

			++dirY;
			++dirZ;
			dirZ =(dirZ ==0?1:dirZ);
		}
		
		break;
	case 't':

		oldPos = camera.position;

		camera.position = vec3(0.f, 30.f, 1.0f);

		DestructorManager::LaunchDestruction(objectManager, ground, vec3(0.0f, 0.0f, 0.0f), -camera.position, radiusExplosionCircle, depthExplosion, nbPointsCircle, nbPointsCircle);
		
		ground->getComponents()->getRigidBody()->changeIndexesList(*ground->indexesList);
		ground->getComponents()->getRigidBody()->changeVerticesList(*ground->verticesList);
		ground->getComponents()->getRigidBody()->getRigidBodyObjectGeneric()->resetWireframeModeindexes(*ground->listIndexesWireframe);
		
		
		camera.position = oldPos;

		break;
	}

}
开发者ID:bibiGN,项目名称:annualproject,代码行数:101,代码来源:main.cpp

示例6: makeExplosion

void makeExplosion(vec3 positionImpact)
{
	float LO;
	float HI;
	float x; 
	float z; 
	float y;
	float r, g, b;
	Generic_Object* frag;
	vec3 oldPos;

	float dirX;
	float dirY;
	float dirZ;


	oldPos = camera.position;

	camera.position = vec3(0.f, 30.f, 1.0f);

	DestructorManager::LaunchDestruction(objectManager, ground, positionImpact, -camera.position, radiusExplosionCircle, depthExplosion, nbPointsCircle, nbParticlesVoronoi);
		
	ground->getComponents()->getRigidBody()->changeIndexesList(*ground->indexesList);
	ground->getComponents()->getRigidBody()->changeVerticesList(*ground->verticesList);
	ground->getComponents()->getRigidBody()->getRigidBodyObjectGeneric()->resetWireframeModeindexes(*ground->listIndexesWireframe);
		
		
	camera.position = oldPos;

	dirX = -2;
	dirY = 4;
	dirZ = -2;


	for(int i = 0; i < 4; ++i)
	{
		for(int j = 0; j < 4; ++j)
		{
			for(int k = 0; k < 4; ++k)
			{
					
				frag = CreateFragments(positionImpact + vec3((float)k * 10.0f-10.f, (float)i * 10.0f - (depthExplosion/3), (float)j * 10.0f-10.0f), 6.0f);

				++nbObjects;

				LO = -3.0f;
				HI = 3.0f;

				r = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));
				g = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

				b = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

				frag->setWireframeMode(wireframeMode);
				frag->getComponents()->getGravity()->setUseGravity(true);
				frag->getComponents()->getRigidBody()->addRigidBody(RIGID_GENERIC, *frag->getListOfVertices(), *frag->getListOfIndexes(), frag->getCenterOfObject(), true);
				frag->getComponents()->getRigidBody()->setDisplayRigidBody(wireframeRigidBodyMode);
				frag->getComponents()->getRigidBody()->activateRigidBody(true);
				frag->getComponents()->getGravity()->setBounciness(frag->getMass(), frag->getMass()/550);
				frag->getComponents()->getGravity()->setResistance(frag->getMass(), frag->getMass() / 1.01f);
				frag->setAlternateFacesAndNormals(true);
				frag->getComponents()->getGravity()->setGravity(9.8f);

				switch(j)
				{
				case 0:
					frag->setColor(0.61f, 0.44f, 0.13f, 1.0f);
					break;
				case 1:
					frag->setColor(0.77f, 0.56f, 0.16f, 1.0f);
					break;
				case 2:
					frag->setColor(0.86f, 0.72f, 0.43f, 1.0f);
					break;
				case 3:
					frag->setColor(0.91f, 0.79f, 0.58f, 1.0f);
					break;
				default:
					frag->setColor(r, g, b, 1.0f);
					break;
				}
					
				LO = 1.0f;
				HI = 2.0f;

				x = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));
				y = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

				z = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));

				frag->getComponents()->getGravity()->addForce(vec3(dirX * -x, dirY* - (blastPower*y), dirZ *-z), frag->getVelocity(), 1.0);

				++dirX;
				dirX =(dirX ==0?1:dirX);

				objectManager.addObject(frag);
			}

			dirX = -2;
		}
//.........这里部分代码省略.........
开发者ID:bibiGN,项目名称:annualproject,代码行数:101,代码来源:main.cpp

示例7: generateGround

void generateGround()
{
	int numberSudivisionX = 4;
	int numberSudivisionZ = 4;


	vec3 minimalSize(-skyboxSize, 0.f, -skyboxSize);
	vec3 maximalSize(skyboxSize, 0.f, skyboxSize);

	float sizeElementX = (maximalSize.x - minimalSize.x) / numberSudivisionX;
	float sizeElementZ = (maximalSize.z - minimalSize.z) / numberSudivisionZ;
	
	for (int i = 0; i < 1 + numberSudivisionX; ++i)
	{
		for (int j = 0; j < 1 + numberSudivisionZ; ++j)
		{
			ground->verticesList->push_back(vec3(minimalSize.x + sizeElementX * i, 0.f, minimalSize.z + sizeElementZ * j));
		}
	}

	Edge * edge1, * edge2, * edge3;
	for (int i = 0; i < numberSudivisionX; ++i)
	{
		edge1 = new Edge(i * (1 + numberSudivisionZ), (i + 1) * (1 + numberSudivisionZ));
		ground->listEdges->push_back(edge1);
		for (int j = 0; j < numberSudivisionZ; ++j)
		{
			edge2 = new Edge((i + 1) * (1 + numberSudivisionZ) + j, (i + 1) * (1 + numberSudivisionZ) + j + 1);
			ground->listEdges->push_back(edge2);
			edge3 = new Edge((i + 1) * (1 + numberSudivisionZ) + j + 1, i * (1 + numberSudivisionZ) + j);
			ground->listEdges->push_back(edge3);
			ground->listFaces->push_back(new Face(edge1, edge2, edge3));
			edge1 = new Edge((i + 1) * (1 + numberSudivisionZ) + j + 1, i * (1 + numberSudivisionZ) + j + 1);
			ground->listEdges->push_back(edge1);
			switch(i)
			{
			case 0:
				edge2 = new Edge(i * (1 + numberSudivisionZ) + j + 1, i * (1 + numberSudivisionZ) + j);
				ground->listEdges->push_back(edge2);
				break;
			case 1:
				edge2 = ground->listEdges->at(j + ((i - 1) * 3 * numberSudivisionZ + i) + j * 3);
				break;
			default:
				edge2 = ground->listEdges->at(numberSudivisionZ + ((i - 1) * 3 * numberSudivisionZ + i) + j * 3);
				break;
			}
			ground->listFaces->push_back(new Face(edge1, edge2, edge3));
		}
	}

	Face::VerifyFaces(ground->verticesList, ground->listFaces, vec3(0.0f, 1.0f, 0.0f));
	ground->CalculateIndexes();
	objectManager.addObject(ground);

	ground->setWireframeMode(wireframeMode);
	ground->setRenderObject(true);
	ground->setUseTexture(true);
	ground->getComponents()->getRigidBody()->addRigidBody(RIGID_GENERIC, *ground->verticesList, *ground->indexesList, vec3(0.0f, 0.0f, 0.0f),false);
	ground->getComponents()->getRigidBody()->setIsStatic(true);
	ground->getComponents()->getRigidBody()->setSize(2000.0f);
	ground->getComponents()->getRigidBody()->setDisplayRigidBody(wireframeRigidBodyMode);
	ground->getComponents()->getRigidBody()->activateRigidBody(true);
	ground->getComponents()->getRigidBody()->getRigidBodyObjectGeneric()->resetWireframeModeindexes(*ground->listIndexesWireframe);
	ground->setColor(0.84f, 0.79f, 0.69f,1.0f);
}
开发者ID:bibiGN,项目名称:annualproject,代码行数:66,代码来源:main.cpp

示例8: createBoard

void taeRuleset::createBoard(string path, uint32_t galaxy) {
    Game* game = Game::getGame();
    ObjectManager* obm = game->getObjectManager();
    ObjectTypeManager* obtm = game->getObjectTypeManager();
    stack<string> lines;
    string line;
    int row = 0;
    ifstream file (path.c_str());

    //Attempt to read in a custom map
    if (file.is_open())
    {
        while(!file.eof()) {
            getline (file,line);
            lines.push(line);
        }
        if(lines.top().compare("") == 0) {
            lines.pop();
        }
        file.close();
    } else {
        //Build default map
        lines.push(string("....MMMMM.A.M..."));
        lines.push(string(".A..M.......M..A"));
        lines.push(string("...MMA......MM.."));
        lines.push(string("MMMM.........MMM"));
        lines.push(string(".............AMM"));
        lines.push(string("..............M."));
        lines.push(string("MMMM....A...MMM."));
        lines.push(string(".A.MMMM.....M..."));
        lines.push(string("......MMMMMMM.A."));
        lines.push(string(".....A.........."));
        lines.push(string("..........A....."));
    }
    while(!lines.empty()) {
        line = lines.top();
        lines.pop();
        for(int i = 0; i < line.length(); i++) {

            //Create a star system
            IGObject* sys1 = obm->createNewObject();
            obtm->setupObject(sys1, obtm->getObjectTypeByName("Star System"));
            StarSystem* sys1ob = (StarSystem*)(sys1->getObjectBehaviour());
            sys1ob->setSize(60000ll);
            char* name = new char[8];
            sprintf(name, "%d, %d", i, row);
            sys1->setName(name);
            sys1ob->setPosition(Vector3d(1ll + 80000ll*i, 1ll+80000ll*(row+1), 0ll));
            sys1ob->setDestroyed(false);                
            sys1->addToParent(galaxy);
            obm->addObject(sys1);

            //Create a planet
            IGObject *p = obm->createNewObject();
            obtm->setupObject(p, obtm->getObjectTypeByName("Planet"));
            Planet * pob = (Planet*)(p->getObjectBehaviour());
            pob->setSize(2);
            char* planetName = new char[20];
            sprintf(planetName, "Planet %d, %d", i, row);
            p->setName(planetName);
            pob->setPosition(sys1ob->getPosition());
            OrderQueue *planetoq = new OrderQueue();
            planetoq->setObjectId(p->getID());
            planetoq->addOwner(0);
            game->getOrderManager()->addOrderQueue(planetoq);
            OrderQueueObjectParam* oqop = static_cast<OrderQueueObjectParam*>(p->getParameterByType(obpT_Order_Queue));
            oqop->setQueueId(planetoq->getQueueId());
            pob->setDefaultOrderTypes();
            p->addToParent(sys1->getID());
            obm->addObject(p);
            if(line[i] == '.') {
                sys1ob->setInhabitable(true);
            } else if (line[i] == 'M') {
                sys1ob->setInhabitable(false);
                pob->addResource(1,1);
            } else if (line[i] == 'A') {
                sys1ob->setInhabitable(true);
                sys1ob->setRegion(sys1->getID());
                pob->addResource(3,1);
                pob->addResource(5,1);
            }   
        }
        row++;
    } 
}
开发者ID:AfrazHussain,项目名称:tpserver-cpp,代码行数:85,代码来源:tae.cpp

示例9: show

void Entity::show(){
    if(objectmanagerId == 0){
        ObjectManager *objectManager = Global::getInstance()->objectManager;
        objectmanagerId = objectManager->addObject(this);
    }
}
开发者ID:hflw,项目名称:Blackpyre-Engine,代码行数:6,代码来源:Entity.cpp


注:本文中的ObjectManager::addObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。