OpenWalnut  1.4.0
WGESubdividedPlane.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WGESUBDIVIDEDPLANE_H
00026 #define WGESUBDIVIDEDPLANE_H
00027 
00028 #include <osg/Geode>
00029 
00030 /**
00031  * Represents a plane which is subdivided into quads where each quad primitive is colorable.
00032  */
00033 class WGESubdividedPlane : public osg::Geode
00034 {
00035 public:
00036     /**
00037      * For each quad primitive, the center point is computed and stored in \ref m_quadCenters.
00038      *
00039      * \param centers the vertex array of the center points of each quad in same order as the quads
00040      */
00041     void setCenterArray( osg::ref_ptr< osg::Vec3Array > centers );
00042 
00043     /**
00044      * Gives the reference to the centerpoints of the quads this plane is representing.
00045      *
00046      * \return Const reference to the center points
00047      */
00048     osg::ref_ptr< const osg::Vec3Array > getCenterArray() const;
00049 
00050 protected:
00051 private:
00052     /**
00053      * Stores the center points of each quad. This is saved in this geode, so the center points are
00054      * available before transformation.
00055      */
00056     osg::ref_ptr< osg::Vec3Array > m_quadCenters;
00057 };
00058 
00059 inline void WGESubdividedPlane::setCenterArray( osg::ref_ptr< osg::Vec3Array > centers )
00060 {
00061     // TODO(math): do some constraint checks
00062     m_quadCenters = centers;
00063 }
00064 
00065 inline osg::ref_ptr< const osg::Vec3Array > WGESubdividedPlane::getCenterArray() const
00066 {
00067     return m_quadCenters;
00068 }
00069 
00070 #endif  // WGESUBDIVIDEDPLANE_H