Пример #1
0
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");
}
Пример #2
0
// 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);
    }
}
Пример #3
0
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);
}
Пример #4
0
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);
}
Пример #5
0
void Keyboard(unsigned char key, int mx, int my)
{
	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;
	
	float moveSpeed = 10.0f;

	switch(key)
	{
	case 'z':
		camera.position += camera.target * moveSpeed;
		break;
	case 's':
		camera.position -= camera.target * moveSpeed;
		break;
	case 'q':
		camera.position += camera.orientation.Cross(camera.target).Normalized() * moveSpeed;
		break;
	case 'd':
		camera.position -= camera.orientation.Cross(camera.target).Normalized() * moveSpeed;
		break;
	case 'w':
		clearScene = true;
		break;
	case 'x':
		wireframeMode = (wireframeMode?false:true);

		objectManager.setWireframeMode(wireframeMode);
		break;
	case 'y':
		makeExplosion(vec3(0.0f, 0.0f, 0.0f));
		break;
	case 'u':
		makeExplosion(vec3(750.0f, 0.0f, 750.0f));
		break;
	case 'i':
		makeExplosion(vec3(-750.0f, 0.0f, 750.0f));
		break;
	case 'o':
		makeExplosion(vec3(-750.0f, 0.0f, -750.0f));
		break;
	case 'p':
		makeExplosion(vec3(750.0f, 0.0f, -750.0f));
		break;
	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;
	}

}
Пример #6
0
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;
		}

		++dirY;
		++dirZ;
		dirZ =(dirZ ==0?1:dirZ);
	}
}
Пример #7
0
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);
}
Пример #8
0
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++;
    } 
}
Пример #9
0
void Entity::show(){
    if(objectmanagerId == 0){
        ObjectManager *objectManager = Global::getInstance()->objectManager;
        objectmanagerId = objectManager->addObject(this);
    }
}