本文整理汇总了C++中Geometry::addVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::addVertex方法的具体用法?C++ Geometry::addVertex怎么用?C++ Geometry::addVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry::addVertex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createGeom
void Path::createGeom(Geometry& geom) {
// clear geom from previous data
geom.clear();
// add vertices to the geom
for (sf::Vector2f& p: points) {
geom.addVertex(p);
}
// triangulate polygon (only with no holes)
std::vector<sf::Vector2f> triangles;
Triangulate::Process(points, triangles);
for (int i = 0; i != triangles.size(); i += 3) {
geom.addFace(triangles[i], triangles[i + 1], triangles[i + 2]);
}
}
示例3: loadObj
bool loadObj( std::vector<Geometry> &geomList, const std::string &filename, float scale, int flags)
{
std::ifstream file;
file.open(filename.c_str(), std::ios::in);
std::cout<<"loading "<<filename<<std::endl;
if(file.fail())
{
std::cout<<"loadObj failed, could not read "<<std::endl;
return 1;
}
VertexBank vb;
Geometry g;
std::string line,param;
std::vector<vec3> tempVertex;
std::vector<vec3> tempNormal;
std::vector<vec2> tempTexCoord;
tempVertex.reserve(10000);
tempNormal.reserve(10000);
tempTexCoord.reserve(10000);
std::vector<std::vector<int> > vertexUsed;
std::vector<int> texCoordUsed;
int tempSG = 0;
std::vector<size_t> vertexRemap;
std::vector<size_t> normalRemap;
std::vector<size_t> texCoordRemap;
std::vector<int> resetVector;
resetVector.resize(1,-1);
std::string tempName;
while( !file.eof() && file.good() )
{
std::getline(file,line);
#ifdef DEBUG
std::cout<<line<<"\n";
#endif
Tokenizer token(line);
param = token.getToken();
if(param == "v")
{
vec3 vertex;
vertex.x = scale*toFloat(token.getToken());
vertex.y = scale*toFloat(token.getToken());
vertex.z = scale*toFloat(token.getToken());
//tempVertex.push_back(vertex);
//vertexUsed.push_back(resetVector);
vertexRemap.push_back( insertUnique(tempVertex, vertex) );
}
else if(param == "f")
{
ivec4 vdata(-1), tdata(-1), ndata(-1), fdata(-1);
for(int i=0; i<(int)token.size()-1; ++i)
{
param = token.getToken();
getIndices(param, vdata[i], tdata[i], ndata[i],
hasVertex,
hasTexCoord && !(flags & LOADOBJ_IGNORE_TEXCOORDS),
hasNormal && !(flags & LOADOBJ_IGNORE_NORMALS) );
int remappedV = (vdata[i] > -1) ? vdata[i] : -1;
int remappedN = (ndata[i] > -1) ? ndata[i] : -1;
int remappedT = (tdata[i] > -1) ? tdata[i] : -1;
int index;
//printf("Checking vertex uniqueness \n");
if(vb.isUnique(remappedV, remappedN, remappedT, index))
{
index = g.getVertexSize();
Geometry::sVertex tv;
assert( remappedV < (int)tempVertex.size() );
tv.position = tempVertex[ remappedV ];
if(remappedT > -1)
{
assert( remappedT < (int)tempTexCoord.size() );
tv.texCoord = tempTexCoord[ remappedT ];
}
if(remappedN > -1)
{
assert( remappedN < (int)tempNormal.size() );
tv.normal = tempNormal[ remappedN ];
}
g.addVertex(tv);
//.........这里部分代码省略.........