本文整理汇总了C++中Box3F::intersect方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3F::intersect方法的具体用法?C++ Box3F::intersect怎么用?C++ Box3F::intersect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3F
的用法示例。
在下文中一共展示了Box3F::intersect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeBounds
void TSShapeLoader::computeBounds(Box3F& bounds)
{
// Compute the box that encloses the model geometry
bounds = Box3F::Invalid;
// Use bounds node geometry if present
if ( boundsNode && boundsNode->getNumMesh() )
{
for (S32 iMesh = 0; iMesh < boundsNode->getNumMesh(); iMesh++)
{
AppMesh* mesh = boundsNode->getMesh( iMesh );
if ( !mesh )
continue;
Box3F meshBounds;
mesh->computeBounds( meshBounds );
if ( meshBounds.isValidBox() )
bounds.intersect( meshBounds );
}
}
else
{
// Compute bounds based on all geometry in the model
for (S32 iMesh = 0; iMesh < appMeshes.size(); iMesh++)
{
AppMesh* mesh = appMeshes[iMesh];
if ( !mesh )
continue;
Box3F meshBounds;
mesh->computeBounds( meshBounds );
if ( meshBounds.isValidBox() )
bounds.intersect( meshBounds );
}
}
}
示例2: renderTool
void TransformTool::renderTool()
{
if (!mActive)
return;
// Grid
{
Point3F editorPos = mEditorManager->mEditorCamera.getWorldPosition();
editorPos = editorPos / 10.0f;
editorPos.x = mFloor(editorPos.x);
editorPos.y = mFloor(editorPos.y);
editorPos = editorPos * 10.0f;
Torque::Debug.ddPush();
Torque::Debug.ddSetState(true, false, true);
Torque::Debug.ddSetWireframe(true);
Torque::Debug.ddSetColor(BGFXCOLOR_RGBA(255, 255, 255, 255));
F32 gridNormal[3] = { 0.0f, 0.0f, 1.0f };
F32 gridPos[3] = { editorPos.x, editorPos.y, -0.01f };
Torque::Debug.ddDrawGrid(gridNormal, gridPos, 100, 10.0f);
}
// Draw Light Icons
/*if (mLightIcon != NULL)
{
Vector<Lighting::LightData*> lightList = Torque::Lighting.getLightList();
for (S32 n = 0; n < lightList.size(); ++n)
{
Lighting::LightData* light = lightList[n];
Torque::Graphics.drawBillboard(mEditorManager->mRenderLayer4View->id,
mLightIcon,
light->position,
1.0f, 1.0f,
ColorI(light->color[0] * 255, light->color[1] * 255, light->color[2] * 255, 255),
NULL);
}
}*/
if (mMultiselect)
{
Box3F multiSelectBox;
multiSelectBox.set(Point3F(0, 0, 0));
for (S32 n = 0; n < mSelectedObjects.size(); ++n)
{
Scene::SceneObject* obj = dynamic_cast<Scene::SceneObject*>(mSelectedObjects[n]);
if (obj)
{
if (n == 0)
multiSelectBox = obj->mBoundingBox;
else
multiSelectBox.intersect(obj->mBoundingBox);
}
Scene::BaseComponent* component = dynamic_cast<Scene::BaseComponent*>(mSelectedObjects[n]);
if (component)
{
Box3F boundingBox = component->getBoundingBox();
boundingBox.transform(component->mTransform.matrix);
if (n == 0)
multiSelectBox = boundingBox;
else
multiSelectBox.intersect(boundingBox);
}
}
mSelectionBounds = true;
mSelectionBoundsStart = multiSelectBox.minExtents;
mSelectionBoundsEnd = multiSelectBox.maxExtents;
}
// Object Selected
if (mSelectedObject != NULL && mSelectedComponent == NULL)
{
mSelectionBounds = true;
mSelectionBoundsStart = mSelectedObject->mBoundingBox.minExtents;
mSelectionBoundsEnd = mSelectedObject->mBoundingBox.maxExtents;
}
// Component Selected
if (mSelectedObject != NULL && mSelectedComponent != NULL)
{
Box3F boundingBox = mSelectedComponent->getBoundingBox();
boundingBox.transform(mSelectedObject->mTransform.matrix);
mSelectionBounds = true;
mSelectionBoundsStart = boundingBox.minExtents;
mSelectionBoundsEnd = boundingBox.maxExtents;
}
// Selection Bounding Box
if (mSelectionBounds)
{
Aabb debugBox;
debugBox.m_min[0] = mSelectionBoundsStart.x;
debugBox.m_min[1] = mSelectionBoundsStart.y;
debugBox.m_min[2] = mSelectionBoundsStart.z;
//.........这里部分代码省略.........
示例3: _captureVerts
void DecalRoad::_captureVerts()
{
PROFILE_SCOPE( DecalRoad_captureVerts );
//Con::warnf( "%s - captureVerts", isServerObject() ? "server" : "client" );
if ( isServerObject() )
{
//Con::errorf( "DecalRoad::_captureVerts - called on the server side!" );
return;
}
if ( mEdges.size() == 0 )
return;
//
// Construct ClippedPolyList objects for each pair
// of roadEdges.
// Use them to capture Terrain verts.
//
SphereF sphere;
RoadEdge *edge = NULL;
RoadEdge *nextEdge = NULL;
mTriangleCount = 0;
mVertCount = 0;
Vector<ClippedPolyList> clipperList;
for ( U32 i = 0; i < mEdges.size() - 1; i++ )
{
Box3F box;
edge = &mEdges[i];
nextEdge = &mEdges[i+1];
box.minExtents = edge->p1;
box.maxExtents = edge->p1;
box.extend( edge->p0 );
box.extend( edge->p2 );
box.extend( nextEdge->p0 );
box.extend( nextEdge->p1 );
box.extend( nextEdge->p2 );
box.minExtents.z -= 5.0f;
box.maxExtents.z += 5.0f;
sphere.center = ( nextEdge->p1 + edge->p1 ) * 0.5f;
sphere.radius = 100.0f; // NOTE: no idea how to calculate this
ClippedPolyList clipper;
clipper.mNormal.set(0.0f, 0.0f, 0.0f);
VectorF n;
PlaneF plane0, plane1;
// Construct Back Plane
n = edge->p2 - edge->p0;
n.normalize();
n = mCross( n, edge->uvec );
plane0.set( edge->p0, n );
clipper.mPlaneList.push_back( plane0 );
// Construct Front Plane
n = nextEdge->p2 - nextEdge->p0;
n.normalize();
n = -mCross( edge->uvec, n );
plane1.set( nextEdge->p0, -n );
//clipper.mPlaneList.push_back( plane1 );
// Test if / where the planes intersect.
bool discardLeft = false;
bool discardRight = false;
Point3F iPos;
VectorF iDir;
if ( plane0.intersect( plane1, iPos, iDir ) )
{
Point2F iPos2F( iPos.x, iPos.y );
Point2F cPos2F( edge->p1.x, edge->p1.y );
Point2F rVec2F( edge->rvec.x, edge->rvec.y );
Point2F iVec2F = iPos2F - cPos2F;
F32 iLen = iVec2F.len();
iVec2F.normalize();
if ( iLen < edge->width * 0.5f )
{
F32 dot = mDot( rVec2F, iVec2F );
// The clipping planes intersected on the right side,
// discard the right side clipping plane.
if ( dot > 0.0f )
discardRight = true;
// The clipping planes intersected on the left side,
// discard the left side clipping plane.
else
discardLeft = true;
}
}
// Left Plane
if ( !discardLeft )
//.........这里部分代码省略.........