|
| 1 | +/****************************************************************************** |
| 2 | +* SOFA, Simulation Open-Framework Architecture * |
| 3 | +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * |
| 4 | +* * |
| 5 | +* This program is free software; you can redistribute it and/or modify it * |
| 6 | +* under the terms of the GNU Lesser General Public License as published by * |
| 7 | +* the Free Software Foundation; either version 2.1 of the License, or (at * |
| 8 | +* your option) any later version. * |
| 9 | +* * |
| 10 | +* This program is distributed in the hope that it will be useful, but WITHOUT * |
| 11 | +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * |
| 12 | +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * |
| 13 | +* for more details. * |
| 14 | +* * |
| 15 | +* You should have received a copy of the GNU Lesser General Public License * |
| 16 | +* along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | +******************************************************************************* |
| 18 | +* Authors: The SOFA Team and external contributors (see Authors.txt) * |
| 19 | +* * |
| 20 | +* Contact information: contact@sofa-framework.org * |
| 21 | +******************************************************************************/ |
| 22 | + |
| 23 | +#include <sofa/component/visual/VisualBoundingBox.h> |
| 24 | +#include <sofa/core/visual/VisualParams.h> |
| 25 | +#include <sofa/core/ObjectFactory.h> |
| 26 | +#include <sofa/defaulttype/VecTypes.h> |
| 27 | + |
| 28 | +namespace sofa::component::visual |
| 29 | +{ |
| 30 | + |
| 31 | +void registerVisualBoundingBox(sofa::core::ObjectFactory* factory) |
| 32 | +{ |
| 33 | + factory->registerObjects(core::ObjectRegistrationData("Display an Axis Aligned Bounding Box (AABB).") |
| 34 | + .add< VisualBoundingBox >()); |
| 35 | +} |
| 36 | + |
| 37 | +VisualBoundingBox::VisualBoundingBox() |
| 38 | + : d_color(initData(&d_color, sofa::type::RGBAColor::yellow(), "color", "Color of the lines of the box.")) |
| 39 | + , d_thickness(initData(&d_thickness, 1.0f, "thickness", "Thickness of the lines of the box.")) |
| 40 | +{ |
| 41 | + |
| 42 | +} |
| 43 | + |
| 44 | +void VisualBoundingBox::doDrawVisual(const core::visual::VisualParams* vparams) |
| 45 | +{ |
| 46 | + |
| 47 | + const auto& bbox = f_bbox.getValue(); |
| 48 | + vparams->drawTool()->disableLighting(); |
| 49 | + vparams->drawTool()->setMaterial(d_color.getValue()); |
| 50 | + vparams->drawTool()->drawBoundingBox(bbox.minBBox(), bbox.maxBBox(), d_thickness.getValue()); |
| 51 | +} |
| 52 | + |
| 53 | +} // namespace sofa::component::visual |
0 commit comments