0
和最近我一直在閱讀一段代碼,我想從中生成.obj網格文件。但它看起來像VBO沒有三角形信息。 這裏是代碼生成VBO網:如何從只有(頂點,法線,顏色,正切)的VBO網格生成網格物體文件?
void buildVBOMesh()
{
const vector<VertexData> &vertexData = m_graph->vertexData();
uint nrVertices = vertexData.size();
VertexBufferObjectAttribs::DATA *attrData = new VertexBufferObjectAttribs::DATA[nrVertices];
for(uint i=0; i<nrVertices; ++i)
{
VertexData d = vertexData[i];
vec3 p = d.position;
vec3 n = d.direction;
vec3 v = d.vParallel;
vec3 t = d.tangent;
float thick = d.thickness;
float lengthFromBeginning = d.lengthFromBegining;
float lengthTotal = d.lengthTotal;
attrData[i].vx = p.x;
attrData[i].vy = p.y;
attrData[i].vz = p.z;
attrData[i].vw = 1.0f;
attrData[i].nx = n.x;
attrData[i].ny = n.y;
attrData[i].nz = n.z;
attrData[i].nw = lengthFromBeginning;
attrData[i].cx = v.x;
attrData[i].cy = v.y;
attrData[i].cz = v.z;
attrData[i].cw = thick;
attrData[i].tx = t.x;
attrData[i].ty = t.y;
attrData[i].tz = t.z;
attrData[i].tw = lengthTotal;
}
delete m_vboMesh;
m_vboMesh = new VertexBufferObjectAttribs();
m_vboMesh->setData(attrData, GL_STATIC_DRAW, nrVertices, GL_LINES);
delete[] attrData;
}
然後,如果我畫網格,它會是一些單點? –