Exemplo n.º 1
0
ByteBuffer Mesh::_toBuffer() {
    ByteBuffer uuid = ::toBuffer ( getUUID() );
    ByteBuffer name = ::toBuffer ( getName () );

    unsigned long long totalSize = 5 * sizeof ( unsigned int ) +
            get < unsigned int > ( "#Vertices" ) * sizeof ( Vector3d ) +
            get < unsigned int > ( "#TexVertices" ) * sizeof ( Vector2d ) +
            get < unsigned int > ( "#Normals" ) * sizeof ( Vector3d )
            + get < unsigned int > ( "#Faces" ) * sizeof ( Triangle ),
            index = 0;
    ByteBuffer result ( totalSize );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Vertices" ) );
    index = ::toBuffer ( result, index, get < Vector3d* > ( "Vertices" ), get < unsigned int > ( "#Vertices" ) );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#TexVertices" ) );
    index = ::toBuffer ( result, index, get < Vector2d* > ( "TexVertices" ), get < unsigned int > ( "#TexVertices" ) );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Normals" ) );
    index = ::toBuffer ( result, index, get < Vector3d* > ( "Normals" ), get < unsigned int > ( "#Normals" ) );
    /**/
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Faces" ) );
    index = ::toBuffer ( result, index, get < Triangle* > ( "Faces" ), get < unsigned int > ( "#Faces" ) );
    /**/
    index = ::toBuffer ( result, index, getSize < MaterialGroup* > ( "MaterialGroups" ) );
    for ( unsigned int i = 0 ; i < getSize < MaterialGroup* > ( "MaterialGroups" ) ; i ++ ) {
        MaterialGroup* grp = get < MaterialGroup* > ( "MaterialGroups", i );
        ByteBuffer grpBuf = grp->convertToBuffer ();
        result.append(grpBuf);
    }
    return result;
}
void MaterialGroupBase::onCreate(const MaterialGroup *source)
{
    Inherited::onCreate(source);

    if(source != NULL)
    {
        MaterialGroup *pThis = static_cast<MaterialGroup *>(this);

        pThis->setMaterial(source->getMaterial());
    }
}
Exemplo n.º 3
0
Action::ResultE ShadingCallbacks::matGroupRenderEnter(CNodePtr &pNode, 
                                                      Action   *action)
{
    ShadingAction *da  = dynamic_cast<ShadingAction *>(action         );
    MaterialGroup *pMG = dynamic_cast<MaterialGroup *>(pNode.getCPtr());

    if(da != NULL && pMG->getSFMaterial()->getValue() != NullFC)
    {
        da->setMaterial(&(*(pMG->getSFMaterial()->getValue())));
    }

    return Action::Continue;
}
void MaterialGroupBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    MaterialGroup *pThis = static_cast<MaterialGroup *>(this);

    pThis->execSync(static_cast<MaterialGroup *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
Quad::Quad(void) :
    SceneObject()
{
    Mesh *renderable = (Mesh *)RESOURCEMANAGER->createRenderable("Mesh");//new Mesh;
    std::vector<VertexData::Attr> *vertices = new std::vector<vec4>(4);
    std::vector<VertexData::Attr> *textureCoords = new std::vector<vec4>(4);
    std::vector<VertexData::Attr> *normals = new std::vector<vec4>(4);

    for (int i = 0; i < 4; ++i)
        normals->at(i).set(0.0f, 0.0f, 0.0f);

    vertices->at (0).set (-1.0f, -1.0f, -1.0f);
    vertices->at (1).set (1.0f, -1.0f, -1.0f);
    vertices->at (2).set (1.0f, 1.0f, -1.0f);
    vertices->at (3).set (-1.0f, 1.0f, -1.0f);

    textureCoords->at (0).set (0.0f, 0.0f, 0.0f);
    textureCoords->at (1).set (1.0f, 0.0f, 0.0f);
    textureCoords->at (2).set (1.0f, 1.0f, 0.0f);
    textureCoords->at (3).set (0.0f, 1.0f, 0.0f);

    VertexData &vertexData = renderable->getVertexData();

    vertexData.setDataFor (VertexData::getAttribIndex("position"), vertices);
    vertexData.setDataFor (VertexData::getAttribIndex("texCoord0"), textureCoords);
    vertexData.setDataFor (VertexData::getAttribIndex("normal"), normals);

    MaterialGroup *aMaterialGroup = new MaterialGroup();


    std::vector<unsigned int> *indices = new std::vector<unsigned int>(6);

    m_Transform = new SimpleTransform;

    indices->at (0) = 0;
    indices->at (1) = 1;
    indices->at (2) = 3;
    indices->at (3) = 1;
    indices->at (4) = 2;
    indices->at (5) = 3;

//	aMaterialGroup->setMaterialId (0);
    aMaterialGroup->setIndexList (indices);
    aMaterialGroup->setParent (renderable);
    aMaterialGroup->setMaterialName("__Quad");

    renderable->addMaterialGroup (aMaterialGroup);
    setRenderable (renderable);
}
Axis::Axis(void) : Primitive()
	
{
	setDrawingPrimitive(curitiba::render::IRenderer::LINES);
	std::vector<VertexData::Attr> *vertices = new std::vector<vec4>(6);
	std::vector<VertexData::Attr> *normals = new std::vector<vec4>(6);

	// FRONT
	vertices->at (0).set	(-1.0f,  0.0f,  0.0f);
	vertices->at (1).set	( 1.0f,  0.0f,  0.0f);
	vertices->at (2).set	( 0.0f, -1.0f,  0.0f);
	vertices->at (3).set	( 0.0f,  1.0f,  0.0f);
	vertices->at (4).set	( 0.0f,  0.0f, -1.0f);
	vertices->at (5).set	( 0.0f,  0.0f,  1.0f);

	VertexData &vertexData = getVertexData();

	vertexData.setDataFor (VertexData::getAttribIndex("position"), vertices);
	vertexData.setDataFor (VertexData::getAttribIndex("normal"), normals);

	MaterialGroup *aMaterialGroup = new MaterialGroup();
	std::vector<unsigned int> *indices = new std::vector<unsigned int>(2);
	indices->at (0) = 0;		
	indices->at (1) = 1;
	aMaterialGroup->setIndexList (indices);
	aMaterialGroup->setParent (this);
	aMaterialGroup->setMaterialName("__Emission Red");
	addMaterialGroup (aMaterialGroup);

	aMaterialGroup = new MaterialGroup();
	indices = new std::vector<unsigned int>(2);
	indices->at (0) = 2;		
	indices->at (1) = 3;
	aMaterialGroup->setIndexList (indices);
	aMaterialGroup->setParent (this);
	aMaterialGroup->setMaterialName("__Emission Green");
	addMaterialGroup (aMaterialGroup);

	aMaterialGroup = new MaterialGroup();
	indices = new std::vector<unsigned int>(2);
	indices->at (0) = 4;		
	indices->at (1) = 5;
	aMaterialGroup->setIndexList (indices);
	aMaterialGroup->setParent (this);
	aMaterialGroup->setMaterialName("__Emission Blue");
	addMaterialGroup (aMaterialGroup);
}
Exemplo n.º 7
0
unsigned long long Mesh::_fromBuffer ( const ByteBuffer& buffer, unsigned long long index ) {
    unsigned long long lindex = index;
    {
        unsigned int count;
        lindex = ::fromBuffer ( buffer, lindex, count ); set < unsigned int > ( "#Vertices", count );
        Vector3d* tri = new Vector3d [ count ];
        lindex = ::fromBuffer ( buffer, lindex, tri, count ); set < Vector3d* > ( "Vertices", tri );
    }
    {
        unsigned int count;
        lindex = ::fromBuffer ( buffer, lindex, count ); set < unsigned int > ( "#TexVertices", count );
        Vector2d* tri = new Vector2d [ count ];
        lindex = ::fromBuffer ( buffer, lindex, tri, count ); set < Vector2d* > ( "TexVertices", tri );
    }
    {
        unsigned int count;
        lindex = ::fromBuffer ( buffer, lindex, count ); set < unsigned int > ( "#Normals", count );
        Vector3d* tri = new Vector3d [ count ];
        lindex = ::fromBuffer ( buffer, lindex, tri, count ); set < Vector3d* > ( "Normals", tri );
    }
    /**/
    {
        unsigned int count;
        lindex = ::fromBuffer ( buffer, lindex, count ); set < unsigned int > ( "#Faces", count );
        Triangle* tri = new Triangle [ count ];
        lindex = ::fromBuffer ( buffer, lindex, tri, count ); set < Triangle* > ( "Faces", tri );
    }
    /**/
    {
        unsigned int count;
        lindex = ::fromBuffer ( buffer, lindex, count );
        for ( int i = 0 ; i < count ; i ++ ) {
            MaterialGroup* mat = new MaterialGroup;
            lindex = mat->convertFromBuffer ( buffer, lindex );
            add<MaterialGroup*> ( "MaterialGroups", mat );
        }
    }
    return lindex;
}
Exemplo n.º 8
0
void MergeGraphOp::processGroups(Node * const node)
{
    MFUnrecChildNodePtr::const_iterator mfit = node->getMFChildren()->begin();
    MFUnrecChildNodePtr::const_iterator mfen = node->getMFChildren()->end  ();
    std::vector<Node *> toAdd;
    std::vector<Node *> toSub;
    
    for ( ; mfit != mfen; ++mfit )
    {
        bool special=isInExcludeList(*mfit);
        bool leaf=isLeaf(*mfit);
        
        if (isGroup(*mfit))
        {
            if (!leaf && !special)
            {
                MFUnrecChildNodePtr::const_iterator it2 = 
                    (*mfit)->getMFChildren()->begin();
                MFUnrecChildNodePtr::const_iterator en2 = 
                    (*mfit)->getMFChildren()->end  ();
                
                for ( ; it2 != en2; ++it2 )
                {
                    toAdd.push_back(*it2);
                }                
            }
            
            if (!special)
            {
                toSub.push_back(*mfit);
                continue;
            }
            
            if (leaf && special)
            {
                //what to do?
            }
            if (!leaf && special)
            {
                //what to do?
            }
            continue;
        }
        else if ((*mfit)->getCore()->getType().isDerivedFrom( 
                     MaterialGroup::getClassType() ))
        {
            MaterialGroup *mg = 
                dynamic_cast<MaterialGroup *>((*mfit)->getCore());
            
            MFUnrecChildNodePtr::const_iterator it2 = 
                (*mfit)->getMFChildren()->begin();
            MFUnrecChildNodePtr::const_iterator en2 = 
                (*mfit)->getMFChildren()->end  ();
            
            bool empty=true;
            
            for ( ; it2 != en2; ++it2 )
            {
                if (!isInExcludeList(*it2))
                {
                    //check if geometry
                    if ((*it2)->getCore()->getType().isDerivedFrom(
                            Geometry::getClassType()))
                    {
                        if(!isLeaf(*it2))
                        {
                            //hmm...bad tree...
                            empty=false;
                        }
                        else
                        {                                
                            //it is a leaf geometry, so apply the transformation
                            Geometry *geo = 
                                dynamic_cast<Geometry *>((*it2)->getCore());

                            geo->setMaterial(mg->getMaterial());

                            toAdd.push_back(*it2);                            
                        }
                    } 
                    else 
                    {
                        empty=false;
                    }
                } 
                else 
                {
                    empty=false;                
                }
            }
            
            if (empty) 
                toSub.push_back(*mfit);
        }
    }
    
    std::vector<Node *>::const_iterator vit = toAdd.begin();
    std::vector<Node *>::const_iterator ven = toAdd.end  ();
    
    for ( ; vit != ven; ++vit )
    {
        node->addChild(*vit);
    }
    
    vit = toSub.begin();
    ven = toSub.end  ();
    
    for ( ; vit != ven; ++vit )
    {
        node->subChild(*vit);
    }
}
Exemplo n.º 9
0
void 
MaterialSortRenderQueue::addToQueue (SceneObject* aObject,
									 std::map<std::string, MaterialID> &materialMap)
{
	PROFILE ("Queue add");

	int order;
	Material* aMaterial = 0;
	MaterialLibManager *m = NAU->getMaterialLibManager();

	IRenderable &aRenderable = aObject->getRenderable();

	std::vector<MaterialGroup*> vMaterialGroups = aRenderable.getMaterialGroups();
	std::vector<MaterialGroup*>::iterator groupIter;
	groupIter = vMaterialGroups.begin();

	for ( ; groupIter != vMaterialGroups.end(); groupIter++ ) {
		MaterialGroup *aGroup = (*groupIter);
		IndexData &indexData = aGroup->getIndexData();
		{
			PROFILE ("Get material");
			aMaterial = materialMap[aGroup->getMaterialName()].m_MatPtr;
		}
		order = aMaterial->getState()->getPropi(IState::ORDER);
		if ((order >= 0) && (0 != aMaterial) && (true == aMaterial->isEnabled())) {

			if (0 == m_RenderQueue.count (order)){
				m_RenderQueue[order] = new std::map <Material*, std::vector<pair_MatGroup_Transform >* >;
			}
			std::map<Material*, std::vector<pair_MatGroup_Transform >* > *materialMap = m_RenderQueue[order];

			if (0 == materialMap->count (aMaterial)) {
				(*materialMap)[aMaterial] = new std::vector<pair_MatGroup_Transform >;
			}
			std::vector<pair_MatGroup_Transform > *matGroupVec = (*materialMap)[aMaterial];
			matGroupVec->push_back (pair_MatGroup_Transform(aGroup, aObject->_getTransformPtr()));
		}
	}

// ADD BOUNDING BOXES TO QUEUE
#ifdef NAU_RENDER_FLAGS
	if (NAU->getRenderFlag(Nau::BOUNDING_BOX_RENDER_FLAG)) {

		Profile("Enqueue Bounding Boxes");

		groupIter = nau::geometry::BoundingBox::getGeometry()->getMaterialGroups().begin();

		for ( ; groupIter != nau::geometry::BoundingBox::getGeometry()->getMaterialGroups().end(); groupIter++ ) {
			MaterialGroup *aGroup = (*groupIter);;
			Material *aMaterial = MATERIALLIBMANAGER->getMaterial(DEFAULTMATERIALLIBNAME, aGroup->getMaterialName());
			mat4 *trans = &((nau::geometry::BoundingBox *)(aObject->getBoundingVolume()))->getTransform();
			if (0 == m_RenderQueue.count (0)){
					m_RenderQueue[0] = new std::map <Material*, std::vector<pair_MatGroup_Transform >* >;
				}
				std::map<Material*, std::vector<pair_MatGroup_Transform >* > *materialMap = m_RenderQueue[aMaterial->getState()->getPropi(IState::ORDER)];

				if (0 == materialMap->count (aMaterial)) {
					(*materialMap)[aMaterial] = new std::vector<pair_MatGroup_Transform >;
				}
				std::vector<pair_MatGroup_Transform > *matGroupVec = (*materialMap)[aMaterial];
				nau::geometry::BoundingBox *bb = (nau::geometry::BoundingBox *)(aObject->getBoundingVolume());
				matGroupVec->push_back( pair_MatGroup_Transform(aGroup, &(bb->getTransform())));
		}
	}
#endif
}
Exemplo n.º 10
0
void
Font::createSentenceRenderable(IRenderable &renderable, std::string sentence)
{
	assert(mMaterialName != "");

	int aux = sentence.length();
	int size = 0;

	for (int count = 0; count < aux; count++) {
	
		// if char exists in the font definition
		if (mChars.count(sentence[count])) 
			size++;
	}

	assert(size);

	// need to clear previous mesh 
	//Mesh *renderable = (Mesh *)RESOURCEMANAGER->createRenderable("Mesh", sentence, "Sentence");
	//renderable->setDrawingPrimitive(curitiba::render::IRenderer::TRIANGLES);

	std::vector<VertexData::Attr> *vertices = new std::vector<VertexData::Attr>(size*6);
	std::vector<VertexData::Attr> *texCoords = new std::vector<VertexData::Attr>(size*6);
	std::vector<VertexData::Attr> *normals = new std::vector<VertexData::Attr>(size*6);



	int i = 0;
	float hDisp = 0.0f, vDisp = 0.0f;

	for (int count = 0; count < aux; count++) {
	
		// get char at position count
		char c = sentence[count];
		if (c == ' ') {
			if (mFixedSize)
				hDisp += mChars[c].C + mChars[c].A; 
			else
				hDisp += mChars[c].C;	
		}
		// if char exists in the font definition
		else if (mChars.count(c)) {
			vertices->at(6*i  ).set(hDisp, vDisp + mHeight, 0.0f, 1.0f);
			vertices->at(6*i+1).set(hDisp + mChars[c].width, vDisp, 0.0f, 1.0f);
			vertices->at(6*i+2).set(hDisp, vDisp, 0.0f, 1.0f);			
			vertices->at(6*i+3).set(hDisp + mChars[c].width, vDisp, 0.0f, 1.0f);			
			vertices->at(6*i+4).set(hDisp, vDisp + mHeight,0.0f, 1.0f);			
			vertices->at(6*i+5).set(hDisp + mChars[c].width, vDisp + mHeight, 0.0f, 1.0f);		

			normals->at(6*i    ).set(0,0,1);
			normals->at(6*i+1  ).set(0,0,1);
			normals->at(6*i+2  ).set(0,0,1);
			normals->at(6*i+3  ).set(0,0,1);
			normals->at(6*i+4  ).set(0,0,1);
			normals->at(6*i+5  ).set(0,0,1);

			texCoords->at(6*i  ).set(mChars[c].x1, 1-mChars[c].y2, 0.0f, 1.0f);
			texCoords->at(6*i+1).set(mChars[c].x2, 1-mChars[c].y1, 0.0f, 1.0f);
			texCoords->at(6*i+2).set(mChars[c].x1, 1-mChars[c].y1, 0.0f, 1.0f);
			texCoords->at(6*i+3).set(mChars[c].x2, 1-mChars[c].y1, 0.0f, 1.0f);
			texCoords->at(6*i+4).set(mChars[c].x1, 1-mChars[c].y2, 0.0f, 1.0f);
			texCoords->at(6*i+5).set(mChars[c].x2, 1-mChars[c].y2, 0.0f, 1.0f);

			if (mFixedSize)
				hDisp += mChars[c].C + mChars[c].A; 
			else
				hDisp += mChars[c].C;
			i++;
		}
		// newline
		else if (c == '\n') {
			vDisp += mHeight;
			hDisp = 0.0f;
		}
	}

	VertexData &vertexData = renderable.getVertexData();
	vertexData.setDataFor (VertexData::getAttribIndex("position"), vertices);
	vertexData.setDataFor (VertexData::getAttribIndex("normal"), normals);
	vertexData.setDataFor (VertexData::getAttribIndex("texCoord0"), texCoords);

	std::vector<unsigned int> *indices = new std::vector<unsigned int>(size*6);
	for (int j = 0; j < size*6 ; j++)
		indices->push_back(j);

	MaterialGroup* auxMG;

	std::vector<IMaterialGroup *> aMatG = renderable.getMaterialGroups();
	if (aMatG.size()) {
		auxMG = (MaterialGroup *)aMatG[0];
		auxMG->setIndexList (indices);
	}
	else {
		auxMG = new MaterialGroup();
		auxMG->setMaterialName(mMaterialName);
		auxMG->setParent(&renderable);
		auxMG->setIndexList (indices);
		renderable.addMaterialGroup(auxMG);
	}
}
Exemplo n.º 11
0
static Action::ResultE modifyMaterial(Node * const node)
{   
    MaterialGroup *mg = dynamic_cast<MaterialGroup *>(node->getCore());
    
    if(mg == NULL)
        return Action::Continue; 
    
    ChunkMaterial *cmat = dynamic_cast<ChunkMaterial *>(mg->getMaterial());
    
    if(cmat == NULL)
        return Action::Continue; 
    
    TextureObjChunk *texc = 
        dynamic_cast<TextureObjChunk *>(
            cmat->find(TextureObjChunk::getClassType()));
    
    if(texc == NULL)
        return Action::Continue;
    
    MaterialChunk *matc = 
        dynamic_cast<MaterialChunk *>(
            cmat->find(MaterialChunk::getClassType()));

    TextureEnvChunkUnrecPtr texe = 
        dynamic_cast<TextureEnvChunk *>(
            cmat->find(TextureEnvChunk::getClassType()));
    
    if(texe == NULL)
    {
        texe = TextureEnvChunk::create();
        cmat->addChunk(texe);
    }

    if(matc == NULL)
    {
        // no material chunk so we use the replace mode.
        texe->setEnvMode(GL_REPLACE);
        return Action::Continue;
    }
    
    if(matc != NULL)
    {
        Image *img = texc->getImage();

        texe->setEnvMode(GL_MODULATE);

        if(img != NULL && img->getBpp() > 2)
        {
            // for color textures the texture replaces only the diffuse part.
            matc->setDiffuse(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
        }
        
        
        // check for textures with alpha
        if(!matc->isTransparent()         && 
            img                   != NULL &&
            img->getBpp()         ==    4   )
        {
            BlendChunkUnrecPtr blendc = 
                dynamic_cast<BlendChunk *>(
                    cmat->find(BlendChunk::getClassType()));

            if(blendc == NULL)
            {
                blendc = OSG::BlendChunk::create();

                blendc->setSrcFactor (GL_SRC_ALPHA);
                blendc->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
    
                cmat->addChunk(blendc);
            }
        }
    }

    return Action::Continue;
}
void SortLastWindow::collectDrawables(Node * const   node,
                                      DrawableListT &drawables)
{
    Material *mat  = NULL;
    NodeCore *core = node->getCore();

    if(core != NULL)
    {
        // handle material groups
        MaterialGroup *matGrp = dynamic_cast<MaterialGroup *>(core);

        if(matGrp != NULL)
        {
            mat = matGrp->getMaterial();

            // ignore transparent material groups
            if(mat != NULL && mat->isTransparent())
                return;
        }

        // handle geometries
        Geometry *geo = dynamic_cast<Geometry *>(core);

        if(geo != NULL)
        {
            mat = geo->getMaterial();
            // ignore transparent materials

            if(mat == NULL || mat->isTransparent() == false)
            {
                DrawableInfo drawableInfo;

                drawableInfo.node = node;

                // get transformed volume
                node->updateVolume();

                BoxVolume volume;
                node->getWorldVolume(volume);

                // get min,max
                volume.getBounds(drawableInfo.bMin, drawableInfo.bMax);

                // num of indices
                drawableInfo.load = 0;

                GeoIntegralProperty *indicesPtr = 
                    geo->getIndex(Geometry::PositionsIndex);

                if(indicesPtr != NULL)
                    drawableInfo.load = indicesPtr->size();

                // put to list
                drawables.push_back(drawableInfo);
            }
        }

        // handle poxy groups
        ProxyGroup *proxy = dynamic_cast<ProxyGroup *>(core);

        if(proxy != NULL)
        {
            DrawableInfo drawableInfo;

            drawableInfo.node = node;

            // get transformed volume
            node->updateVolume();

            BoxVolume volume;
            node->getWorldVolume(volume);

            // get min,max
            volume.getBounds(drawableInfo.bMin, drawableInfo.bMax);

            // num of indices
            drawableInfo.load = proxy->getIndices();

            // put to list
            drawables.push_back(drawableInfo);
        }
    }
    
    MFUnrecChildNodePtr::const_iterator nI;

    for(  nI  = node->getMFChildren()->begin();
          nI != node->getMFChildren()->end();
        ++nI)
    {
        collectDrawables(*nI, drawables);
    }
}
Camera::Camera (const std::string &name) :
	SceneObject(),

	m_Float4Props(COUNT_FLOAT4PROPERTY),
	m_FloatProps(COUNT_FLOATPROPERTY),
	m_Mat4Props(COUNT_MAT4PROPERTY),

	m_IsDynamic (false),
	m_pViewport (0),
	m_LookAt(false),
	m_LookAtPoint(0.0f, 0.0f, 0.0f),
	m_Spherical((float)M_PI,0.0f),
	m_PositionOffset (0.0f),
	m_IsOrtho (false)
{

	//mFloatAttribs.add(AttribFloat(FOV, 60.0f));
	//mFloatAttribs.add(AttribFloat(NEARP, 1.0f));
	//mFloatAttribs.add(AttribFloat(FARP, 10000.0f));
	//mFloatAttribs.add(AttribFloat(LEFT, -1.0f));
	//mFloatAttribs.add(AttribFloat(RIGHT, 1.0f));
	//mFloatAttribs.add(AttribFloat(TOP, 1.0f));
	//mFloatAttribs.add(AttribFloat(BOTTOM, -1.0f));

	//mVec4Attribs.add(AttribVec4(POSITION, 0.0f, 0.0f, 0.0f, 1.0f));
	//mVec4Attribs.add(AttribVec4(VIEW_VEC, 0.0f, 0.0f, -1.0f, 0.0f));
	//mVec4Attribs.add(AttribVec4(NORMALIZED_VIEW_VEC, 0.0f, 0.0f, -1.0f, 0.0f, true));
	//mVec4Attribs.add(AttribVec4(NORMALIZED_RIGHT_VEC, 1.0f, 0.0f, 0.0f, 0.0f, true));
	//mVec4Attribs.add(AttribVec4(UP_VEC, 0.0f, 1.0f, 0.0f, 0.0f));
	//mVec4Attribs.add(AttribVec4(NORMALIZED_UP_VEC, 0.0f, 1.0f, 0.0f, 0.0f, true));
	//mVec4Attribs.add(AttribVec4(LOOK_AT_POINT, 0.0f, 0.0f, -1.0, 1.0));

	m_Id = 0;
	m_Name = name;
	m_pViewport = CURITIBA->getDefaultViewport();

	m_Float4Props[POSITION].set(0.0f, 0.0f, 0.0f, 1.0f);
	m_Float4Props[VIEW_VEC].set(0.0f, 0.0f, -1.0f, 0.0f);
	m_Float4Props[NORMALIZED_VIEW_VEC].set(0.0f, 0.0f, -1.0f, 0.0f);

	m_Float4Props[NORMALIZED_RIGHT_VEC].set(1.0f, 0.0f, 0.0f, 0.0f);

	m_Float4Props[UP_VEC].set(0.0f, 1.0f, 0.0f, 0.0f);
	m_Float4Props[NORMALIZED_UP_VEC].set(0.0f, 1.0f, 0.0f, 0.0f);

	m_Float4Props[LOOK_AT_POINT].set(0.0f, 0.0f, -1.0f, 1.0f);

	m_FloatProps[FOV] = 60.0f;
	m_FloatProps[TOP] = 1.0f;
	m_FloatProps[BOTTOM] = -1.0f;
	m_FloatProps[LEFT] = -1.0f;
	m_FloatProps[RIGHT] = 1.0f;
	m_FloatProps[NEARP] = 1.0f;
	m_FloatProps[FARP] = 10000.0f;

	buildViewMatrix();
	buildViewMatrixInverse();

	m_StaticCondition = false;

	m_BoundingVolume = new BoundingBox;
	m_Transform = new SimpleTransform;
	setVectorsFromSpherical();

	// Adding a Mesh with the frustum lines
	Mesh *renderable =  (Mesh *)RESOURCEMANAGER->createRenderable("Mesh", m_Name, "Camera");
	renderable->setDrawingPrimitive(curitiba::render::IRenderer::LINES);
	std::vector<VertexData::Attr> *vertices = new std::vector<VertexData::Attr>(8);
	VertexData &vertexData = renderable->getVertexData();
	vertexData.setDataFor (VertexData::getAttribIndex("position"), vertices);

	MaterialGroup *aMaterialGroup = new MaterialGroup;
	
	std::vector<unsigned int> *indices = new std::vector<unsigned int>(16);
	indices->at (0) = Camera::TOP_LEFT_NEAR;		indices->at (1) = Camera::TOP_LEFT_FAR;
	indices->at (2) = Camera::TOP_RIGHT_NEAR;		indices->at (3) = Camera::TOP_RIGHT_FAR;
	indices->at (4) = Camera::BOTTOM_RIGHT_NEAR;	indices->at (5) = Camera::BOTTOM_RIGHT_FAR;
	indices->at (6) = Camera::BOTTOM_LEFT_NEAR;		indices->at (7) = Camera::BOTTOM_LEFT_FAR;

	indices->at (8) = Camera::TOP_LEFT_FAR;			indices->at (9) = Camera::TOP_RIGHT_FAR;
	indices->at (10) = Camera::TOP_RIGHT_FAR;		indices->at (11) = Camera::BOTTOM_RIGHT_FAR;
	indices->at (12) = Camera::BOTTOM_RIGHT_FAR;	indices->at (13) = Camera::BOTTOM_LEFT_FAR;
	indices->at (14) = Camera::BOTTOM_LEFT_FAR;		indices->at (15) = Camera::TOP_LEFT_FAR;

	aMaterialGroup->setIndexList (indices);
	aMaterialGroup->setParent (renderable);
	aMaterialGroup->setMaterialName("__Emission White");

	renderable->addMaterialGroup (aMaterialGroup);
	m_Transform = & m_Mat4Props[VIEW_INVERSE_MATRIX];
	setRenderable (renderable);

	aMaterialGroup = new MaterialGroup;
	indices = new std::vector<unsigned int>(8);
	indices->at (0) = Camera::TOP_LEFT_NEAR;		indices->at (1) = Camera::TOP_RIGHT_NEAR;
	indices->at (2) = Camera::TOP_RIGHT_NEAR;		indices->at (3) = Camera::BOTTOM_RIGHT_NEAR;
	indices->at (4) = Camera::BOTTOM_RIGHT_NEAR;	indices->at (5) = Camera::BOTTOM_LEFT_NEAR;
	indices->at (6) = Camera::BOTTOM_LEFT_NEAR;		indices->at (7) = Camera::TOP_LEFT_NEAR;

	aMaterialGroup->setIndexList (indices);
	aMaterialGroup->setParent (renderable);
	aMaterialGroup->setMaterialName("__Emission Red");

	renderable->addMaterialGroup (aMaterialGroup);
	setRenderable (renderable);

	IScene *s = RENDERMANAGER->createScene(name, "SceneAux");
	s->add(this);

	EVENTMANAGER->addListener("VIEWPORT_CHANGED", this);
}