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


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

本文整理汇总了C++中BoundingBox::getHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::getHeight方法的具体用法?C++ BoundingBox::getHeight怎么用?C++ BoundingBox::getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBox的用法示例。


在下文中一共展示了BoundingBox::getHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawBoundingBox

void QtGraphicsViewVisitor::drawBoundingBox(BoundingBox &boundingBox) {
    int x = boundingBox.getX();
    int y = boundingBox.getY();
    int w = boundingBox.getWidth();
    int h = boundingBox.getHeight();
    scene->addRect(x, y, w, h, *greenPen);
}
开发者ID:a60814billy,项目名称:NTUT2015fallPOSD-HW,代码行数:7,代码来源:QtGraphicsViewVisitor.cpp

示例2: overlapsWith

bool BoundingBox::overlapsWith(const BoundingBox& other)
{
   if(!use || !other.use) return false;

   float wa = getWidth()/2;
   float ha = getHeight()/2;
   float da = getDepth()/2;

   glm::vec3 Ca = getCenter();
   glm::vec3 Az = getFrontNormal();
   glm::vec3 Ay = getUpNormal();
   glm::vec3 Ax = getRightNormal();

   glm::vec3 Cb = other.getCenter();
   glm::vec3 Bz = other.getFrontNormal();
   glm::vec3 By = other.getUpNormal();
   glm::vec3 Bx = other.getRightNormal();
   float wb = other.getWidth()/2;
   float hb = other.getHeight()/2;
   float db = other.getDepth()/2;

   glm::vec3 T = Cb - Ca;

   float lhs = 0, rhs = 0;

   float Rxx = glm::dot(Ax, Bx);
   float Rxy = glm::dot(Ax, By);
   float Rxz = glm::dot(Ax, Bz);

   // Case 1: L = Ax
   lhs = glm::dot(T, Ax);
   rhs = wa + fabs(wb * Rxx) + fabs(hb * Rxy) + fabs(db * Rxz);
   if(lhs > rhs) return false;

   float Ryx = glm::dot(Ay, Bx);
   float Ryy = glm::dot(Ay, By);
   float Ryz = glm::dot(Ay, Bz);

   // Case 2: L = Ay
   lhs = glm::dot(T, Ay);
   rhs = ha + fabs(wb * Ryx) + fabs(hb * Ryy) + fabs(db * Ryz);
   if(lhs > rhs) return false;

   float Rzx = glm::dot(Az, Bx);
   float Rzy = glm::dot(Az, By);
   float Rzz = glm::dot(Az, Bz);

   // Case 3: L = Az
   lhs = glm::dot(T, Az);
   rhs = da + fabs(wb * Rzx) + fabs(hb * Rzy) + fabs(db * Rzz);
   if(lhs > rhs) return false;

   // Case 4: L = Bx
   lhs = glm::dot(T, Bx);
   rhs = fabs(wa * Rxx) + fabs(ha * Ryx) + fabs(da * Rzx) + wb;
   if(lhs > rhs) return false;

   // Case 5: L = By
   lhs = glm::dot(T, By);
   rhs = fabs(wa * Rxy) + fabs(ha * Ryy) + fabs(da * Rzy) + hb;
   if(lhs > rhs) return false;

   // Case 6: L = Bz
   lhs = glm::dot(T, Bz);
   rhs = fabs(wa * Rxz) + fabs(ha * Ryz) + fabs(da * Rzz) + db;
   if(lhs > rhs) return false;

   // Case 7: L = Ax x Bx
   lhs = glm::dot(T, glm::cross(Ax, Bx));
   rhs = fabs(ha * Rzx) + fabs(da * Ryx) + fabs(hb * Rxz) + fabs(db * Rxy);
   if(lhs > rhs) return false;

   // Case 8: L = Ax x By
   lhs = glm::dot(T, glm::cross(Ax, By));
   rhs = fabs(ha * Rzy) + fabs(da * Ryy) + fabs(wb * Rxz) + fabs(db * Rxx);
   if(lhs > rhs) return false;

   // Case 9: L = Ax x Bz
   lhs = glm::dot(T, glm::cross(Ax, Bz));
   rhs = fabs(ha * Rzz) + fabs(da * Ryz) + fabs(wb * Rxy) + fabs(hb * Rxx);
   if(lhs > rhs) return false;

   // Case 10: L = Ay x Bx
   lhs = glm::dot(T, glm::cross(Ay, Bx));
   rhs = fabs(wa * Rzx) + fabs(da * Rxx) + fabs(hb * Ryz) + fabs(db * Ryy);
   if(lhs > rhs) return false;

   // Case 11: L = Ay x By
   lhs = glm::dot(T, glm::cross(Ay, By));
   rhs = fabs(wa * Rzy) + fabs(da * Rxy) + fabs(wb * Ryz) + fabs(db * Ryx);
   if(lhs > rhs) return false;

   // Case 12: L = Ay x Bz
   lhs = glm::dot(T, glm::cross(Ay, Bz));
   rhs = fabs(wa * Rzz) + fabs(da * Rxz) + fabs(wb * Ryy) + fabs(hb * Ryx);
   if(lhs > rhs) return false;

   // Case 13: L = Az x Bx
   lhs = glm::dot(T, glm::cross(Az, Bx));
   rhs = fabs(wa * Ryx) + fabs(ha * Rxx) + fabs(hb * Rzz) + fabs(db * Rzy);
//.........这里部分代码省略.........
开发者ID:fishersc,项目名称:3DGEFinal,代码行数:101,代码来源:BoundingBox.cpp

示例3: osgColor

osg::Drawable *ClampNode::createBrick(void) const {
    // Get the brick
    Clamp* clamp = static_cast<Clamp*>(_lego);
    
    // Get brick color
    QColor color = clamp->getColor();

    // Get clamp bounding box
    clamp->calculateBoundingBox();
    BoundingBox bb = clamp->getBoundingBox();
    // Get integer sizes
    int width = bb.getWidth();
    int length = bb.getLength();
    int height = bb.getHeight();

    // Get real position, according to tile size
    double mw = (-width)*Lego::length_unit/2;
    double mwpm = (-width)*Lego::length_unit/2+Lego::height_unit/2;
    double mwp = (-width)*Lego::length_unit/2+0.93*Lego::height_unit;
    double pw = (width)*Lego::length_unit/2;
    double pwm = (width)*Lego::length_unit/2-Lego::height_unit/2;
    double ml = (-length)*Lego::length_unit/2;
    double mlp = (-length+0.5)*Lego::length_unit/2;
    double pl = (length)*Lego::length_unit/2;
    double plm = (length-0.5)*Lego::length_unit/2;
    double mh = (-height)*Lego::height_unit/2;
    double mhp = (-height)*Lego::height_unit/2+2*Lego::plot_top_height;
    double mhpm = (-height)*Lego::height_unit/2+Lego::plot_top_height;
    double phm = (height)*Lego::height_unit/2-Lego::height_unit/2;
    double phmp = (height)*Lego::height_unit/2-0.5*Lego::height_unit/2;
    
    // Create 3 vertices
    osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
    osg::Vec3 v0(ml, mw, mh);
    osg::Vec3 v1(pl, mw, mh);
    osg::Vec3 v2(pl, pw, mh);
    osg::Vec3 v3(ml, pw, mh);
    osg::Vec3 v4(ml, pw, mhp);
    osg::Vec3 v5(pl, pw, mhp);
    osg::Vec3 v6(pl, mw, mhp);
    osg::Vec3 v7(ml, mw, mhp);
    osg::Vec3 v8(mlp, mw, mhp);
    osg::Vec3 v9(mlp, mw, phm);
    osg::Vec3 v10(ml, mw, phm);
    osg::Vec3 v11(ml, mwp, phmp);
    osg::Vec3 v12(mlp, mwp, phmp);
    osg::Vec3 v13(mlp, pw, mhp);
    osg::Vec3 v14(plm, mw, mhp);
    osg::Vec3 v15(plm, mw, phm);
    osg::Vec3 v16(pl, mw, phm);
    osg::Vec3 v17(pl, mwp, phmp);
    osg::Vec3 v18(plm, mwp, phmp);
    osg::Vec3 v19(plm, pw, mhp);
    osg::Vec3 v20(mlp, mwpm, mh);
    osg::Vec3 v21(plm, mwpm, mh);
    osg::Vec3 v22(plm, pwm, mh);
    osg::Vec3 v23(mlp, pwm, mh);
    osg::Vec3 v24(mlp, mwpm, mhpm);
    osg::Vec3 v25(plm, mwpm, mhpm);
    osg::Vec3 v26(plm, pwm, mhpm);
    osg::Vec3 v27(mlp, pwm, mhpm);
    
    // Create 1 faces, 0 faces are quads splitted into two triangles
    // NB: Down face is transparent, we don't even create it

    // Bottom
    vertices->push_back(v3);
    vertices->push_back(v2);
    vertices->push_back(v1);
    vertices->push_back(v0);
    // Bottom hole
    vertices->push_back(v20);
    vertices->push_back(v21);
    vertices->push_back(v22);
    vertices->push_back(v23);
    // Bottom far
    vertices->push_back(v24);
    vertices->push_back(v25);
    vertices->push_back(v26);
    vertices->push_back(v27);

    // Front face
    vertices->push_back(v2);
    vertices->push_back(v3);
    vertices->push_back(v4);
    vertices->push_back(v5);

    // Back face
    vertices->push_back(v0);
    vertices->push_back(v1);
    vertices->push_back(v6);
    vertices->push_back(v7);

    // Left bottom face
    vertices->push_back(v0);
    vertices->push_back(v3);
    vertices->push_back(v4);
    vertices->push_back(v7);

    // Right bottom face
//.........这里部分代码省略.........
开发者ID:vmichele,项目名称:LEGO_CREATOR,代码行数:101,代码来源:ClampNode.cpp

示例4: createGeode

void ClampNode::createGeode(void) {
    // Remove children
    removeChildren(0, getNumChildren());
    
    // Create geode
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    addChild(geode);
    geode->addDrawable(createBrick());

    // Distance between two plot center
    double distPlot = Lego::length_unit;

    // Get the brick
    Clamp* clamp = static_cast<Clamp*>(_lego);

    // Get clamp bounding box
    clamp->calculateBoundingBox();
    BoundingBox bb = clamp->getBoundingBox();
    // Get integer sizes
    int width = bb.getWidth();
    int length = bb.getLength();
    int height = bb.getHeight();

    // Calculate x max and y max for plots
    double xminb = -(length-2)*Lego::length_unit/2;
    double yminb = -(width-1)*Lego::length_unit/2;

    double w = (-width)*Lego::length_unit/2+Lego::height_unit/2;
    double h = (height)*Lego::height_unit/2-Lego::height_unit/2;

    // Add cylinder parts

    // Create geode
    osg::ref_ptr<osg::Geode> cylinderGeode = new osg::Geode;

    // Create drawable cylinder
    osg::Drawable* cylinderPart = makeCylinder(0, w, h, length*Lego::length_unit, Lego::height_unit/2);
    // Add drawable to geode
    cylinderGeode->addDrawable(cylinderPart);

    // Create top and bottom cylinder
    osg::Drawable* topPart = makeDisk(0, w, h, Lego::height_unit/2, length*Lego::length_unit, true);
    osg::Drawable* bottomPart = makeDisk(0, w, h, Lego::height_unit/2, length*Lego::length_unit, false);
    // Add drawables to geode
    cylinderGeode->addDrawable(topPart);
    cylinderGeode->addDrawable(bottomPart);

    // Create matrix transform to rotate cylinder
    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
    // Create matrix to handle rotation
    osg::Matrix matRot, matTrans;
    // Make PI/2 rotation according to y axis
    matRot.makeRotate(M_PI_2, osg::Vec3(0.f, 1.f, 0.f));
    // Translate
    matTrans.makeTranslate(-length*Lego::length_unit/4-Lego::height_unit/4, 0, 3*height*Lego::height_unit/8);
    // Set matrix transform matrix
    mt->setMatrix(matRot*matTrans);
    // Add geode to matrix transform
    mt->addChild(cylinderGeode.get());
    // Add matrix transform
    addChild(mt);

    // Add bottom cylinders iteratively
    for (int i = 0; i < length-1; i++) {
        for (int j = 0; j < width; j++) {
            double radiusX = xminb + i*distPlot;
            double radiusY = yminb + j*distPlot;

            addChild(createBottomCylinder(radiusX, radiusY, 0.5, true, (-height+0.5)*Lego::height_unit/2));
        }
    }
}
开发者ID:vmichele,项目名称:LEGO_CREATOR,代码行数:72,代码来源:ClampNode.cpp


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