Exemplo n.º 1
0
//--------------------------------------------------------------
void ofVboMesh::update(){	
	if(meshElement->haveVertsChanged()){
		setupVertices(drawType);
		//vbo.updateVertexData(meshElement->getVerticesPointer(), meshElement->getNumVertices());
	}
	
	if(meshElement->haveColorsChanged()){
		setupColors(drawType);
		//vbo.updateColorData(meshElement->getColorsPointer(), meshElement->getNumColors());
	}
	
	if(meshElement->haveNormalsChanged()){
		setupNormals(drawType);
		//vbo.updateNormalData(meshElement->getNormalsPointer(), meshElement->getNumNormals());
	}
	
	if(meshElement->haveTexCoordsChanged()){
		setupTexCoords(drawType);
		//vbo.updateTexCoordData(meshElement->getTexCoordsPointer(), meshElement->getNumTexCoords());
	}	
	
	if(meshElement->haveIndicesChanged() && bUseIndices){
		setupIndices(drawType);
		//vbo.setIndexData(meshElement->getIndexPointer(),meshElement->getNumIndices());
		//vbo.updateIndexData(meshElement->getIndexPointer(),meshElement->getNumIndices());
	}
}
Exemplo n.º 2
0
 DebugPath::DebugPath( SBMath::vec3& startPosition, SBMath::vec3& endPosition, float timeToDie )
     :   m_startPos( startPosition )
     ,   m_endPos( endPosition )
 {
     m_timeToDie = timeToDie;
     m_currentSimTime = 0.0;
     setupVertices();
 }
Exemplo n.º 3
0
void createGraph5(Graph* g)
{
	int i, j;
	srand(9875);

	g->numVertices = 20;
	setupVertices(g);

	g->numEdges = 400;
	for(i = 0; i < g->numVertices; ++i)
		for(j = i + 1; j < g->numVertices; ++j)
			setupEdge(g, &g->vertexSet[i], &g->vertexSet[j]);
}
Exemplo n.º 4
0
bool ATOM_TerrainPatch::initialize (ATOM_TerrainQuadtree *quadtree, ATOM_TerrainPatch *parent, PatchPosition position, ATOM_VertexArray *baseVertices)
{
	ATOM_STACK_TRACE(ATOM_TerrainPatch::initialize);

	ATOM_ASSERT(quadtree);

	unsigned patchSize = quadtree->getPatchSize ();
	unsigned rootSize = quadtree->getRootSize ();
	float scaleX = quadtree->getScaleX ();
	float scaleZ = quadtree->getScaleZ ();

	_mipLevel = parent ? parent->getMipLevel() + 1 : 0;
	unsigned step = ((rootSize - 1) / (patchSize - 1)) >> _mipLevel;
	unsigned interval = (patchSize - 1) * step;
	unsigned parentOffsetX = parent ? parent->getOffsetX() : 0;
	unsigned parentOffsetZ = parent ? parent->getOffsetZ() : 0;

	switch (position)
	{
	case ATOM_TerrainPatch::LeftTop:
		_offsetX = parentOffsetX;
		_offsetZ = parentOffsetZ;
		break;
	case ATOM_TerrainPatch::RightTop:
		_offsetX = parentOffsetX + interval;
		_offsetZ = parentOffsetZ;
		break;
	case ATOM_TerrainPatch::LeftBottom:
		_offsetX = parentOffsetX;
		_offsetZ = parentOffsetZ + interval;
		break;
	case ATOM_TerrainPatch::RightBottom:
		_offsetX = parentOffsetX + interval;
		_offsetZ = parentOffsetZ + interval;
		break;
	default:
		return false;
	}

	_position = position;
	_quadtree = quadtree;
	_step = step;
	_parent = parent;
	_maxError = computeMaxError ();

	setupVertices (computeSkirtLength (), baseVertices);
	_boxRadius = computeBoundingBox (_boundingBox);

	return true;
}
    //-----------------------------------------------------------------------
    RenderOperation InstanceBatch::build( const SubMesh* baseSubMesh )
    {
        if( checkSubMeshCompatibility( baseSubMesh ) )
        {
            //Only triangle list at the moment
            mRenderOperation.operationType  = RenderOperation::OT_TRIANGLE_LIST;
            mRenderOperation.srcRenderable  = this;
            mRenderOperation.useIndexes = true;
            setupVertices( baseSubMesh );
            setupIndices( baseSubMesh );

            createAllInstancedEntities();
        }

        return mRenderOperation;
    }
Exemplo n.º 6
0
void createGraph1(Graph* g)
{
	Vertex* firstVert;
	Vertex* secondVert;
	int i;
	srand(3);

	g->numVertices = 3;
	setupVertices(g);

	g->numEdges = 3;
	for(i = 0; i < g->numEdges; ++i)
	{
		firstVert = &g->vertexSet[i];
		secondVert = &g->vertexSet[(i+1) % g->numVertices];
		setupEdge(g, firstVert, secondVert);
	}
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void ofVboMesh::draw(polyMode pMode){
	if(!vbo.getIsAllocated()){
		setupVertices(drawType);
	}

	if(meshElement->getNumColors() && !vbo.getUsingColors()){
		setupColors(drawType);
	}
	
	if(meshElement->getNumNormals() && !vbo.getUsingNormals()){
		setupNormals(drawType);
	}
	
	if(meshElement->getNumTexCoords() && !vbo.getUsingTexCoords()){
		setupTexCoords(drawType);
	}
	
	if(!meshElement->getNumIndices()){
		meshElement->setupIndices();
	}
	
	update();
	
	glPushAttrib(GL_POLYGON_BIT);
	glPolygonMode(GL_FRONT_AND_BACK, pMode);
	
	GLuint mode = ofGetGLTriangleMode(meshElement->getMode());
	
	if(pMode!=OF_MESH_POINTS){
		if(bUseIndices){
			cout << meshElement->getNumIndices() << endl;
			vbo.drawElements(mode,meshElement->getNumIndices());
		}else{
			vbo.draw(mode,0,meshElement->getNumVertices());
		}
	}else{
		//no indices needed for just drawing verts as points
		vbo.draw(GL_POINTS,0,meshElement->getNumVertices());
	}
	
	glPopAttrib();
}
Exemplo n.º 8
0
void createGraph4(Graph* g)
{
	Vertex* firstVert;
	Vertex* secondVert;
	int i;
	srand(9875);

	g->numVertices = 26;
	setupVertices(g);

	g->numEdges = 100;
	for(i = 0; i < g->numEdges; ++i)
	{
		firstVert = &g->vertexSet[rand() % g->numVertices];
		secondVert = firstVert;
		while(firstVert == secondVert || isAdjacent(firstVert, secondVert))
			secondVert = &g->vertexSet[rand() % g->numVertices];

		setupEdge(g, firstVert, secondVert);
	}
}