/* -*- c++ -*-
    Copyright (C) 2003 <ryu@gpul.org>

    This library 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 2.1 of the License, or (at your option) any later version.

    This library 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 this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
/*
 *
 * Copyright (C) 2004 Mekensleep
 *
 *	Mekensleep
 *	24 rue vieille du temple
 *	75004 Paris
 *       licensing@mekensleep.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Authors:
 *  Cedric PINSON <cpinson@freesheep.org>
 *  Loic Dachary <loic@gnu.org>
 *
 */
#ifndef __OSGCAL__SUBMESHSOFTWARE_H__
#define __OSGCAL__SUBMESHSOFTWARE_H__

#include <osg/Geometry>
#include <osgCal/Export>

class CalSubmesh;
class CalRenderer;

namespace osgCal {

class OSGCAL_EXPORT SubMeshSoftware : public osg::Geometry {
protected:
  virtual ~SubMeshSoftware();

public:
  META_Object(osgCal, SubMeshSoftware);

  SubMeshSoftware();
  SubMeshSoftware(CalSubmesh* calSubmesh, CalRenderer* calRenderer);
  SubMeshSoftware(const SubMeshSoftware&, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);

  void create(void);
  void update(void);

  virtual void drawImplementation(osg::State& state) const;
  virtual bool computeBound() const;

  inline virtual bool supports(PrimitiveFunctor&) const { return _supportsPrimitiveFunctor; }

  // no bounding box, no picking if set to false (saves lots of computing)
  inline void setSupportsPrimitiveFunctor(bool supportsPrimitiveFunctor) { _supportsPrimitiveFunctor = supportsPrimitiveFunctor; }
  // the mesh is not drawn ()
  inline void setInvisible(bool invisible) { _invisible = invisible; }

  const std::string& getName(void) { return mName; }
  void setName(const std::string& name) { mName = name; }

  osg::BoundingBox _staticbbox;
protected:

  bool _supportsPrimitiveFunctor;
  bool _invisible;
  CalSubmesh* _calSubmesh;
  CalRenderer* _calRenderer;
  std::string mName;
};

};

#endif
