示例#1
0
	void Face::draw( bool front ) {
		if( smooth ) 
			glShadeModel( GL_SMOOTH );
		else 
			glShadeModel( GL_FLAT );
		
		if( mtl != NULL ) {
			setCurrentMaterial( mtl );
		}
		
		if( textureHandle != 0 ) {
			glEnable( GL_TEXTURE_2D );
			glBindTexture( GL_TEXTURE_2D, textureHandle );
		} else {
			glDisable( GL_TEXTURE_2D );
		}
		
		glBegin( GL_TRIANGLES ); {
			(front ? pN.glNormal() : (-1 * pN).glNormal());	
			if( textureHandle != 0 ) pT.glTexCoord();
			p.glVertex();
			
			(front ? qN.glNormal() : (-1 * qN).glNormal());		
			if( textureHandle != 0 ) qT.glTexCoord();
			q.glVertex();
			
			(front ? rN.glNormal() : (-1 * rN).glNormal());	
			if( textureHandle != 0 ) rT.glTexCoord();
			r.glVertex();
		}; glEnd();
		
		glDisable( GL_TEXTURE_2D );	
	}
示例#2
0
void updateFile(ObjFile* file, const char* line)
{
    // counts the number of groups, objectes, faces, positions, normals, 
    // texcoords 

    // TODO: trim [line]

    if (line[0] == 'v' && line[1] == ' ')
    {
        addPosition(file, line);
        return;
    }

    if (line[0] == 'v' && line[1] == 'n' && line[2] == ' ')
    {
        addNormal(file, line);
        return;
    }

    if (line[0] == 'v' && line[1] == 't' && line[2] == ' ')
    {
        addTexCoord(file, line);
        return;
    }

    if (line[0] == 'o' && line[1] == ' ')
    {
        addObject(file, line);
        return;
    }

    if (line[0] == 'g' && line[1] == ' ')
    {
        addGroup(file, line);
        return;
    }

    if (line[0] == 'f' && line[1] == ' ')
    {
        addFace(file, line);
        return;
    }

    if (strstr(line, "usemtl") == line) 
    {
        setCurrentMaterial(file, line);
        return;
    }
}
示例#3
0
// Add triangles Fan
GLC_uint GLC_Mesh::addTrianglesFan(GLC_Material* pMaterial, const IndexList& indexList, const int lod, double accuracy)
{
	GLC_uint groupId= setCurrentMaterial(pMaterial, lod, accuracy);
	Q_ASSERT(m_PrimitiveGroups.value(lod)->contains(groupId));
	Q_ASSERT(!indexList.isEmpty());

	GLC_uint id= 0;
	if (0 == lod)
	{
		id= m_NextPrimitiveLocalId++;
	}
	m_MeshData.trianglesAdded(lod, indexList.size() - 2);
	m_PrimitiveGroups.value(lod)->value(groupId)->addTrianglesFan(indexList, id);

	// Invalid the geometry
	m_GeometryIsValid = false;

	return id;
}