void CqTeapot::Bound(CqBound* bound) const { CqVector3D vecMin( -3.000, -2.0, 0.0 ); CqVector3D vecMax( 3.525, 2.0, ( m_CrowBase ? 3.15 : 3.15 - 0.15 /* remove bottom */ ) ); bound->vecMin() = vecMin; bound->vecMax() = vecMax; bound->Transform( m_matTx ); AdjustBoundForTransformationMotion( bound ); }
/** * Calculates bounds for a CqCurve. * * NOTE: This method makes the same assumptions as * CqSurfacePatchBicubic::Bound() does about the convex-hull property of the * curve. This is fine most of the time, but the user can specify basis * matrices like Catmull-Rom, which are non-convex. * * FIXME: Make sure that all hulls which reach this method are convex! * * @return CqBound object containing the bounds. */ void CqCurve::Bound(CqBound* bound) const { // Get the boundary in camera space. CqVector3D vecA( FLT_MAX, FLT_MAX, FLT_MAX ); CqVector3D vecB( -FLT_MAX, -FLT_MAX, -FLT_MAX ); TqFloat maxCameraSpaceWidth = 0; TqUint nWidthParams = cVarying(); for ( TqUint i = 0; i < ( *P() ).Size(); i++ ) { // expand the boundary if necessary to accomodate the // current vertex CqVector3D vecV = vectorCast<CqVector3D>(P()->pValue( i )[0]); if ( vecV.x() < vecA.x() ) vecA.x( vecV.x() ); if ( vecV.y() < vecA.y() ) vecA.y( vecV.y() ); if ( vecV.x() > vecB.x() ) vecB.x( vecV.x() ); if ( vecV.y() > vecB.y() ) vecB.y( vecV.y() ); if ( vecV.z() < vecA.z() ) vecA.z( vecV.z() ); if ( vecV.z() > vecB.z() ) vecB.z( vecV.z() ); // increase the maximum camera space width of the curve if // necessary if ( i < nWidthParams ) { TqFloat camSpaceWidth = width()->pValue( i )[0]; if ( camSpaceWidth > maxCameraSpaceWidth ) { maxCameraSpaceWidth = camSpaceWidth; } } } // increase the size of the boundary by half the width of the // curve in camera space vecA -= ( maxCameraSpaceWidth / 2.0 ); vecB += ( maxCameraSpaceWidth / 2.0 ); bound->vecMin() = vecA; bound->vecMax() = vecB; AdjustBoundForTransformationMotion( bound ); }