本文整理汇总了C++中Object3D::getNumFaces方法的典型用法代码示例。如果您正苦于以下问题:C++ Object3D::getNumFaces方法的具体用法?C++ Object3D::getNumFaces怎么用?C++ Object3D::getNumFaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object3D
的用法示例。
在下文中一共展示了Object3D::getNumFaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: groupObjectComponents
/**
* Method is used to group object components.
* @param object is source object.
* @param vertices is other object vertices.
* @pram indices is other object indices.
* @param faceStatus1 is face status.
* @param faceStatus2 is face status.
*/
void GeoModifier::groupObjectComponents(Object3D& object, VertexSet& vertices, IntSet& indices, int faceStatus1, int faceStatus2)
{
//for each face..
for(int i = 0; i < object.getNumFaces(); ++i)
{
Face& face = *(object.getFace(i));
if(face.getStatus()==faceStatus1 || face.getStatus()==faceStatus2)
{
VertexPointerSet faceVerts;
faceVerts.add(face.v1);
faceVerts.add(face.v2);
faceVerts.add(face.v3);
for(int j=0;j<faceVerts.length();j++)
{
if(vertices.contains(faceVerts[j]))
indices.push_back(vertices.indexOf(faceVerts[j]));
else
{
indices.push_back(vertices.length());
vertices.AddVertex(*faceVerts[j]);
}
}
}
}
}
示例2: rayTraceClassify
/**
* Method is used to perform ray trace classify of face.
* @param oobject is source object.
*/
void Face::rayTraceClassify(Object3D& object)
{
//creating a ray starting starting at the face baricenter going to the normal direction
Vector p0;
p0.x = (v1->x + v2->x + v3->x)/3.0f;
p0.y = (v1->y + v2->y + v3->y)/3.0f;
p0.z = (v1->z + v2->z + v3->z)/3.0f;
Line ray(getNormal(),p0);
bool success;
float dotProduct, distance;
Vector intersectionPoint;
Face * closestFace = 0;
float closestDistance;
//float TOL = 0.0001f;
do
{
success = true;
closestDistance = 99999.9f;
//for each face from the other solid...
for(int i=0;i<object.getNumFaces();i++)
{
Face & face = *(object.getFace(i));
dotProduct = face.getNormal() * ray.getDirection(); // dot product
bool bIntersectResult = false;
intersectionPoint = ray.computePlaneIntersection(face.getNormal(), face.v1->getPosition(), bIntersectResult);
// Need to return whether was successful.
//if ray intersects the plane...
//if(intersectionPoint!=0)
if(bIntersectResult)
{
distance = ray.computePointToPointDistance(intersectionPoint);
//if ray lies in plane...
if(fabs(distance)<TOL && fabs(dotProduct)<TOL)
{
//disturb the ray in order to not lie into another plane
ray.perturbDirection();
success = false;
break;
}
//if ray starts in plane...
if(fabs(distance)<TOL && fabs(dotProduct)>TOL)
{
//if ray intersects the face...
if(face.hasPoint(intersectionPoint))
{
//faces coincide
closestFace = &face;
closestDistance = 0;
break;
}
}
//if ray intersects plane...
else if(fabs(dotProduct)>TOL && distance>TOL)
{
if(distance<closestDistance)
{
//if ray intersects the face;
if(face.hasPoint(intersectionPoint))
{
//this face is the closest face untill now
closestDistance = distance;
closestFace = &face;
}
}
}
}
}
}while(success==false);
//none face found: outside face
if(closestFace==0)
status = OUTSIDE;
//face found: test dot product
else
{
dotProduct = closestFace->getNormal() * ray.getDirection();
//distance = 0: coplanar faces
if(fabs(closestDistance)<TOL)
{
if(dotProduct>TOL)
status = SAME;
else if(dotProduct<-TOL)
status = OPPOSITE;
}
//dot product > 0 (same direction): inside face
else if(dotProduct>TOL)
status = INSIDE;
//.........这里部分代码省略.........