本文整理汇总了C++中BoundingBox::getCorners方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::getCorners方法的具体用法?C++ BoundingBox::getCorners怎么用?C++ BoundingBox::getCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::getCorners方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBoundingBox
BoundingBox MeshRenderer::getBoundingBox() {
std::vector<Vector3f> coordinates;
for(uint i = 0; i < getNrOfInputData(); i++) {
BoundingBox transformedBoundingBox = mMeshToRender[i]->getTransformedBoundingBox();
MatrixXf corners = transformedBoundingBox.getCorners();
for(uint j = 0; j < 8; j++) {
coordinates.push_back((Vector3f)corners.row(j));
}
}
return BoundingBox(coordinates);
}
示例2: boundsInFrustum
bool Frustum::boundsInFrustum (BoundingBox& bounds) {
const std::vector<Vector3>& corners = bounds.getCorners();
int len = corners.size();
for (int i = 0, len2 = 6; i < len2; i++) {
int out = 0;
for (int j = 0; j < len; j++)
if (planes[i]->testPoint(corners[j]) == Plane::PlaneSide_Back) out++;
if (out == 8) return false;
}
return true;
}
示例3: appProjectActor
BoundingBox appProjectActor (Actor3D *actor, Camera *camera,
Float viewX, Float viewY, Float viewW, Float viewH)
{
//Get the transformation matrix
Matrix4x4 world = actor->getGlobalMatrix();
Matrix4x4 modelview = camera->getGlobalMatrix().affineNormalize().affineInverse();
Matrix4x4 projection = camera->getProjection( viewW, viewH );
Matrix4x4 m = projection * modelview * world;
//Get corners of the bounding box
BoundingBox bboxActor = actor->getBoundingBox();
Vector3 bboxCorners[8];
bboxActor.getCorners( bboxCorners );
//Project each corner into viewport
BoundingBox bboxOut;
for (Uint c=0; c<8; ++c)
{
//Projection and perspective division
Vector4 p = m.transformPoint( bboxCorners[ c ].xyz(1.0f) );
p /= p.w;
//Apply view
Vector3 v;
v.x = (Float)viewX + (0.5f * p.x + 0.5f) * (Float)viewW;
v.y = (Float)viewY + (0.5f * p.y + 0.5f) * (Float)viewH;
v.z = 1.0f - (0.5f * p.z + 0.5f);
//Find projected bounds
if (c==0) bboxOut.min = bboxOut.max = v;
else {
if (v.x < bboxOut.min.x) bboxOut.min.x = v.x;
if (v.y < bboxOut.min.y) bboxOut.min.y = v.y;
if (v.z < bboxOut.min.z) bboxOut.min.z = v.z;
if (v.x > bboxOut.max.x) bboxOut.max.x = v.x;
if (v.y > bboxOut.max.y) bboxOut.max.y = v.y;
if (v.z > bboxOut.max.z) bboxOut.max.z = v.z;
}
}
return bboxOut;
}
示例4: lua_BoundingBox_getCorners
int lua_BoundingBox_getCorners(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
{
// Get parameter 1 off the stack.
bool param1Valid;
gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", false, ¶m1Valid);
if (!param1Valid)
{
lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector3'.");
lua_error(state);
}
BoundingBox* instance = getInstance(state);
instance->getCorners(param1);
return 0;
}
lua_pushstring(state, "lua_BoundingBox_getCorners - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 2).");
lua_error(state);
break;
}
}
return 0;
}