Commit 73bf5d71 authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: Added-bounding-box-node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6111 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 48471400
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4826 $
// $Author: dekkers $
// $Date: 2009-02-12 20:50:56 +0100 (Do, 12. Feb 2009) $
//
//=============================================================================
//=============================================================================
//
// CLASS BoundingBoxNode - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "BoundingBoxNode.hh"
#include "SceneGraph.hh"
#include "../GL/gl.hh"
//== NAMESPACES ===============================================================
namespace ACG {
namespace SceneGraph {
//== IMPLEMENTATION ==========================================================
unsigned int
BoundingBoxNode::
availableDrawModes() const
{
return DrawModes::WIREFRAME;
}
//----------------------------------------------------------------------------
void
BoundingBoxNode::
draw(GLState& /* _state */ , unsigned int _drawMode)
{
ACG::SceneGraph::BoundingBoxAction act;
ACG::SceneGraph::traverse(this, act);
ACG::Vec3d bbmin = (ACG::Vec3d) act.bbMin();
ACG::Vec3d bbmax = (ACG::Vec3d) act.bbMax();
if (_drawMode & DrawModes::WIREFRAME)
{
glPushAttrib (GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
glVertex3f(bbmin[0],bbmin[1],bbmin[2]);
glVertex3f(bbmax[0],bbmin[1],bbmin[2]);
glVertex3f(bbmax[0],bbmin[1],bbmin[2]);
glVertex3f(bbmax[0],bbmax[1],bbmin[2]);
glVertex3f(bbmax[0],bbmax[1],bbmin[2]);
glVertex3f(bbmin[0],bbmax[1],bbmin[2]);
glVertex3f(bbmin[0],bbmax[1],bbmin[2]);
glVertex3f(bbmin[0],bbmin[1],bbmin[2]);
glVertex3f(bbmin[0],bbmin[1],bbmax[2]);
glVertex3f(bbmax[0],bbmin[1],bbmax[2]);
glVertex3f(bbmax[0],bbmin[1],bbmax[2]);
glVertex3f(bbmax[0],bbmax[1],bbmax[2]);
glVertex3f(bbmax[0],bbmax[1],bbmax[2]);
glVertex3f(bbmin[0],bbmax[1],bbmax[2]);
glVertex3f(bbmin[0],bbmax[1],bbmax[2]);
glVertex3f(bbmin[0],bbmin[1],bbmax[2]);
glVertex3f(bbmin[0],bbmin[1],bbmin[2]);
glVertex3f(bbmin[0],bbmin[1],bbmax[2]);
glVertex3f(bbmax[0],bbmin[1],bbmin[2]);
glVertex3f(bbmax[0],bbmin[1],bbmax[2]);
glVertex3f(bbmax[0],bbmax[1],bbmin[2]);
glVertex3f(bbmax[0],bbmax[1],bbmax[2]);
glVertex3f(bbmin[0],bbmax[1],bbmin[2]);
glVertex3f(bbmin[0],bbmax[1],bbmax[2]);
glEnd();
glPopAttrib ();
}
}
//=============================================================================
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4826 $
// $Author: dekkers $
// $Date: 2009-02-12 20:50:56 +0100 (Do, 12. Feb 2009) $
//
//=============================================================================
//=============================================================================
//
// CLASS BoundingBoxNode
//
//=============================================================================
#ifndef ACG_BOUNDINGBOXNODE_HH
#define ACG_BOUNDINGBOXNODE_HH
//== INCLUDES =================================================================
#include "MaterialNode.hh"
#include "DrawModes.hh"
#include <vector>
//== NAMESPACES ===============================================================
namespace ACG {
namespace SceneGraph {
//== CLASS DEFINITION =========================================================
/** \class BoundingBoxNode BoundingBoxNode.hh <ACG/Scenegraph/BoundingBoxNode.hh>
BoundingBoxNode renders the bounding box of its childe nodes
**/
class ACGDLLEXPORT BoundingBoxNode : public MaterialNode
{
public:
/// default constructor
BoundingBoxNode( BaseNode* _parent=0,
std::string _name="<BoundingBoxNode>" ) :
MaterialNode(_parent,
_name,
MaterialNode::BaseColor |
MaterialNode::LineWidth)
{
drawMode(DrawModes::WIREFRAME);
}
/// destructor
~BoundingBoxNode() {}
/// static name of this class
ACG_CLASSNAME(BoundingBoxNode);
/// return available draw modes
unsigned int availableDrawModes() const;
/// draw lines and normals
void draw(GLState& _state, unsigned int _drawMode);
};
//=============================================================================
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
#endif // ACG_LINENODE_HH defined
//=============================================================================
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment