本文整理汇总了C++中FaceSet::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ FaceSet::Size方法的具体用法?C++ FaceSet::Size怎么用?C++ FaceSet::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FaceSet
的用法示例。
在下文中一共展示了FaceSet::Size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFromFaces
void Box::SetFromFaces(FaceSet& faces) {
if (faces.Size() == 0) return;
// initialize max and min with the first member of the face set
FaceList::iterator itr = faces.begin();
Vector<3,float> max((*itr)->vert[0]);
Vector<3,float> min(max);
// find the boundary values
for (; itr != faces.end(); itr++) {
for (int i=0; i<3; i++) {
Vector<3,float> v = (*itr)->vert[i];
for (int j=0; j<3; j++)
if (v[j] < min[j]) min[j] = v[j];
else if (v[j] > max[j]) max[j] = v[j];
}
}
// set box center
center = (max - min) / 2 + min;
// set corner vector
corner = max - center;
// compute the corners
float x = corner[0];
float y = corner[1];
float z = corner[2];
SetCorner(1,1,1, center+Vector<3,float>( x, y, z));
SetCorner(1,1,0, center+Vector<3,float>( x, y,-z));
SetCorner(1,0,1, center+Vector<3,float>( x,-y, z));
SetCorner(1,0,0, center+Vector<3,float>( x,-y,-z));
SetCorner(0,1,1, center+Vector<3,float>(-x, y, z));
SetCorner(0,1,0, center+Vector<3,float>(-x, y,-z));
SetCorner(0,0,1, center+Vector<3,float>(-x,-y, z));
SetCorner(0,0,0, center+Vector<3,float>(-x,-y,-z));
}
示例2: Process
void Process(const float dt, const float p) {
// Set the path to our resources
ResourceManager::AppendPath("tests/");
// Pointer to model resource.
IModelResourcePtr mod_res;
mod_res = ResourceManager::CreateModel("box.obj");
mod_res->Load();
// Get a pointer to the loaded face set.
FaceSet* fset = mod_res->GetFaceSet();
// Test if the loader has created a face set.
BOOST_CHECK(fset != NULL);
// Test of the number of faces is right
BOOST_CHECK(fset->Size() == 12);
// Check all faces.
int fc = 0;
int faceCount = 0;
FaceList::iterator itr = fset->begin();
for( ; itr!=fset->end(); itr++ ){
FacePtr f = *itr; faceCount++;
Vector<3,float> v0(faceArray[fc],faceArray[fc+1],faceArray[fc+2]); fc += 3;
Vector<3,float> v1(faceArray[fc],faceArray[fc+1],faceArray[fc+2]); fc += 3;
Vector<3,float> v2(faceArray[fc],faceArray[fc+1],faceArray[fc+2]); fc += 3;
BOOST_CHECK( f->vert[0] == v0 && f->vert[1] == v1 && f->vert[2] == v2 );
// Check that face number 6 has no material
if (faceCount == 8)
BOOST_CHECK(f->texr == NULL);
// Check that face number 9 has a material assigned
if (faceCount == 9)
BOOST_CHECK(f->texr != NULL);
}
// Check all normals.
fc = 0;
for( itr = fset->begin(); itr!=fset->end(); itr++ ){
FacePtr f = *itr;
Vector<3,float> n0(normArray[fc],normArray[fc+1],normArray[fc+2]); fc += 3;
Vector<3,float> n1(normArray[fc],normArray[fc+1],normArray[fc+2]); fc += 3;
Vector<3,float> n2(normArray[fc],normArray[fc+1],normArray[fc+2]); fc += 3;
BOOST_CHECK( f->norm[0] == n0 && f->norm[1] == n1 && f->norm[2] == n2 );
}
// Check all texture coordinates.
fc = 0;
for( itr = fset->begin(); itr!=fset->end(); itr++ ){
FacePtr f = *itr;
Vector<2,float> t0(texcArray[fc],texcArray[fc+1]); fc += 2;
Vector<2,float> t1(texcArray[fc],texcArray[fc+1]); fc += 2;
Vector<2,float> t2(texcArray[fc],texcArray[fc+1]); fc += 2;
BOOST_CHECK( f->texc[0] == t0 && f->texc[1] == t1 && f->texc[2] == t2 );
}
// Check all colors coordinates.
fc = 0;
for( itr = fset->begin(); itr!=fset->end(); itr++ ){
FacePtr f = *itr;
Vector<4,float> c0(colrArray[fc],colrArray[fc+1],colrArray[fc+2],colrArray[fc+3]); fc += 4;
Vector<4,float> c1(colrArray[fc],colrArray[fc+1],colrArray[fc+2],colrArray[fc+3]); fc += 4;
Vector<4,float> c2(colrArray[fc],colrArray[fc+1],colrArray[fc+2],colrArray[fc+3]); fc += 4;
BOOST_CHECK( f->colr[0] == c0 && f->colr[1] == c1 && f->colr[2] == c2 );
}
// Check all colors coordinates.
fc = 0;
for( itr = fset->begin(); itr!=fset->end(); itr++ ){
FacePtr f = *itr;
Vector<3,float> hard(hardNormArray[fc],hardNormArray[fc+1],hardNormArray[fc+2]); fc += 3;
BOOST_CHECK( f->hardNorm == hard );
}
GameEngine::Instance().Stop();
}