예제 #1
0
Ogre::String ConfigManager::getFullscreenStr() const
{
  Ogre::String str = cf.getSetting("Fullscreen", "Settings", "false");
  if (str.compare("false") == 0)
    return Ogre::String("No");
  else if (str.compare("true") == 0)
    return Ogre::String("Yes");
  return Ogre::String("No");
}
예제 #2
0
void HealthManager::receive(const HitEvent &event)
{
    std::cout<<"ricevuto"<<std::endl;
    entityx::ptr<entityx::EntityManager> entities = ScreenManager::getPtr()->getCurrentEntities();
    for(auto entity : entities->entities_with_components<Destroyable, Renderable>())
    {
        ptr<Destroyable> points = entity.component<Destroyable>();
        std::string entName = entity.component<Name>()->name;
        Ogre::String name;

        if(entName != "Block"){
            ptr<Children> child = entity.component<Children>();
            name = child->children["body"].component<Renderable>()->sceneNode->getName();
        }else{
            ptr<Renderable> rend = entity.component<Renderable>();
            name = rend->sceneNode->getName();
        }

        std::cout<<"name: "<<name<<std::endl;


        int max = points->maxHealth;

        if(name.compare(event.targetName)==0)
        {
            points->health-=event.points;
            if(points->health<=0)
            {
                MessageManager::getPtr()->emit<ObjectDestroyed>(entity);
                if(entity.valid()){
                    if(entity.component<Name>()->name == "Block")
                    {
                        MapManager::getPtr()->deletePosition(entity.component<Position>()->position);
                        RenderManager::getPtr()->getSceneManager()->destroySceneNode(entity.component<Renderable>()->sceneNode);
                        entity.destroy();
                    }else{
                        entity.assign<Position>(MapManager::getPtr()->getFreePos());
                        entity.assign<Destroyable>(max,max);
                    }
                }
                return;
            }else{
                std::cout<<"punti"<<points->health<<std::endl;
                entity.assign<Destroyable>(points->health,max);
            }
            return;
        }

    }
    return;
}
 bool ConfigurationManager::shouldUseStaticGeometry()
 {
     Ogre::String mode = getSystemConfig()->getSetting( "use_static_geometry" );
     
     if( mode == Ogre::StringUtil::BLANK )
         mode = "auto";
     
     if( mode.compare("yes") == 0 )
     {
         return true;
     }
     else if( mode.compare("no") == 0 )
     {
         return false;
     }        
     else
     {
         // Überprüfen ob der Renderer VertexBuffer unterstützt
         return Ogre::Root::getSingleton().getRenderSystem()
             ->getCapabilities()->hasCapability( Ogre::RSC_VBO );
     }
     
 }
	/// __DATE__ sieht ca. so aus : Nov 08 2005
	long parseDate(char* date)
	{   
		Ogre::String dateStr = Ogre::String(date);
		Ogre::String monthStr = dateStr.substr(0,3);
		int day = Ogre::StringConverter::parseInt( dateStr.substr(4,2) );
		int year = Ogre::StringConverter::parseInt( dateStr.substr(7,4) );
		int month = 0;

		while( month < 12 && monthStr.compare(sMonths[month]) != 0 )
			month++;

		return /* Jahr */		  year * 100000 +
			   /* Monat */	 (month+1) * 1000 + 
			   /* Tag */		   day * 10 + 
			   /* Sub-Version */	 0;	
	}
예제 #5
0
bool SceneLoader::parseNode(TiXmlElement *XMLNode)
{
	TiXmlElement *XMLRotation;
	TiXmlElement *XMLPosition;
	TiXmlElement *XMLEntity;
	TiXmlElement *XMLScale;
	TiXmlElement *XMLProperty;

	Ogre::String  nodeName;
	Ogre::String  meshName;
	Ogre::String  meshFile;
	Ogre::Vector3 vec3Position;
	Ogre::Vector3 vec3Scale;
	Ogre::Quaternion quatRotation;

	Ogre::Entity *ent;


	//Get the name of the node
	nodeName = XMLNode->Attribute("name");
	std::cout << "NodeName: " << nodeName << std::endl;

	//Get the position element;
	XMLPosition = XMLNode->FirstChildElement("position");
	vec3Position.x = Ogre::StringConverter::parseReal(XMLPosition->Attribute("x"));
	vec3Position.y = Ogre::StringConverter::parseReal(XMLPosition->Attribute("y"));
	vec3Position.z = Ogre::StringConverter::parseReal(XMLPosition->Attribute("z"));
	//Debug text
	std::cout << "Position: " << "x: " << XMLPosition->Attribute("x");
	std::cout << " y: " << XMLPosition->Attribute("y");
	std::cout << " z: " << XMLPosition->Attribute("z") << std::endl;

	//Get the rotation
	XMLRotation = XMLNode->FirstChildElement("quaternion");
	quatRotation.x = Ogre::StringConverter::parseReal(XMLRotation->Attribute("x"));
	quatRotation.y = Ogre::StringConverter::parseReal(XMLRotation->Attribute("y"));
	quatRotation.z = Ogre::StringConverter::parseReal(XMLRotation->Attribute("z"));
	quatRotation.w = Ogre::StringConverter::parseReal(XMLRotation->Attribute("w"));
	//Debug text
	std::cout << "Quat: " << "qx: " << XMLRotation->Attribute("x");
	std::cout << "qy: " << XMLRotation->Attribute("y");
	std::cout << "qz: " << XMLRotation->Attribute("z");
	std::cout << "qw: " << XMLRotation->Attribute("w") << std::endl;

	//Get the scale
	XMLScale = XMLNode->FirstChildElement("scale");
	vec3Scale.x = Ogre::StringConverter::parseReal(XMLScale->Attribute("x"));
	vec3Scale.y = Ogre::StringConverter::parseReal(XMLScale->Attribute("y"));
	vec3Scale.z = Ogre::StringConverter::parseReal(XMLScale->Attribute("z")); 
	//Degub text
	std::cout << "Scale: " << "x: " << XMLScale->Attribute("x");
	std::cout << " y: " << XMLScale->Attribute("y");
	std::cout << " z: " << XMLScale->Attribute("z") << std::endl;



	//Get the entity
	XMLEntity = XMLNode->FirstChildElement("entity");
	meshName = XMLEntity->Attribute("name");
	meshFile = XMLEntity->Attribute("meshFile");
	std::cout << "meshname: " << meshName << " meshFile: " << meshFile << std::endl;

	//Create the entity
	ent = mvpSceneMgr->createEntity(meshName,meshFile);
	//if(Ogre::StringConverter::parseBool(XMLEntity->Attribute("castShadows")))
	ent->setCastShadows(false);
	//if(ent->getCastShadows())
	//	std::cout << "ent casts shadows"<< std::endl;
	std::cout << "nodeName + Node";
	Ogre::String str = nodeName;
	str += "Node";
	
	//vec3Position.y = mvpTerrain->getHeightAtWorldPosition(vec3Position);
	//vec3Position.y -= 0.3; //@todo wtf!
	Ogre::SceneNode *node = mvpSceneMgr->getRootSceneNode()->createChildSceneNode(str,vec3Position,quatRotation);
	std::cout << "createChildNode";
	node->scale(vec3Scale);
	std::cout << "scale";
	node->attachObject(ent);

	//Get physicsproperties
	std::vector<Ogre::Vector3> posList;

	TiXmlElement * XMLUserData = XMLNode->FirstChildElement("userData");
	XMLProperty = XMLUserData->FirstChildElement("property");
	bool EntityIsStatic = false;
	int collisionGroup;
	int mass  = 0;
	Ogre::String posString;
	Ogre::Vector3 tempVec(0,0,0);
	Ogre::Real speed;
	double tempDouble;
	while(XMLProperty)
	{
		Ogre::String propName = XMLProperty->Attribute("name");
		if (propName.compare("isStatic") == 0)
			if (Ogre::StringConverter::parseInt(XMLProperty->Attribute("data")) == 1)
				EntityIsStatic = true;

		if (propName.compare("mass") == 0)
			mass = Ogre::StringConverter::parseInt(XMLProperty->Attribute("data"));
					
		if(propName.compare("collisionGroup") == 0)
			collisionGroup = Ogre::StringConverter::parseInt(XMLProperty->Attribute("data"));

		if(propName.compare("position") == 0)
		{
			std::stringstream ost;
			posString = XMLProperty->Attribute("data");
			ost << posString;
			ost >> tempDouble;
			tempVec.x = tempDouble;
			ost >> tempDouble;
			tempVec.y = tempDouble;
			ost >> tempDouble;
			tempVec.z = tempDouble;
			posList.push_back(tempVec);
			ost.clear();
		}

		if(propName.compare("speed") == 0)
			speed = Ogre::StringConverter::parseReal(XMLProperty->Attribute("data"));
		
		XMLProperty = XMLProperty->NextSiblingElement("property");
	}
예제 #6
0
    void Actor::doAttach(
        Actor* actor,
        const Ogre::String& slot, 
        const Ogre::String& childSlot, 
        const Ogre::Vector3& offsetPosition,
        const Ogre::Quaternion& offsetOrientation ) 
    {
        Ogre::Vector3 offsetPositionMod = offsetPosition;
        Ogre::Quaternion offsetOrientationMod = offsetOrientation;

        if( actor == NULL )
            Throw(NullPointerException, 
            "Aktor "+mName+": Der anzufügende Aktor darf nicht NULL sein." );
        if( actor->mParent != NULL )
            Throw(NullPointerException, 
            "Aktor "+mName+": Der Aktor ist bereits an einen anderen Aktor angefügt." );

        // Verschiebung durch den Child-Slot berechnen
        // Ist es ein nicht Standard-Slot && Kontrolliert der Aktor ein Objekt && Ist dieses ein Mesh
        if( childSlot.compare(DEFAULT_SLOT_NAME) != 0 &&
            actor->getControlledObject() != NULL && 
            actor->getControlledObject()->isMeshObject() )
        {
            Entity* ent = dynamic_cast<MeshObject*>(actor->getControlledObject())->getEntity();

            // Braucht ein Skelett
            if( !ent->hasSkeleton() )
                Throw(IllegalArgumentException, 
                "Aktor "+mName+": Das kontrollierte MeshObject des ChildAktor hat kein Skeleton." );

            // Der Slot muss existieren
            try
            {
                Bone* bone = ent->getSkeleton()->getBone( childSlot );

                Vector3 vec = bone->_getDerivedPosition();
                Quaternion quat = bone->_getDerivedOrientation();

                // Durch den Bone ExtraOffset hinzufügen
                offsetOrientationMod = offsetOrientation *  quat;
                offsetPositionMod = ( offsetOrientationMod * (-vec) ) + offsetPosition;
            }
            catch (Ogre::Exception) {
                Throw(IllegalArgumentException, 
                    "Aktor "+mName+": Der geforderte Slot '"+childSlot+"' am ChildAktor existiert nicht." );
            }
        }

        // Das wirkliche Anfügen
        // Ist es ein nicht Standard-Slot && Kontrolliert der Aktor ein Objekt && Ist dieses ein Mesh
        if( slot.compare(DEFAULT_SLOT_NAME) != 0 && 
            getControlledObject() != NULL && 
            getControlledObject()->isMeshObject() )
        {
            if( actor->getControlledObject() == NULL )
                Throw(IllegalArgumentException, 
                "Aktor "+mName+": Der zu befestigende Aktor darf bei SLOTs nicht leer sein." );

            MovableObject* movObj = actor->getControlledObject()->getMovableObject();
            Entity* ent = dynamic_cast<MeshObject*>(getControlledObject())->getEntity();

            // Braucht ein Skelett
            if( !ent->hasSkeleton() )
                Throw(IllegalArgumentException, 
                "Aktor "+mName+": Das kontrollierte MeshObject hat kein Skeleton." );

            // Der Slot muss existieren
            try
            {
                ent->getSkeleton()->getBone( slot );
            }
            catch (Ogre::Exception) {
                Throw(IllegalArgumentException, 
                    "Aktor "+mName+": Der geforderte Slot '"+slot+"' existiert nicht." );
            }

            // Am Bone befestigen
            ent->attachObjectToBone( slot, movObj, offsetOrientationMod, offsetPositionMod );
            // Der Aktor wurde an einem Bone befestigt
            actor->mBone = ent->getSkeleton()->getBone( slot );

            return;
        }
        // Wenn hier kein MeshObjekt dran ist, trotzdem irgendwie zusammenfügen
        else
        {
            actor->placeIntoNode( mSceneNode,  offsetPositionMod, offsetOrientationMod );

            // Der Aktor wurde nicht an einem Bone befestigt
            actor->mBone = 0;
            return;      
        }
    }