PresenceVoxel::PresenceVoxel(Vec3f minDim, Vec3f maxDim, Vec3i divisions, bool createDL) : Voxel(minDim, maxDim, divisions, false) {
	if(createDL) {
		createDisplayList();
//		constructFloorPoints();
	}

}	
void SceneNode::createDisplayTree()
{
	for(unsigned int i = 0; i < this->descendants.size(); i++)
	{
		this->descendants.at(i)->createDisplayTree();
	}

	if(usesDisplayList)
	{
		createDisplayList();
	}
}
void RenderSVGResourceClipper::drawClipMaskContent(GraphicsContext* context, const FloatRect& targetBoundingBox)
{
    ASSERT(context);

    AffineTransform contentTransformation;
    if (clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
        contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox.y());
        contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetBoundingBox.height());
        context->concatCTM(contentTransformation);
    }

    if (!m_clipContentDisplayList)
        createDisplayList(context, contentTransformation);

    ASSERT(m_clipContentDisplayList);
    context->drawDisplayList(m_clipContentDisplayList.get());
}
void RenderSVGResourceMasker::drawMaskForRenderer(GraphicsContext* context, const FloatRect& targetBoundingBox)
{
    ASSERT(context);

    AffineTransform contentTransformation;
    SVGUnitTypes::SVGUnitType contentUnits = toSVGMaskElement(element())->maskContentUnits()->currentValue()->enumValue();
    if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
        contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox.y());
        contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetBoundingBox.height());
        context->concatCTM(contentTransformation);
    }

    if (!m_maskContentDisplayList)
        createDisplayList(context, contentTransformation);
    ASSERT(m_maskContentDisplayList);
    context->drawDisplayList(m_maskContentDisplayList.get());
}
void getBatchFaceCount(
	// input
	const double *FM, int fNum, const double *VM, int vNum, const double *objCenterV, double maxRadius,
	const double *majorAxisM, const double *lightDirM, int lightNum, int maxHeight, int maxWidth, 
	unsigned int channelModFactor,
	// output
	void *FacePixelCountM)
{
	int i;
	
	GLubyte *imageBuffer = (GLubyte *) mxMalloc(maxHeight * maxWidth * 3);
	GLuint batchList = createDisplayList(FM, fNum, VM, vNum, channelModFactor);

	
	//memset(FacePixelCountM, 0, sizeof(double) * fNum * lightNum);
	
	printf("Facet Number: %d, Vertex Number: %d\nProjecting images: \n", fNum, vNum);
	
	float screenScale;
	
	// make sure that maxHeight always >= maxWidth
	if (maxHeight < maxWidth) {
		int temp = maxHeight;
		maxHeight = maxWidth;
		maxWidth = temp;	
	}
	
	for (i = 0; i < lightNum; i++) {
		
		printf(" %d ", i);
		if (i % 16 == 15) {
			printf("\n");
		}		
		orthoCameraSetup(objCenterV, lightDirM + 3*i, maxRadius, majorAxisM, maxHeight, maxWidth, screenScale);

		drawPatch(batchList, imageBuffer, maxHeight, maxWidth);		
		
		extractFaceCount(imageBuffer, channelModFactor, maxHeight, maxWidth, fNum, i%(32),
			(unsigned int*) FacePixelCountM + i/32 * fNum);
	}
	printf("\n");
	mxFree(imageBuffer);	
		
}
Exemple #6
0
Terrain3D::Terrain3D(Terrain* _pTerrain) : pTerrain(_pTerrain) {
	//calcolo delle normali per il terreno
	xMul = pTerrain->getWidth() / pTerrain->getCols();
	zMul = pTerrain->getLength() / pTerrain->getRows();

	for(int i = 1; i < MAX_X-1; i++)
		for(int j = 1; j < MAX_Z-1; j++) {
			float h = pTerrain->values[i][j];
			Vector v1(1*xMul, pTerrain->values[i+1][j] - h, 0);
			Vector v2(0, pTerrain->values[i][j-1] - h, -1*zMul);
			Vector v3(-1*xMul, pTerrain->values[i-1][j] - h, 0);
			Vector v4(0, pTerrain->values[i][j+1] - h, 1*zMul);
			
			Vector v12 = Vector::crossProd(v1, v2);
			Vector v23 = Vector::crossProd(v2, v3);
			Vector v34 = Vector::crossProd(v3, v4);
			Vector v41 = Vector::crossProd(v4, v1);

			v12.normalize();
			v23.normalize();
			v34.normalize();
			v41.normalize();

			Vector n = Vector(
				v12.coords[0] + v23.coords[0] + v34.coords[0] + v41.coords[0],
				v12.coords[1] + v23.coords[1] + v34.coords[1] + v41.coords[1],
				v12.coords[2] + v23.coords[2] + v34.coords[2] + v41.coords[2]
				);
			n.normalize();
			normals[i][j] = n;
		}

	LightPanel::getInstance()->setGlobalAmbient(A_R, A_G, A_B, A_A);
	FogPanel::getInstance()->enable();
	FogPanel::getInstance()->setDensity(0);
	FogPanel::getInstance()->setColor(1, 1, 1, 1);
	loadTex();
	createDisplayList();
}
Exemple #7
0
//***************************************************************************
int Kwave::SaveBlocksPlugin::start(QStringList &params)
{
    qDebug("SaveBlocksPlugin::start()");

    // interprete the parameters
    int result = interpreteParameters(params);
    if (result) return result;

    QString filename = m_url.path();
    QFileInfo file(filename);
    QString path = file.absolutePath();
    QString ext  = file.suffix();
    QString base = findBase(filename, m_pattern);
    QByteArray sep("/");

    // determine the selection settings
    sample_index_t selection_left  = 0;
    sample_index_t selection_right = 0;
    selection(0, &selection_left, &selection_right, false);

    bool selected_something = (selection_left != selection_right);
    bool selected_all = ((selection_left == 0) &&
                         (selection_right+1 >= signalLength()));
    bool enable_selection_only = selected_something && !selected_all;
    bool selection_only = enable_selection_only && m_selection_only;

    if (selection_only) {
	selection(0, &selection_left, &selection_right, true);
    } else {
	selection_left  = 0;
	selection_right = signalLength() - 1;
    }

    // get the index range
    scanBlocksToSave(base, selection_only);
    unsigned int count = m_block_info.count();
    unsigned int first = firstIndex(path, base, ext, m_pattern,
                                    m_numbering_mode, count);

//     qDebug("m_url            = '%s'", m_url.prettyURL().local8Bit().data());
//     qDebug("m_pattern        = '%s'", m_pattern.local8Bit().data());
//     qDebug("m_numbering_mode = %d", (int)m_numbering_mode);
//     qDebug("selection_only   = %d", selection_only);
//     qDebug("indices          = %u...%u (count=%u)", first, first+count-1,count);

    // iterate over all blocks to check for overwritten files and missing dirs
    QStringList  overwritten_files;
    QStringList  missing_dirs;
    for (unsigned int i = first; i < (first + count); i++) {
	QString name = createFileName(base, ext, m_pattern, i, count,
	                              first + count - 1);
	QString display_name = Kwave::Parser::unescape(name);

	// split the name into directory and file name
	name = QString::fromLatin1(QUrl::toPercentEncoding(display_name, sep));
	QUrl url = m_url.adjusted(QUrl::RemoveFilename);
	url.setPath(url.path(QUrl::FullyEncoded) + name, QUrl::StrictMode);

	QString filename = url.path();
	QFileInfo file_info(filename);

	// check for potentially overwritten file
	if (file_info.exists())
	    overwritten_files += Kwave::Parser::unescape(display_name);

	// check for missing subdirectory
	if (!file_info.dir().exists()) {
	    QFileInfo inf(display_name);
	    QString missing_dir = inf.path();
	    if (!missing_dirs.contains(missing_dir))
		missing_dirs += missing_dir;
	}
    }

    // inform about overwritten files
    if (!overwritten_files.isEmpty()) {
	// ask the user for confirmation if he really wants to overwrite...
	if (Kwave::MessageBox::warningYesNo(parentWidget(),
	    _("<html>") +
	    i18n("This would overwrite the following file(s): %1" \
	    "Do you really want to continue?",
	    createDisplayList(overwritten_files, 5)) +
	    _("</html>") ) != KMessageBox::Yes)
	{
	    return -1;
	}
    }

    // handle missing directories
    if (!missing_dirs.isEmpty()) {
	// ask the user if he wants to continue and create the directory
	if (Kwave::MessageBox::warningContinueCancel(parentWidget(),
	    i18n("The following directories do not exist: %1"
	         "Do you want to create them and continue?",
	         createDisplayList(missing_dirs, 5)),
	    QString(),
	    QString(),
	    QString(),
	    _("saveblocks_create_missing_dirs")
	    ) != KMessageBox::Continue)
	{
	    return -1;
	}

	// create all missing directories
	QUrl base_url = m_url.adjusted(QUrl::RemoveFilename);
	foreach (const QString &missing, missing_dirs) {
	    QUrl url(base_url);
	    url.setPath(
		base_url.path(QUrl::FullyEncoded) +
		QString::fromLatin1(QUrl::toPercentEncoding(missing)),
		QUrl::StrictMode
	    );
	    QString path = url.path();
	    QDir dir;
	    if (!dir.mkpath(path))
		qWarning("creating path '%s' failed", DBG(path));
	}
    }
Exemple #8
0
void Ivy::birth()
{
	//evolve a gaussian filter over the adhesian vectors

	float gaussian[11] = {1.0f, 2.0f, 4.0f, 7.0f, 9.0f, 10.0f, 9.0f, 7.0f, 4.0f, 2.0f, 1.0f };

    for(unsigned int r=0; r < roots.size(); r++)
    {
        for(int g = 0; g <5; ++g)
        {
            IvyRoot root = roots[r];
            for(unsigned int n=0; n < root.nodes.size(); n++)
            {
                Vector3d e;

                for (int i = -5; i <= 5; ++i)
                {
                    Vector3d tmpAdhesion;

                    if ((n + i) < 0)
                        tmpAdhesion = root.nodes.front().adhesionVector;
                    if ((n + i) >= root.nodes.size())
                        tmpAdhesion = root.nodes.back().adhesionVector;
                    if (((n + i) >= 0) && ((n + i) < root.nodes.size()))
                        tmpAdhesion = root.nodes[n + i].adhesionVector;

                    e += tmpAdhesion * gaussian[i+5];
                }

               root.nodes[n].smoothAdhesionVector = e / 56.0f;
            }

            for(unsigned int n=0; n < root.nodes.size(); n++)
            {
                root.nodes[n].adhesionVector = root.nodes[n].smoothAdhesionVector;
            }
        }
    }

//	for (std::vector<IvyRoot>::iterator root = roots.begin(); root != roots.end(); ++root)
//	{
//		for (int g = 0; g < 5; ++g)
//		{
//			for (std::vector<IvyNode>::iterator node = root->nodes.begin(); node != root->nodes.end(); ++node)
//			{
//				Vector3d e;

//				for (int i = -5; i <= 5; ++i)
//				{
//					Vector3d tmpAdhesion;

//                    if ((node + i) < root->nodes.begin())
//                        tmpAdhesion = root->nodes.front().adhesionVector;
//                    if ((node + i) >= root->nodes.end())
//                        tmpAdhesion = root->nodes.back().adhesionVector;
//                    if (((node + i) >= root->nodes.begin()) && ((node + i) < root->nodes.end()))
//                        tmpAdhesion = (node + i)->adhesionVector;

//					e += tmpAdhesion * gaussian[i+5];
//				}

//				node->smoothAdhesionVector = e / 56.0f;
//			}

//            for (std::vector<IvyNode>::iterator node = root->nodes.begin(); node != root->nodes.end(); ++node)
//            {
//                node->adhesionVector = node->smoothAdhesionVector;
//            }
//		}
//	}


	//parameters that depend on the scene object bounding sphere
	float local_ivyLeafSize = Common::mesh.boundingSphereRadius * ivySize * ivyLeafSize;

	float local_ivyBranchSize = Common::mesh.boundingSphereRadius * ivySize * ivyBranchSize;


	//reset existing geometry
	BasicMesh::reset();


	//set data path
    path = "../textures/";


	//create material for leafs
	BasicMaterial tmpMaterial;

	tmpMaterial.id = 1;
	tmpMaterial.name = "leaf_adult";
	tmpMaterial.texFile = "efeu1.png";

	materials.push_back( tmpMaterial );


	//create second material for leafs
	tmpMaterial.id = 2;
	tmpMaterial.name = "leaf_young";
	tmpMaterial.texFile = "efeu0.png";

	materials.push_back( tmpMaterial );


	//create material for branches
	tmpMaterial.id = 3;
	tmpMaterial.name = "branch";
	tmpMaterial.texFile = "efeu_branch.png";

	materials.push_back( tmpMaterial );


	//create leafs
	for (std::vector<IvyRoot>::iterator root = roots.begin(); root != roots.end(); ++root)
	{
		//simple multiplier, just to make it a more dense
		for (int i = 0; i < 10; ++i)
		{
			//srand(i + (root - roots.begin()) * 10);

			for (std::vector<IvyNode>::iterator node = root->nodes.begin(); node != root->nodes.end(); ++node)
			{
				//weight depending on ratio of node length to total length
				float weight = pow(node->length / root->nodes.back().length, 0.7f);

				//test: the probability of leaves on the ground is increased
				float groundIvy = std::max<float>(0.0f, -Vector3d::dotProduct( Vector3d(0.0f, 1.0f, 0.0f), Vector3d::getNormalized(node->adhesionVector) ));
				weight += groundIvy * pow(1.0f - node->length / root->nodes.back().length, 2.0f);

				//random influence
				float probability = rand()/(float)RAND_MAX;

				if (probability * weight > leafProbability)
				{
					//alignment weight depends on the adhesion "strength"
					float alignmentWeight = node->adhesionVector.length();

					//horizontal angle (+ an epsilon vector, otherwise there's a problem at 0� and 90�... mmmh)
					float phi = Vector2d::vectorToPolar( Vector2d::getNormalized( Vector2d(node->adhesionVector.z, node->adhesionVector.x) ) + Vector2d::getEpsilon() ) - PI * 0.5f;

					//vertical angle, trimmed by 0.5
					float theta = Vector3d::getAngle( node->adhesionVector, Vector3d(0.0f, -1.0f, 0.0f) ) * 0.5f;

					//center of leaf quad
					Vector3d center = node->pos + Vector3d::getRandomized() * local_ivyLeafSize;

					//size of leaf
					float sizeWeight = 1.5f - (cos(weight * 2.0f * PI) * 0.5f + 0.5f);


					//random influence
					phi += (rand()/(float)RAND_MAX - 0.5f) * (1.3f - alignmentWeight);

					theta += (rand()/(float)RAND_MAX - 0.5f) * (1.1f - alignmentWeight);



					//create vertices
					BasicVertex tmpVertex;

					tmpVertex.pos = center + Vector3d(-local_ivyLeafSize * sizeWeight, 0.0f, local_ivyLeafSize * sizeWeight);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 0.0f, 1.0f), theta);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 1.0f, 0.0f), phi);
					tmpVertex.pos += Vector3d::getRandomized() * local_ivyLeafSize * sizeWeight * 0.5f;
					vertices.push_back( tmpVertex );

					tmpVertex.pos = center + Vector3d( local_ivyLeafSize * sizeWeight, 0.0f, local_ivyLeafSize * sizeWeight);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 0.0f, 1.0f), theta);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 1.0f, 0.0f), phi);
					tmpVertex.pos += Vector3d::getRandomized() * local_ivyLeafSize * sizeWeight * 0.5f;
					vertices.push_back( tmpVertex );

					tmpVertex.pos = center + Vector3d(-local_ivyLeafSize * sizeWeight, 0.0f, -local_ivyLeafSize * sizeWeight);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 0.0f, 1.0f), theta);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 1.0f, 0.0f), phi);
					tmpVertex.pos += Vector3d::getRandomized() * local_ivyLeafSize * sizeWeight * 0.5f;
					vertices.push_back( tmpVertex );

					tmpVertex.pos = center + Vector3d( local_ivyLeafSize * sizeWeight, 0.0f, -local_ivyLeafSize * sizeWeight);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 0.0f, 1.0f), theta);
					tmpVertex.pos = Vector3d::rotateAroundAxis(tmpVertex.pos, center, Vector3d(0.0f, 1.0f, 0.0f), phi);
					tmpVertex.pos += Vector3d::getRandomized() * local_ivyLeafSize * sizeWeight * 0.5f;
					vertices.push_back( tmpVertex );


					//create texCoords
					BasicTexCoord tmpTexCoord;

					tmpTexCoord.pos = Vector2d( 0.0f, 1.0f);
					texCoords.push_back( tmpTexCoord );

					tmpTexCoord.pos = Vector2d( 1.0f, 1.0f);
					texCoords.push_back( tmpTexCoord );

					tmpTexCoord.pos = Vector2d( 0.0f, 0.0f);
					texCoords.push_back( tmpTexCoord );

					tmpTexCoord.pos = Vector2d( 1.0f, 0.0f);
					texCoords.push_back( tmpTexCoord );


					//create triangle
					BasicTriangle tmpTriangle;

					tmpTriangle.matid = 1;

					float probability = rand()/(float)RAND_MAX;
					if (probability * weight > leafProbability) tmpTriangle.matid = 2;

                    tmpTriangle.v0id = (unsigned int)vertices.size()-1;
                    tmpTriangle.v1id = (unsigned int)vertices.size()-3;
                    tmpTriangle.v2id = (unsigned int)vertices.size()-2;

                    tmpTriangle.t0id = (unsigned int)vertices.size()-1;
                    tmpTriangle.t1id = (unsigned int)vertices.size()-3;
                    tmpTriangle.t2id = (unsigned int)vertices.size()-2;

					triangles.push_back( tmpTriangle );

                    tmpTriangle.v0id = (unsigned int)vertices.size()-2;
                    tmpTriangle.v1id = (unsigned int)vertices.size()-0;
                    tmpTriangle.v2id = (unsigned int)vertices.size()-1;

                    tmpTriangle.t0id = (unsigned int)vertices.size()-2;
                    tmpTriangle.t1id = (unsigned int)vertices.size()-0;
                    tmpTriangle.t2id = (unsigned int)vertices.size()-1;

					triangles.push_back( tmpTriangle );
				}
			}
		}
	}



	//branches
	for (std::vector<IvyRoot>::iterator root = roots.begin(); root != roots.end(); ++root)
	{
		//process only roots with more than one node
		if (root->nodes.size() == 1) continue;


		//branch diameter depends on number of parents
		float local_ivyBranchDiameter = 1.0f / (float)(root->parents + 1) + 1.0f;


        for (std::vector<IvyNode>::iterator node = root->nodes.begin(); node != root->nodes.end()-1; ++node)
		{
			//weight depending on ratio of node length to total length
			float weight = node->length / root->nodes.back().length;


			//create trihedral vertices
			Vector3d up = Vector3d(0.0f, -1.0f, 0.0f);

			Vector3d basis = Vector3d::getNormalized((node + 1)->pos - node->pos);

			Vector3d b0 = Vector3d::getNormalized( Vector3d::crossProduct(up, basis) ) * local_ivyBranchDiameter * local_ivyBranchSize * (1.3f - weight) + node->pos;

			Vector3d b1 = Vector3d::rotateAroundAxis(b0, node->pos, basis, 2.09f);

			Vector3d b2 = Vector3d::rotateAroundAxis(b0, node->pos, basis, 4.18f);


			//create vertices
			BasicVertex tmpVertex;

			tmpVertex.pos = b0;
			vertices.push_back( tmpVertex );

			tmpVertex.pos = b1;
			vertices.push_back( tmpVertex );

			tmpVertex.pos = b2;
			vertices.push_back( tmpVertex );


			//create texCoords
			BasicTexCoord tmpTexCoord;

			float texV = (node - root->nodes.begin()) % 2 == 0 ? 1.0f : 0.0f;

			tmpTexCoord.pos = Vector2d( 0.0f, texV);
			texCoords.push_back( tmpTexCoord );

			tmpTexCoord.pos = Vector2d( 0.3f, texV);
			texCoords.push_back( tmpTexCoord );

			tmpTexCoord.pos = Vector2d( 0.6f, texV);
			texCoords.push_back( tmpTexCoord );


			if (node == root->nodes.begin()) continue;


			//create triangle
			BasicTriangle tmpTriangle;

			tmpTriangle.matid = 3;

            tmpTriangle.v0id = (unsigned int)vertices.size()-3;
            tmpTriangle.v1id = (unsigned int)vertices.size()-0;
            tmpTriangle.v2id = (unsigned int)vertices.size()-4;

            tmpTriangle.t0id = (unsigned int)vertices.size()-3;
            tmpTriangle.t1id = (unsigned int)vertices.size()-0;
            tmpTriangle.t2id = (unsigned int)vertices.size()-4;

			triangles.push_back( tmpTriangle );


            tmpTriangle.v0id = (unsigned int)vertices.size()-4;
            tmpTriangle.v1id = (unsigned int)vertices.size()-0;
            tmpTriangle.v2id = (unsigned int)vertices.size()-1;

            tmpTriangle.t0id = (unsigned int)vertices.size()-4;
            tmpTriangle.t1id = (unsigned int)vertices.size()-0;
            tmpTriangle.t2id = (unsigned int)vertices.size()-1;

			triangles.push_back( tmpTriangle );


            tmpTriangle.v0id = (unsigned int)vertices.size()-4;
            tmpTriangle.v1id = (unsigned int)vertices.size()-1;
            tmpTriangle.v2id = (unsigned int)vertices.size()-5;

            tmpTriangle.t0id = (unsigned int)vertices.size()-4;
            tmpTriangle.t1id = (unsigned int)vertices.size()-1;
            tmpTriangle.t2id = (unsigned int)vertices.size()-5;

			triangles.push_back( tmpTriangle );


            tmpTriangle.v0id = (unsigned int)vertices.size()-5;
            tmpTriangle.v1id = (unsigned int)vertices.size()-1;
            tmpTriangle.v2id = (unsigned int)vertices.size()-2;

            tmpTriangle.t0id = (unsigned int)vertices.size()-5;
            tmpTriangle.t1id = (unsigned int)vertices.size()-1;
            tmpTriangle.t2id = (unsigned int)vertices.size()-2;

			triangles.push_back( tmpTriangle );


            tmpTriangle.v0id = (unsigned int)vertices.size()-5;
            tmpTriangle.v1id = (unsigned int)vertices.size()-2;
            tmpTriangle.v2id = (unsigned int)vertices.size()-0;

            tmpTriangle.t0id = (unsigned int)vertices.size()-5;
            tmpTriangle.t1id = (unsigned int)vertices.size()-2;
            tmpTriangle.t2id = (unsigned int)vertices.size()-0;

			triangles.push_back( tmpTriangle );


            tmpTriangle.v0id = (unsigned int)vertices.size()-5;
            tmpTriangle.v1id = (unsigned int)vertices.size()-0;
            tmpTriangle.v2id = (unsigned int)vertices.size()-3;

            tmpTriangle.t0id = (unsigned int)vertices.size()-5;
            tmpTriangle.t1id = (unsigned int)vertices.size()-0;
            tmpTriangle.t2id = (unsigned int)vertices.size()-3;

			triangles.push_back( tmpTriangle );
		}
	}


	//initialize ivy mesh
	loadTextures();

	prepareData();

	calculateVertexNormals();

	prepareData();

	createDisplayList(true);
}
Exemple #9
0
void Node::draw(map<string, Node*>& grafo, map<string, Aparencia*>& aparencias, string referenciaApp, map<string, Textura*>& texturas, map<string, Animation*> anime){

	if (this->firstTime){
		createDisplayList(grafo, aparencias, referenciaApp, texturas,anime);
		this->firstTime = false;
	}
	else if (this->displayList){
		glPushMatrix();
		glCallList(this->index);
		typedef vector<string>::iterator iter;
		for (iter it = this->getDescendencia().begin(); it != this->getDescendencia().end(); it++){
			glPushMatrix();
			grafo[*it]->draw(grafo, aparencias, this->appRef, texturas,anime);
			glPopMatrix();
		}
		glPopMatrix();
	}
	else if (!this->displayList && this->insideList && this->controlList){
		glPushMatrix();
		
		unsigned int size = this->primitivas.size();
		typedef vector<string>::iterator iter;
		for (iter it = this->getDescendencia().begin(); it != this->getDescendencia().end(); it++){
			glPushMatrix();
			grafo[*it]->draw(grafo, aparencias, this->appRef, texturas,anime);
			glPopMatrix();
		}
		glPopMatrix();
	}
	else {
		glPushMatrix();
		glMultMatrixf(&this->matrix[0]);
		if (this->appRef != "inherit"){
			aparencias[this->appRef]->apply();
		}
		else {
			aparencias[referenciaApp]->apply();
			this->appRef = referenciaApp;
		}

		if (this->animacoes.size() != 0){
			for (int i = 0; i < this->animacoes.size(); i++){ // alterar
				anime[animacoes[i]]->draw();
			}
		}

		unsigned int size = this->primitivas.size();
		for (unsigned int i = 0; i < size; i++){
			if (aparencias[appRef]->getTextRef() != "null"){
				float texS = texturas[aparencias[appRef]->getTextRef()]->getTexLenS();
				float texT = texturas[aparencias[appRef]->getTextRef()]->getTexLenT();
				primitivas[i]->draw(texS, texT);
			}
			else primitivas[i]->draw();
		}
		typedef std::vector<std::string>::iterator iter;
		for (iter it = this->getDescendencia().begin(); it != this->getDescendencia().end(); it++){
			glPushMatrix();
			grafo[*it]->draw(grafo, aparencias, this->appRef, texturas,anime);
			glPopMatrix();
		}
		glPopMatrix();
	}
}