Пример #1
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void ChTrackTestRig::AddVisualize_post(std::shared_ptr<ChBody> post_body,
                                       std::shared_ptr<ChBody> chassis_body,
                                       double length,
                                       double width,
                                       double height,
                                       const ChColor& color) {
    // Platform (on post body)
    auto base_box = std::make_shared<ChBoxShape>();
    base_box->GetBoxGeometry().SetLengths(ChVector<>(length, width, height));
    post_body->AddAsset(base_box);

    auto col = std::make_shared<ChColorAsset>();
    col->SetColor(color);
    post_body->AddAsset(col);

    // Piston (on post body)
    auto piston = std::make_shared<ChCylinderShape>();
    piston->GetCylinderGeometry().rad = width / 6.0;
    piston->GetCylinderGeometry().p1 = ChVector<>(0, 0, -height / 2.0);
    piston->GetCylinderGeometry().p2 = ChVector<>(0, 0, -height * 12.0);
    post_body->AddAsset(piston);  // add asset to post body

    // Post sleeve (on chassis/ground body)
    auto cyl = std::make_shared<ChCylinderShape>();
    cyl->GetCylinderGeometry().rad = width / 4.0;
    cyl->GetCylinderGeometry().p1 = post_body->GetPos() - ChVector<>(0, 0, 8 * height);
    cyl->GetCylinderGeometry().p2 = post_body->GetPos() - ChVector<>(0, 0, 16 * height);
    chassis_body->AddAsset(cyl);
}
Пример #2
0
void ChTrackTestRigChassis::AddVisualizationAssets(VisualizationType vis) {
    auto box = std::make_shared<ChBoxShape>();
    box->GetBoxGeometry().SetLengths(ChVector<>(0.1, 0.1, 0.1));
    m_body->AddAsset(box);

    auto blue = std::make_shared<ChColorAsset>();
    blue->SetColor(ChColor(0.2f, 0.2f, 0.8f));
    m_body->AddAsset(blue);
}
void ChTrackShoeBandBushing::AddWebVisualization(std::shared_ptr<ChBody> segment) {
    segment->AddAsset(std::make_shared<ChColorAsset>(GetColor(m_index)));

    auto box = std::make_shared<ChBoxShape>();
    box->GetBoxGeometry().SetLengths(ChVector<>(m_seg_length, GetBeltWidth(), GetWebThickness()));
    segment->AddAsset(box);

    auto cyl = std::make_shared<ChCylinderShape>();
    double radius = GetWebThickness() / 4;
    cyl->GetCylinderGeometry().rad = radius;
    cyl->GetCylinderGeometry().p1 = ChVector<>(m_seg_length / 2, -GetBeltWidth() / 2 - 2 * radius, 0);
    cyl->GetCylinderGeometry().p2 = ChVector<>(m_seg_length / 2, +GetBeltWidth() / 2 + 2 * radius, 0);
    segment->AddAsset(cyl);
}
Пример #4
0
    float csBulletCollider::GetVolume ()
    {
        switch (geomType)
        {
        case BOX_COLLIDER_GEOMETRY:
        {
            csVector3 size;
            GetBoxGeometry (size);
            return size[0] * size[1] * size[2];
        }

        case SPHERE_COLLIDER_GEOMETRY:
        {
            csSphere sphere;
            GetSphereGeometry (sphere);
            return 1.333333f * PI * sphere.GetRadius () * sphere.GetRadius ()
                   * sphere.GetRadius ();
        }

        case CYLINDER_COLLIDER_GEOMETRY:
        {
            float length;
            float radius;
            GetCylinderGeometry (length, radius);
            return PI * radius * radius * length;
        }

        case CAPSULE_COLLIDER_GEOMETRY:
        {
            float length;
            float radius;
            GetCapsuleGeometry (length, radius);
            return PI * radius * radius * length
                   + 1.333333f * PI * radius * radius * radius;
        }

        case CONVEXMESH_COLLIDER_GEOMETRY:
        {
            if (vertexCount == 0)
                return 0.0f;

            float volume = 0.0f;
            int faceCount = (int)vertexCount / 3;
            btVector3 origin = vertices[indices[0]];
            for (int i = 1; i < faceCount; i++)
            {
                int index = i * 3;
                volume += fabsl (btDot
                                 (vertices[indices[index]] - origin,
                                  btCross (vertices[indices[index + 1]] - origin,
                                           vertices[indices[index + 2]] - origin)));
            }

            return volume / 6.0f;
        }

        case TRIMESH_COLLIDER_GEOMETRY:
        {
            if (vertexCount == 0)
                return 0.0f;

            // TODO: this is a really rough estimation
            btVector3 center;
            btScalar radius;
            shape->getBoundingSphere (center, radius);
            return 1.333333f * PI * radius * radius * radius;
        }

        default:
            return 0.0f;
        }

        return 0.0f;
    }
Пример #5
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void ChTrackShoeSinglePin::AddVisualizationAssets(VisualizationType vis) {
    if (vis == VisualizationType::NONE)
        return;

    double pitch = GetPitch();

    double front_cyl_loc = GetFrontCylinderLoc();
    double rear_cyl_loc = GetRearCylinderLoc();
    double cyl_radius = GetCylinderRadius();

    const ChVector<>& pad_box_dims = GetPadBoxDimensions();
    const ChVector<>& guide_box_dims = GetGuideBoxDimensions();

    double p0y = 2.1 * (pad_box_dims.y() / 2);
    double p1y = 1.5 * (pad_box_dims.y() / 2);
    double p2y = 0.5 * (pad_box_dims.y() / 2);

    // Render the revolute pin
    auto rev_axis = std::make_shared<ChCylinderShape>();
    rev_axis->GetCylinderGeometry().p1 = ChVector<>(pitch / 2, -p0y, 0);
    rev_axis->GetCylinderGeometry().p2 = ChVector<>(pitch / 2, p0y, 0);
    rev_axis->GetCylinderGeometry().rad = cyl_radius / 1.5;
    m_shoe->AddAsset(rev_axis);

    // Render boxes between pins
    auto box_L = std::make_shared<ChBoxShape>();
    box_L->GetBoxGeometry().SetLengths(ChVector<>(pitch - 1.5 * cyl_radius, 0.95 * (p0y - p1y), pad_box_dims.z() / 3));
    box_L->GetBoxGeometry().Pos = ChVector<>(0, +0.95 * (p0y + p1y) / 2, 0);
    m_shoe->AddAsset(box_L);

    auto box_R = std::make_shared<ChBoxShape>();
    box_R->GetBoxGeometry().SetLengths(ChVector<>(pitch - 1.5 * cyl_radius, 0.95 * (p0y - p1y), pad_box_dims.z() / 3));
    box_R->GetBoxGeometry().Pos = ChVector<>(0, -0.95 * (p0y + p1y) / 2, 0);
    m_shoe->AddAsset(box_R);

    // Render the contact cylinders (for contact with sprocket)
    auto cyl_FR = std::make_shared<ChCylinderShape>();
    cyl_FR->GetCylinderGeometry().p1 = ChVector<>(front_cyl_loc, -p1y, 0);
    cyl_FR->GetCylinderGeometry().p2 = ChVector<>(front_cyl_loc, -p2y, 0);
    cyl_FR->GetCylinderGeometry().rad = cyl_radius;
    m_shoe->AddAsset(cyl_FR);

    auto cyl_RR = std::make_shared<ChCylinderShape>();
    cyl_RR->GetCylinderGeometry().p1 = ChVector<>(rear_cyl_loc, -p1y, 0);
    cyl_RR->GetCylinderGeometry().p2 = ChVector<>(rear_cyl_loc, -p2y, 0);
    cyl_RR->GetCylinderGeometry().rad = cyl_radius;
    m_shoe->AddAsset(cyl_RR);

    auto cyl_FL = std::make_shared<ChCylinderShape>();
    cyl_FL->GetCylinderGeometry().p1 = ChVector<>(front_cyl_loc, p1y, 0);
    cyl_FL->GetCylinderGeometry().p2 = ChVector<>(front_cyl_loc, p2y, 0);
    cyl_FL->GetCylinderGeometry().rad = cyl_radius;
    m_shoe->AddAsset(cyl_FL);

    auto cyl_RL = std::make_shared<ChCylinderShape>();
    cyl_RL->GetCylinderGeometry().p1 = ChVector<>(rear_cyl_loc, p1y, 0);
    cyl_RL->GetCylinderGeometry().p2 = ChVector<>(rear_cyl_loc, p2y, 0);
    cyl_RL->GetCylinderGeometry().rad = cyl_radius;
    m_shoe->AddAsset(cyl_RL);

    // Render the pad contact box
    auto box_shoe = std::make_shared<ChBoxShape>();
    box_shoe->GetBoxGeometry().SetLengths(pad_box_dims);
    box_shoe->GetBoxGeometry().Pos = GetPadBoxLocation();
    m_shoe->AddAsset(box_shoe);

    // Render the guiding pin contact box
    auto box_pin = std::make_shared<ChBoxShape>();
    box_pin->GetBoxGeometry().SetLengths(guide_box_dims);
    box_pin->GetBoxGeometry().Pos = GetGuideBoxLocation();
    m_shoe->AddAsset(box_pin);

    // Assign color (based on track shoe index)
    auto col = std::make_shared<ChColorAsset>();
    if (m_index == 0)
        col->SetColor(ChColor(0.6f, 0.3f, 0.3f));
    else if (m_index % 2 == 0)
        col->SetColor(ChColor(0.3f, 0.6f, 0.3f));
    else
        col->SetColor(ChColor(0.3f, 0.3f, 0.6f));
    m_shoe->AddAsset(col);
}