00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
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
00069 virtual ref<CollisionModel> getCollisionModel(CollisionModel::CollisionModelType modelType) const;
00070
00071
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
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 }
00106
00107 #endif