当前位置: 首页>>代码示例>>C++>>正文


C++ BoundingBox::getCorners方法代码示例

本文整理汇总了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);
}
开发者ID:jbake,项目名称:FAST,代码行数:11,代码来源:MeshRenderer.cpp

示例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;
}
开发者ID:Brodjaga,项目名称:libgdx-cpp,代码行数:15,代码来源:Frustum.cpp

示例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;
}
开发者ID:ileben,项目名称:GameEngine,代码行数:44,代码来源:app.cpp

示例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, &param1Valid);
                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;
}
开发者ID:0chunhui,项目名称:GamePlay,代码行数:41,代码来源:lua_BoundingBox.cpp


注:本文中的BoundingBox::getCorners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。