Ejemplo n.º 1
0
Map::Map(const String &filename, uint16 firstColId) {
	m_filename = filename;
	m_firstColId = firstColId;
	m_valid = false;

	String buffer = String::Read(filename);

	if (buffer != "") {
		xml_document<> doc;
		doc.parse<0>((char *)buffer.ToCString());
		xml_node<> * rootNode = doc.first_node("map");
		
		m_width = String(rootNode->first_attribute("width")->value()).ToInt();
		m_height = atof(rootNode->first_attribute("height")->value());
		m_tileWidth = atof(rootNode->first_attribute("tilewidth")->value());
		m_tileHeight = atof(rootNode->first_attribute("tileheight")->value());

		xml_node<> * tilesetNode = rootNode->first_node("tileset");			//ignoring other tilesets if any, only getting the first one
		int firstGID = String(tilesetNode->first_attribute("firstgid")->value()).ToInt();
		int tileWidth = String(tilesetNode->first_attribute("tilewidth")->value()).ToInt();
		int tileHeight = String(tilesetNode->first_attribute("tileheight")->value()).ToInt();
		int tileOffsetX = 0;
		int tileOffsetY = 0;
		if (tilesetNode->first_node("tileoffset")) {
			tileOffsetX = String(tilesetNode->first_node("tileoffset")->first_attribute("x")->value()).ToInt();
			tileOffsetY = String(tilesetNode->first_node("tileoffset")->first_attribute("y")->value()).ToInt();
		}
		
		xml_node<> * imageNode = tilesetNode->first_node("image");
		m_imageFile = String(imageNode->first_attribute("source")->value()).StripDir();
		int imageWidth = String(imageNode->first_attribute("width")->value()).ToInt();
		int imageHeight = String(imageNode->first_attribute("height")->value()).ToInt();
		//delete imageNode;

		xml_node<> * dataNode = rootNode->first_node("layer")->first_node("data");
		if (!dataNode->first_attribute("encoding")
			&& !dataNode->first_attribute("compression")) {
			xml_node<> * tileNode = dataNode->first_node("tile");
			while (tileNode != NULL) {
				int32 tileId = String(tileNode->first_attribute("gid")->value()).ToInt() - firstGID;
				m_tileIds.Add(tileId);
				tileNode = tileNode->next_sibling("tile");
			}
			String tilesetFile = filename.ExtractDir() + "/" + m_imageFile;
			m_image = ResourceManager::Instance().LoadImage(tilesetFile,
				imageWidth / tileWidth, imageHeight / tileHeight);
			m_image->SetHandle(tileOffsetX, tileOffsetY);

			m_valid = true;
		}
	}
}
Ejemplo n.º 2
0
Archivo: map.cpp Proyecto: kanc/UTAD
Map::Map(const String &filename, uint16 firstColId) {
    valid = false;
    this->filename = filename;
    this->firstColId = firstColId;
    width = height = tileWidth = tileHeight = 0;

    // Analizamos el XML
    String buffer = String::Read(filename);
    xml_document<> doc;
    doc.parse<0>((char*)buffer.ToCString());

    // Obtenemos informacion de cabecera
    xml_node<>* mapNode = doc.first_node("map");
    width = atoi(mapNode->first_attribute("width")->value());
    height = atoi(mapNode->first_attribute("height")->value());
    tileWidth = atoi(mapNode->first_attribute("tilewidth")->value());
    tileHeight = atoi(mapNode->first_attribute("tileheight")->value());

    // Obtenemos informacion del tileset ("source" no esta soportado)
    xml_node<>* tilesetNode = mapNode->first_node("tileset");
    int firstGid = atoi(tilesetNode->first_attribute("firstgid")->value());
    uint16 tilesetTileWidth = atoi(tilesetNode->first_attribute("tilewidth")->value());
    uint16 tilesetTileHeight = atoi(tilesetNode->first_attribute("tileheight")->value());
    int offsetX = 0, offsetY = 0;
    if ( tilesetNode->first_node("tileoffset") ) {
        offsetX = atoi(tilesetNode->first_node("tileoffset")->first_attribute("x")->value());
        offsetY = atoi(tilesetNode->first_node("tileoffset")->first_attribute("y")->value());
    }
    imageFile = String(tilesetNode->first_node("image")->first_attribute("source")->value()).StripDir();
    int imageWidth = atoi(tilesetNode->first_node("image")->first_attribute("width")->value());
    int imageHeight = atoi(tilesetNode->first_node("image")->first_attribute("height")->value());

    // Leemos el primer layer, sin codificacion ni compresion (los demas son ignorados)
    xml_node<>* dataNode = mapNode->first_node("layer")->first_node("data");
    if ( dataNode->first_attribute("encoding") || dataNode->first_attribute("compression") ) return;
    xml_node<>* tileNode = dataNode->first_node("tile");
    while ( tileNode ) {
        tileIds.Add(atoi(tileNode->first_attribute("gid")->value()) - firstGid);
        tileNode = tileNode->next_sibling("tile");
    }

    // Cargamos la imagen
    image = ResourceManager::Instance().LoadImage(filename.ExtractDir() + "/" + imageFile, imageWidth/tilesetTileWidth, imageHeight/tilesetTileHeight);
    image->SetHandle(offsetX, offsetY);

    valid = true;
}
SkeletonSprite::SkeletonSprite(const String& filename) : Sprite(NULL) {
	// Cargamos los datos del XML
	SkeletonData* data = new SkeletonData(filename);

    root = new Bone("world", NULL, 0, 0, 0, 0);

	// Generamos huesos
    for ( uint32 i = 0; i < data->GetBoneDatas().Size(); i++ ) {
		// Obtenemos hueso
        const BoneData& boneData = data->GetBoneDatas()[i];
		
		// Obtenemos padre del hueso
        Bone* parent = root;
        if ( boneData.GetParentName() != "world" )
            parent = root->FindChild(boneData.GetParentName());

		// Obtenemos imagen
        Image* image = ResourceManager::Instance().LoadImage(filename.ExtractDir() + "/" + boneData.GetImageFilename());

		// Creamos hueso
        Bone bone(boneData.GetId(), image, boneData.GetPivotX(), boneData.GetPivotY(), boneData.GetHandleX(), boneData.GetHandleY());

		// Aniadimos frames
        for ( uint32 i = 0; i < boneData.GetFrames().Size(); i++ )
            bone.AddFrame(boneData.GetFrames()[i]);

		// Aniadimos hueso
		parent->AddChild(bone);	
	}

	// Establecemos el rango de la animacion
    const Bone* bone = root->GetChild(0);
	int32 lastframe = 0;
	for ( uint32 index = 0; index < bone->CountFrames(); index++ ) {
        lastframe = max(lastframe, bone->GetFrame(index)->GetId());
	}
	SetFrameRange(0, lastframe);

	// Eliminamos los datos cargados del XML
	delete data;
}
Ejemplo n.º 4
0
Archivo: map.cpp Proyecto: kanc/UTAD
Map::Map(const String &filename, uint16 firstColId) {
	// TAREA: Implementar constructor
	this->filename = filename;
	this->firstColId = firstColId;
	valid = false;

	String file = String::Read(filename);
	xml_document<> xmlparser;
	xmlparser.parse<0>((char *)file.ToCString());

	//guardamos los datos del mapa
	xml_node<>* nodeMap = xmlparser.first_node("map");

	width = atoi(nodeMap->first_attribute("width")->value());
	height = atoi(nodeMap->first_attribute("height")->value());
	tileWidth = atoi(nodeMap->first_attribute("tilewidth")->value());
	tileHeight = atoi(nodeMap->first_attribute("tileheight")->value());

	//guardamos los datos del tileset
	xml_node<>* nodeTileset = nodeMap->first_node("tileset");

	uint16 firstgid = atoi(nodeTileset->first_attribute("firstgid")->value());
	uint16 tWidth = atoi(nodeTileset->first_attribute("tilewidth")->value());
	uint16 tHeight = atoi(nodeTileset->first_attribute("tileheight")->value());
	uint16 offsX,offsY;	
	offsX = offsY = 0;
	//guardamos el offset
	xml_node<>* nodeOffset = nodeTileset->first_node("tileoffset");

	if (nodeOffset)
	{
		offsX = atoi(nodeOffset->first_attribute("x")->value());
		offsY = atoi(nodeOffset->first_attribute("y")->value());
	}

	//guardamos los datos del fichero de imagen
	xml_node<>* nodeImg = nodeTileset->first_node("image");
	this->imageFile = String( (char *)nodeImg->first_attribute("source")->value() );
	uint16 imgWidth = atoi(nodeImg->first_attribute("width")->value());
	uint16 imgHeight = atoi(nodeImg->first_attribute("height")->value());

	//gestionamos solo la primera capa de tiles
	xml_node<>* nodeData = nodeMap->first_node("layer")->first_node("data");

	//comprobamos que no haya codificacion en "data" y en tal caso salimos con valid=false
	xml_attribute<>* eleEnc = nodeData->first_attribute("enconding");
	xml_attribute<>* eleComp = nodeData->first_attribute("compresion");

	if (eleEnc || eleComp)
		return;
	
	//guardamos los tiles
	xml_node<>* nodeTile = nodeData->first_node("tile");

	while (nodeTile)
	{
		//cogemos el id del tile y le restamos el valor firstgid
		int16 tid = atoi(nodeTile->first_attribute("gid")->value());
		tid -= firstgid;

		this->tileIds.Add(tid);

		nodeTile = nodeTile->next_sibling("tile");
	}

	this->imageFile = filename.ExtractDir() + "/" + this->imageFile;

	//el numero de frames lo obtenemos dividiendo el ancho/alto de la imagen por el ancho/alto del tile
	this->image = ResourceManager::Instance().LoadImage(imageFile, imgWidth / tWidth, imgHeight / tHeight );
	this->image->SetHandle(offsX, offsY);

	tileBuffer = new bool[tileWidth * tileHeight];
	collisionMode = Sprite::CollisionMode::COLLISION_RECT;

	valid = true;

}
Ejemplo n.º 5
0
Archivo: map.cpp Proyecto: diboh/CPP
Map::Map(const String &filename, uint16 firstColId) {
	// TAREA: Implementar constructor

	//Guardamos en las variables miembro los valores de filename y firstColId, y fijamos el valor de valid a false.
	this->filename = filename;
	this->firstColId = firstColId;
	valid = false;

	//Otras variables miembro
	width = 0;
	height = 0;
	tileWidth = 0;
	tileHeight = 0;

	//Cargamos en un objeto String el contenido del fichero.Esto lo podemos hacer mediante el método Read de dicha clase.
	String buffer = String::Read(filename);



	//Generamos un objeto del tipo xml_document<>, y llamamos a su método parse<0>
	//pasándole como parámetro el array de chars contenido en el string cargado
	//anteriormente(esto lo hacemos mediante su método ToCString).
	xml_document<> datosXML;
	datosXML.parse<0>((char*)buffer.ToCString());




	//Obtenemos el primer(y único) elemento(en RapidXML se llaman “nodos”) del
	//documento de nombre “map”, mediante el método first_node(“map”), y lo
	//guardamos en una variable de tipo xml_node<>*
	xml_node<>* nodoMap = datosXML.first_node("map");		
	

	//Guardamos los atributos “width”, “height”, “tilewidth” y “tileheight” del elemento en
	//las variables miembro correspondientes.Podemos obtener el valor de un atributo con el
	//método first_attribute(nombre)->value().Como se devuelve como un array de
	//caracteres, podemos convertirlo en un entero con la función atoi.	
	width		= atoi(nodoMap->first_attribute("width")->value());
	height		= atoi(nodoMap->first_attribute("height")->value());
	tileWidth	= atoi(nodoMap->first_attribute("tilewidth")->value());
	tileHeight	= atoi(nodoMap->first_attribute("tileheight")->value());



	//Obtenemos el primer elemento del nodo “map” llamado “tileset”(si hay más de un
	//tileset, ignoraremos el resto) y lo guardamos en una variable de tipo xml_node<>*.
	xml_node<>* nodoTileSet = nodoMap->first_node("tileset");

	
	
	//Obtenemos el valor de los atributos “firstgid”, “tilewidth”, “tileheight” del elemento, y
	//los guardamos en variables de tipo entero.
	int firstgid	= atoi( nodoTileSet->first_attribute("firstgid")->value() );
	int tilewidth	= atoi(nodoTileSet->first_attribute("tilewidth")->value());
	int tileheight	= atoi(nodoTileSet->first_attribute("tileheight")->value());




	//Si el elemento “tileset” contiene un elemento “tileoffset”, guardamos los atributos “x” e
	//“y” de éste en variables locales enteras.
	int tileOffsetX = 0, tileOffsetY = 0;

	if ( nodoTileSet->first_attribute("tileoffset") )
	{
		int tileOffsetX = atoi( nodoTileSet->first_attribute("x")->value() );
		int tileOffsetY = atoi(nodoTileSet->first_attribute("y")->value());
	} 





	//Obtenemos el primer(y único) elemento llamado “image” del tileset, y guardamos sus
	//atributos “source”, “width” y “height” en las variables miembro correspondientes.
	//Hay que tener en cuenta que el atributo “source” se guarda en la variable miembro
	//imageFile sin ruta, cosa que se puede conseguir utilizando el método StripDir de la
	//clase String.
	
	this->imageFile = String( nodoTileSet->first_node("image")->first_attribute("source")->value() ).StripDir();
	int imageWidth = atoi( nodoTileSet->first_node("image")->first_attribute("width")->value() );
	int imageHeight = atoi(nodoTileSet->first_node("image")->first_attribute("height")->value());





	//Obtenemos el primer elemento “layer” del mapa(el resto son ignorados), y de éste el
	//primer(y único) elemento “data”, y lo guardamos en una variable de tipo xml_node<>*.
	xml_node<>* nodoData = nodoMap->first_node("layer")->first_node("data");
	




	//Si el elemento “data” tiene atributos “encoding” o “compression”, salimos del
	//constructor, ya que la carga de mapas codificados o comprimidos no está soportada.
	if ( nodoData->first_attribute("encoding") || nodoData->first_attribute("compression") )
	{
		return;
	}





	//Obtenemos el primer elemento “tile” del elemento “data”, y lo guardamos en una
	//variable de tipo xml_node<>*.
	xml_node<>* nodoTile = nodoData->first_node("tile");





	//Mientras la variable anterior tenga un valor distinto de NULL :
	while ( nodoTile != NULL)
	{
		//Añadimos al vector tileIds el valor del atributo “gid” del tile.Hay que restarle
		//el valor del atributo “firstgid” que habíamos leído anteriormente en el tileset.
		tileIds.Add(atoi(nodoTile->first_attribute("gid")->value()) - firstgid);





		//Obtenemos el siguiente tile mediante el método next_sibling(“tile”) y lo
		//guardamos en la misma variable.
		nodoTile = nodoTile->next_sibling("tile");

	}





	






	//Por último, vamos a cargar la imagen del tileset.Lo haremos de la siguiente forma :
	//Su nombre de fichero debe ser la ruta al fichero.tmx(que podemos obtener con
	//la función ExtractDir de la clase String) concatenada con el nombre de la
	//imagen obtenido en el tileset.
	

	//El número de frames lo obtendremos dividiendo el ancho y alto de la imagen
	//leídos del XML entre el ancho y el alto de tile leídos en el tileset
	//respectivamente.
	
	image = ResourceManager::Instance().LoadImage(filename.ExtractDir() + "/" + imageFile, imageWidth / tilewidth, imageHeight / tileheight);
	
	
	//El handle de la imagen se debe establecer con los valores de los atributos “x” e
	//“y” leídos en el elemento “tileoffset”.
	image->SetHandle(tileOffsetX, tileOffsetY);





	//Antes de terminar, establecemos el valor de la variable miembro valid a true, para
	//indicar que hemos cargado correctamente el mapa.
	valid = true;

}
Ejemplo n.º 6
0
Archivo: mesh.cpp Proyecto: diboh/CPP
Mesh::Mesh(const String& filename)
{	
	//Analizamos JSON
	String content = String::Read( filename );

    rapidjson::Document json;

    if( json.Parse<0>( content.ToCString() ).HasParseError() ) return;

    rapidjson::Value& sub = json[ "submeshes" ];

    for( unsigned int index = 0; index < sub.Size(); index++ )
    {
        String tex = "";

		if ( sub[ index ].HasMember("texture") )
		{
			tex = sub[ index ][ "texture" ].GetString();

			String path = filename.ExtractDir();

			if ( path != "" )
			{
				tex = path + "/" + tex;
			}
		}

		Ptr< Texture > pTex = ResourceManager::Instance()->LoadTexture(tex);
        Ptr< Submesh > pSub = Submesh::Create( pTex );

		if ( sub[index].HasMember("color")		)
		{
			rapidjson::Value& color		= sub[ index ][ "color"		];
			if ( color.Size() != 3 ) return;
			//for (int nColor = 0; nColor < color.Size(); nColor++)
			//{
				float red = float(color[rapidjson::SizeType(0)].GetDouble());
				float green = float(color[rapidjson::SizeType(1)].GetDouble());
				float blue = float(color[rapidjson::SizeType(2)].GetDouble());
				pSub->SetColor(red, green, blue);
			//}
		}



		if ( sub[index].HasMember("shininess")	)
		{
				rapidjson::Value& shininess	= sub[ index ][ "shininess"	];
				pSub->SetShininess(shininess.GetInt());
		}
		
		
		if ( sub[index].HasMember("indices")	)
		{
			rapidjson::Value& indexes   = sub[ index ][ "indices"   ];

			for( unsigned int nIndex = 0; nIndex < indexes.Size(); nIndex += 3 )
			{
				pSub->AddTriangle( indexes[ nIndex ].GetInt(), indexes[ nIndex + 1 ].GetInt(), indexes[ nIndex + 2 ].GetInt() );
			}
		}

		
		Array< Vector3 > vertexPositions;
        if ( sub[index].HasMember("coords")		)
		{
			rapidjson::Value& coords    = sub[ index ][ "coords"    ];

			for( unsigned int nCoords = 0; nCoords < coords.Size(); nCoords += 3 )
			{
				vertexPositions.Add( 
									Vector3(
											static_cast<float>( coords[ nCoords     ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 1 ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 2 ].GetDouble() ) 
											)
								   );
			}
		}


		Array< Vector3 > normalPositions;
        if ( sub[index].HasMember("normals")		)
		{
			rapidjson::Value& coords    = sub[ index ][ "normals"    ];

			for( unsigned int nCoords = 0; nCoords < coords.Size(); nCoords += 3 )
			{
				normalPositions.Add( 
									Vector3(
											static_cast<float>( coords[ nCoords     ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 1 ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 2 ].GetDouble() ) 
											)
								   );
			}
		}

        Array< float > uTextCoords;
		Array< float > vTextCoords;
		if ( sub[index].HasMember("texcoords")	)		
		{
			rapidjson::Value& texCoords = sub[ index ][ "texcoords" ];

			for( unsigned int nTex = 0; nTex < texCoords.Size(); nTex += 2 )
			{
				//uTextCoords.Add( static_cast<float>( texCoords[nTex + 0].GetDouble() );
				//vTextCoords.Add( static_cast<float>( texCoords[nTex + 1].GetDouble() );

				float u = static_cast<float>( texCoords[ nTex     ].GetDouble() ); 
				float v = static_cast<float>( texCoords[ nTex + 1 ].GetDouble() );

				uTextCoords.Add(u);
				vTextCoords.Add(v);

				/*pSub->AddVertex( 
								Vertex( 
										vertexPositions[ nTex / 2 ],
										normalPositions[ nTex / 2 ],
										static_cast<float>( texCoords[ nTex     ].GetDouble() ), 
										static_cast<float>( texCoords[ nTex + 1 ].GetDouble() ) 
									   )
							   );*/
			}
		}

		

		for (unsigned int i = 0; i < vertexPositions.Size(); i++)
		{
			//if ( !uTextCoords[i] ) uTextCoords[i] = 0;
			//if ( !vTextCoords[i] ) uTextCoords[i] = 0;

			//pSub->AddVertex	( Vertex(vertexPositions[i], normalPositions[i], uTextCoords[i], vTextCoords[i]) );
			pSub->AddVertex	( Vertex(vertexPositions[i], normalPositions[i], 0, 0) );
		}
		
        
		//Add to mesh
        AddSubmesh( pSub );
    }
}
Ejemplo n.º 7
0
Map::Map(const String &filename, uint16 firstColId) {
	String mapInfo;
	xml_document<> doc;
	xml_node<>* root;
	String attr;
	xml_node<>* tileSet;
	xml_node<>* tileOffSet;
	xml_node<>* image;
	xml_node<>* data;
	xml_node<>* tile;

	uint32 firstGId, tileWidth, tileHeight,x,y,imageW,imageH;
	x = y = 0;

	// TAREA: Implementar constructor
	this->filename = filename;
	this->firstColId = firstColId;
	this->valid = false;
	mapInfo = String::Read(filename);
	
	doc.parse<0>((char*)mapInfo.ToCString());
	root = doc.first_node("map");
	

	attr=root->first_attribute("width")->value();
	this->width = attr.ToInt();
	attr = root->first_attribute("height")->value();
	this->height = attr.ToInt();
	attr = root->first_attribute("tilewidth")->value();
	this->tileWidth = attr.ToInt();
	attr = root->first_attribute("tileheight")->value();
	this->tileHeight = attr.ToInt();
	
	tileSet = root->first_node("tileset");
	attr = tileSet->first_attribute("firstgid")->value();
	firstGId = attr.ToInt();
	attr = tileSet->first_attribute("tilewidth")->value();
	tileWidth = attr.ToInt();
	attr = tileSet->first_attribute("tileheight")->value();
	tileHeight = attr.ToInt();
	tileOffSet= tileSet->first_node("tileoffset");
	if (tileOffSet) {
		attr = tileOffSet->first_attribute("x")->value();
		x = attr.ToInt();
		attr = tileOffSet->first_attribute("y")->value();
		y = attr.ToInt();
	}
	image= tileSet->first_node("image");
	attr = image->first_attribute("source")->value();
	this->imageFile = attr.StripDir();
	attr = image->first_attribute("height")->value();
	imageH = attr.ToInt();
	attr = image->first_attribute("width")->value();
	imageW = attr.ToInt();

	data = root->first_node("layer")->first_node("data");
	if (data->first_attribute("encoding")) {
		return;
	}
	tile = data->first_node("tile");
	while (tile)
	{
		attr = tile->first_attribute("gid")->value();
		this->tileIds.Add(attr.ToInt() - firstGId);
		tile = tile->next_sibling("tile");
	}
	this->image=ResourceManager::Instance().LoadImage(filename.ExtractDir()+"/"+ this->imageFile, imageW / tileWidth, imageH / tileHeight);
	if (!this->image) {
		return;
	}
	this->image->SetHandle(x, y);
	this->valid = true;
}
Ejemplo n.º 8
0
Map::Map(const String &filename, uint16 firstColId) {
	// TAREA: Implementar constructor
	this->width = this->height = this->tileWidth = this->tileHeight = 0;
	this->valid = false;
	this->filename = filename;
	this->firstColId = firstColId;

	String content = String::Read( filename.ToCString() );
	xml_document<> file;
	file.parse<0>( (char*) content.ToCString() );

	//PRIMER NODO
	xml_node<>* map = file.first_node( "map" );
	this->width = atoi( map->first_attribute( "width" )->value() );
	this->height = atoi( map->first_attribute( "height" )->value() );
	this->tileWidth = atoi( map->first_attribute( "tilewidth" )->value() );
	this->tileHeight = atoi( map->first_attribute( "tileheight" )->value() );

	//TILESET
	xml_node<>* tileSet = map->first_node( "tileset" );
	int firstgid = atoi( tileSet->first_attribute( "firstgid" )->value() );
	int tilesetWidth = atoi( tileSet->first_attribute( "tilewidth" )->value() );
	int tilesetHeight = atoi( tileSet->first_attribute( "tileheight" )->value() ) ;

	//tileoffset
	int offsetX = 0, offsetY = 0;
	xml_node<>* tileoffset = tileSet->first_node( "tileoffset" );
	if( tileoffset )
	{
		offsetX = atoi( tileoffset->first_attribute( "x" )->value() );
		offsetY= atoi( tileoffset->first_attribute( "y" )->value() );
	}

	//IMAGE
	xml_node<>* imageXml = tileSet->first_node( "image" );
	imageFile = String( imageXml->first_attribute( "source" )->value() ).StripDir() ;
	int widthImageTileSet = atoi( imageXml->first_attribute( "width" )->value() );
	int heightImageTileSet = atoi( imageXml->first_attribute( "height" )->value() );

	//LAYER && DATA
	xml_node<>* layer = map->first_node( "layer" );
	xml_node<>* data = layer->first_node( "data" );

	if( data->first_attribute( "encoding" ) || data->first_attribute( "compression" ) )
	{
		return;
	}

	//TILE
	xml_node<>* tile = data->first_node( "tile" );

	while( tile )
	{
		int gid = atoi( tile->first_attribute( "gid" )->value() );
		tileIds.Add( gid - firstgid );
		tile = tile->next_sibling( "tile" );
	}

	String imageRoute = filename.ExtractDir() + "/" + imageFile;
	image = ResourceManager::Instance().LoadImage( imageRoute, widthImageTileSet / tilesetWidth, heightImageTileSet / tilesetHeight );
	image->SetHandle( offsetX, offsetY);

	valid = true;
}