本文整理汇总了C++中Geometry::addTriangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::addTriangle方法的具体用法?C++ Geometry::addTriangle怎么用?C++ Geometry::addTriangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry::addTriangle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void SGQuad::setup(float w, float h) {
float hw = 0.5f * w;
float hh = 0.5f * h;
vec3f n = vec3f(0,0,1);
Geometry g;
g.init();
g.addVertex(vec3f(-hw, -hh, 0.0f));
g.addVertex(vec3f(hw, -hh, 0.0f));
g.addVertex(vec3f(hw, hh, 0.0f));
g.addVertex(vec3f(-hw, hh, 0.0f));
g.addNormal(n);
g.addNormal(n);
g.addNormal(n);
g.addNormal(n);
g.addTexCoord(vec2f(0, 0));
g.addTexCoord(vec2f(1, 0));
g.addTexCoord(vec2f(1, 1));
g.addTexCoord(vec2f(0, 1));
g.addTriangle(vec3u32(0, 1, 2));
g.addTriangle(vec3u32(2, 3, 0));
SGMesh::setup(g);
if(TheShaderManager::Instance().has("textured")) {
m_spEffect = SmartPtrSGEffect(new TexturedEffect(TheShaderManager::Instance().get("textured")));
}
}
示例2: loadObj
//.........这里部分代码省略.........
// if(vertexUsed[vdata[i]][tempSG] > -1)
// fdata[i] = vertexUsed[vdata[i]][tempSG];
// else
// {
// vertexUsed[vdata[i]][tempSG] = (int)g.vertices.size();
// fdata[i] = g.getVertexSize();
// Geometry::sVertex tv;
// tv.position = tempVertex[vdata[i]];
// //tv.nx = tv.ny = tv.nz = tv.s = tv.t = 0.0f;
// if(vtdata[i]>-1 && !(flags & LOADOBJ_IGNORE_TEXCOORDS))
// {
// assert( vtdata[i] < tempTexCoord.size() );
// tv.texCoord = tempTexCoord[vtdata[i]];
// }
// if(ndata[i]>-1 && !(flags & LOADOBJ_IGNORE_NORMALS))
// {
// assert( ndata[i] < tempNormal.size() );
// tv.normal = tempNormal[ndata[i]];
// }
// g.addVertex(tv);
// }
}
// if its a triangle, just insert.
// However if its a quad, then insert the two triangles forming the quad.
uvec3 t;
t[0] = fdata[0];
t[1] = fdata[1];
t[2] = fdata[2];
g.addTriangle(t);
if(fdata[3] != -1)
{
t[0] = fdata[3];
t[1] = fdata[0];
t[2] = fdata[2];
g.addTriangle(t);
}
}
else if(param == "vt")
{
vec2 tc;
tc.x = toFloat(token.getToken());
tc.y = toFloat(token.getToken());
//tempTexCoord.push_back(tc);
texCoordRemap.push_back( insertUnique(tempTexCoord, tc) );
}
else if(param == "vn")
{
vec3 normal;
normal.x = toFloat(token.getToken());
normal.y = toFloat(token.getToken());
normal.z = toFloat(token.getToken());
//tempNormal.push_back(normal);
normalRemap.push_back( insertUnique(tempNormal, normal) );
}
else if(param == "s")
tempSG = toInt(token.getToken());
else if(param == "g")
{
/*if(first)
first=false;
else
{
g.process();
geomList.push_back(g);
}
for(unsigned int i=0; i<vertexUsed.size(); ++i)
vertexUsed[i].clear();
g.clear();
*/
}
if(file.eof())
break;
}
file.close();
printf("tempVertex.size() = %i \n", (int)tempVertex.size());
printf("tempNormal.size() = %i \n", (int)tempNormal.size());
printf("tempTexCoord.size() = %i \n", (int)tempTexCoord.size());
printf("Reading is done, gonna process \n");
g.process();
geomList.push_back(g);
std::cout<<"done reading "<<filename<<std::endl;
return 0;
}