本文整理汇总了C++中ConvexBody类的典型用法代码示例。如果您正苦于以下问题:C++ ConvexBody类的具体用法?C++ ConvexBody怎么用?C++ ConvexBody使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConvexBody类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateLVS
//-----------------------------------------------------------------------
void FocusedShadowCameraSetup::calculateLVS(const SceneManager& sm, const Camera& cam,
const Light& light, const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const
{
ConvexBody bodyLVS;
// init body with view frustum
bodyLVS.define(cam);
// clip the body with the light frustum (point + spot)
// for a directional light the space of the intersected
// view frustum and sceneBB is always lighted and in front
// of the viewer.
if (light.getType() != Light::LT_DIRECTIONAL)
{
// clip with the light frustum
// set up light camera to clip the resulting frustum
if (!mLightFrustumCameraCalculated)
{
calculateShadowMappingMatrix(sm, cam, light, NULL, NULL, mLightFrustumCamera);
mLightFrustumCameraCalculated = true;
}
bodyLVS.clip(*mLightFrustumCamera);
}
// clip the body with the scene bounding box
bodyLVS.clip(sceneBB);
// extract bodyLVS vertices
out_LVS->build(bodyLVS);
}
示例2: allocatePolygon
//-----------------------------------------------------------------------
ConvexBody::ConvexBody( const ConvexBody& cpy )
{
for ( size_t i = 0; i < cpy.getPolygonCount(); ++i )
{
Polygon *p = allocatePolygon();
*p = cpy.getPolygon( i );
mPolygons.push_back( p );
}
}
示例3: getPolygonCount
//-----------------------------------------------------------------------
bool ConvexBody::operator == ( const ConvexBody& rhs ) const
{
if ( getPolygonCount() != rhs.getPolygonCount() )
return false;
// Compare the polygons. They may not be in correct order.
// A correct convex body does not have identical polygons in its body.
bool *bChecked = OGRE_ALLOC_T(bool, getPolygonCount(), MEMCATEGORY_SCENE_CONTROL);
for ( size_t i=0; i<getPolygonCount(); ++i )
{
bChecked[ i ] = false;
}
for ( size_t i=0; i<getPolygonCount(); ++i )
{
bool bFound = false;
for ( size_t j=0; j<getPolygonCount(); ++j )
{
const Polygon& pA = getPolygon( i );
const Polygon& pB = rhs.getPolygon( j );
if ( pA == pB )
{
bFound = true;
bChecked[ i ] = true;
break;
}
}
if ( bFound == false )
{
OGRE_FREE(bChecked, MEMCATEGORY_SCENE_CONTROL);
bChecked = 0;
return false;
}
}
for ( size_t i=0; i<getPolygonCount(); ++i )
{
if ( bChecked[ i ] != true )
{
OGRE_FREE(bChecked, MEMCATEGORY_SCENE_CONTROL);
bChecked = 0;
return false;
}
}
OGRE_FREE(bChecked, MEMCATEGORY_SCENE_CONTROL);
bChecked = 0;
return true;
}
示例4: getPolygonCount
//-----------------------------------------------------------------------
bool ConvexBody::operator == ( const ConvexBody& rhs ) const
{
if ( getPolygonCount() != rhs.getPolygonCount() )
return false;
// Compare the polygons. They may not be in correct order.
// A correct convex body does not have identical polygons in its body.
bool *bChecked = new bool[ getPolygonCount() ];
for ( size_t i=0; i<getPolygonCount(); ++i )
{
bChecked[ i ] = false;
}
for ( size_t i=0; i<getPolygonCount(); ++i )
{
bool bFound = false;
for ( size_t j=0; j<getPolygonCount(); ++j )
{
const Polygon& pA = getPolygon( i );
const Polygon& pB = rhs.getPolygon( j );
if ( pA == pB )
{
bFound = true;
bChecked[ i ] = true;
break;
}
}
if ( bFound == false )
{
OGRE_DELETE_ARRAY( bChecked );
return false;
}
}
for ( size_t i=0; i<getPolygonCount(); ++i )
{
if ( bChecked[ i ] != true )
{
OGRE_DELETE_ARRAY( bChecked );
return false;
}
}
OGRE_DELETE_ARRAY( bChecked );
return true;
}
示例5: ray
//-----------------------------------------------------------------------
void FocusedShadowCameraSetup::PointListBody::buildAndIncludeDirection(
const ConvexBody& body, Real extrudeDist, const Vector3& dir)
{
// reset point list
this->reset();
// intersect the rays formed by the points in the list with the given direction and
// insert them into the list
const size_t polyCount = body.getPolygonCount();
for (size_t iPoly = 0; iPoly < polyCount; ++iPoly)
{
// store the old inserted point and plane info
// if the currently processed point hits a different plane than the previous point an
// intersection point is calculated that lies on the two planes' intersection edge
// fetch current polygon
const Polygon& p = body.getPolygon(iPoly);
size_t pointCount = p.getVertexCount();
for (size_t iPoint = 0; iPoint < pointCount ; ++iPoint)
{
// base point
const Vector3& pt = p.getVertex(iPoint);
// add the base point
this->addPoint(pt);
// intersection ray
Ray ray(pt, dir);
const Vector3 ptIntersect = ray.getPoint(extrudeDist);
this->addPoint(ptIntersect);
} // for: polygon point iteration
} // for: polygon iteration
}
示例6: clip
//-----------------------------------------------------------------------
void ConvexBody::clip(const ConvexBody& body)
{
if ( this == &body )
return;
// for each polygon; clip 'this' with each plane of 'body'
// front vertex representation is ccw
Plane pl;
for ( size_t iPoly = 0; iPoly < body.getPolygonCount(); ++iPoly )
{
const Polygon& p = body.getPolygon( iPoly );
OgreAssert( p.getVertexCount() >= 3, "A valid polygon must contain at least three vertices." );
// set up plane with first three vertices of the polygon (a polygon is always planar)
pl.redefine( p.getVertex( 0 ), p.getVertex( 1 ), p.getVertex( 2 ) );
clip(pl);
}
}
示例7:
//-----------------------------------------------------------------------
void FocusedShadowCameraSetup::PointListBody::build(const ConvexBody& body, bool filterDuplicates)
{
// erase list
mBodyPoints.clear();
// Try to reserve a representative amount of memory
mBodyPoints.reserve(body.getPolygonCount() * 6);
// build new list
for (size_t i = 0; i < body.getPolygonCount(); ++i)
{
for (size_t j = 0; j < body.getVertexCount(i); ++j)
{
const Vector3 &vInsert = body.getVertex(i, j);
// duplicates allowed?
if (filterDuplicates)
{
bool bPresent = false;
for(Polygon::VertexList::iterator vit = mBodyPoints.begin();
vit != mBodyPoints.end(); ++vit)
{
const Vector3& v = *vit;
if (vInsert.positionEquals(v))
{
bPresent = true;
break;
}
}
if (bPresent == false)
{
mBodyPoints.push_back(body.getVertex(i, j));
}
}
// else insert directly
else
{
mBodyPoints.push_back(body.getVertex(i, j));
}
}
}
// update AAB
// no points altered, so take body AAB
mAAB = body.getAABB();
}
示例8: main
int main() {
int i;
while (scanf("%d",&hull.n), hull.n) {
for (i = 0; i < hull.n; i++) scanf("%lf%lf%lf", &hull.P[i].x, &hull.P[i].y, &hull.P[i].z);
hull.convex_hull();
printf("%.2lf\n", hull.volume());
}
}