Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

physics/LODTerrain

Go to the documentation of this file.
00001 /****************************************************************************
00002   Copyright (C)1996 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   
00018   $Id: LODTerrain 1031 2004-02-11 20:46:36Z jungd $
00019   $Revision: 1.3 $
00020   $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022   
00023 ****************************************************************************/
00024 
00025 #ifndef _PHYSICS_LODTERRAIN_
00026 #define _PHYSICS_LODTERRAIN_
00027 
00028 #include <physics/physics>
00029 #include <physics/Terrain>
00030 #include <gfx/CLODTerrainRenderer>
00031 #include <gfx/CLODTerrainDrawable>
00032 
00033 #include <osg/Geode>
00034 
00035 
00036 namespace physics {
00037 
00038 
00039 class LODTerrain : virtual public Terrain
00040 {
00041 public:
00042   LODTerrain();
00043   LODTerrain(const LODTerrain& t);
00044   virtual ~LODTerrain();
00045 
00046   virtual String className() const { return String("LODTerrain"); }
00047 
00048   // Terrain
00049   virtual void loadMap(ref<base::VFile> mapfile) throw(std::invalid_argument, base::io_error);
00050   virtual void loadHeightField(ref<HeightField> heightfield) throw(std::invalid_argument, base::io_error);
00051 
00052   virtual void setHeight(Real x, Real y, Real h) throw(std::out_of_range);
00053   virtual Real getHeight(Real x, Real y) const   throw(std::out_of_range);
00054   virtual base::Dimension3 getDimension() const;
00055 
00056   // Shape
00057   virtual base::Object& clone() const { return *NewNamedObj(className()) LODTerrain(*this); }
00058   virtual BoundingBox    getBoundingBox() const;
00059   virtual BoundingSphere getBoundingSphere() const;
00060   virtual const MassProperties& getMassProperties(ref<const Material> material) const;
00061 
00062   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const Point3& p) const;
00063   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Segment3& s) const;
00064   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Triangle3& tri) const;
00065   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Quad3& q) const;
00066   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t1, ref<const Shape> s, const base::Transform& t2) const;
00067 
00068   // CollisionModelProvider
00069   virtual ref<CollisionModel> getCollisionModel(CollisionModel::CollisionModelType modelType) const;
00070 
00071   // Visual
00072   virtual bool visualTypeSupported(VisualType type) const { return (type==OSGVisual); }
00073   virtual osg::Node* createOSGVisual(Attributes visualAttributes=0) const;
00074 
00075   virtual void serialize(base::Serializer& s);
00076 
00077   // Externalizable
00078   virtual bool formatSupported(String format, Real version = 1.0, ExternalizationType type = IO) const;
00079   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00080   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00081     { Externalizable::externalize(e,format,version); }
00082    
00083 private:
00084   osg::ref_ptr<gfx::CLODTerrainRenderer> renderer;
00085   osg::ref_ptr<gfx::CLODTerrainDrawable> drawable;
00086 
00087   mutable bool massPropertiesCached;
00088   mutable Real density;
00089   mutable MassProperties massProperties;
00090 
00091   mutable Visual::Attributes attributes;
00092   mutable ref_ptr<osg::Node> node;
00093 
00094   mutable ref<CollisionModel> collisionModel;
00095   mutable CollisionModel::CollisionModelType modelType;
00096 
00097   mutable bool boundsCached;
00098   mutable BoundingBox    boundingBox;
00099   mutable BoundingSphere boundingSphere;
00100   
00101   void computeBounds() const;
00102 };
00103 
00104 
00105 } // physics
00106 
00107 #endif

Generated on Thu Jul 29 15:56:24 2004 for OpenSim by doxygen 1.3.6