1 #ifndef KLAMPT_MODELING_MANAGED_GEOMETRY_H 2 #define KLAMPT_MODELING_MANAGED_GEOMETRY_H 4 #include <KrisLibrary/geometry/AnyGeometry.h> 5 #include <KrisLibrary/GLdraw/GeometryAppearance.h> 12 class GeometryManager;
65 typedef std::shared_ptr<Geometry::AnyCollisionGeometry3D> GeometryPtr;
66 typedef std::shared_ptr<GLDraw::GeometryAppearance> AppearancePtr;
79 bool Load(
const std::string& filename);
123 operator bool()
const {
return geometry != NULL; }
124 bool operator !()
const {
return geometry == NULL; }
126 operator GeometryPtr() {
return geometry; }
127 operator GeometryPtr()
const {
return geometry; }
128 GeometryPtr operator ->() {
return geometry; }
129 const GeometryPtr operator ->()
const {
return geometry; }
130 inline Geometry::AnyCollisionGeometry3D& operator *() {
return *geometry; }
131 inline const Geometry::AnyCollisionGeometry3D& operator *()
const {
return *geometry; }
137 std::string cacheKey,dynamicGeometrySource;
138 GeometryPtr geometry;
139 AppearancePtr appearance;
152 std::vector<ManagedGeometry*> geoms;
154 std::map<std::string,GeometryList> cache;
void AddToCache(const std::string &filename)
Adds to cache, if not already in it.
void DrawGL()
Renders the object using OpenGL.
void DrawGLOpaque(bool opaque)
Renders the opaque parts of the object using OpenGL.
void OnGeometryChange()
If the geometry is changed, call this to update the appearance.
GeometryPtr CreateEmpty()
Creates an empty geometry.
bool Load(const std::string &filename)
Loads a geometry, with caching.
AppearancePtr Appearance() const
Returns the shared appearance data.
void Clear()
Erases the items in this geometry.
bool DynamicGeometryUpdate()
Definition: ManagedGeometry.h:150
bool IsOriginal() const
Returns true if this instance is cached and is identical to a file on disk.
bool IsCached() const
Returns true if this instance is cached.
void SetUniqueAppearance()
A "smart" geometry loading class that caches previous geometries and maintains shared collision detec...
Definition: ManagedGeometry.h:62
bool Empty() const
Returns true if the pointer is NULL or the geometry itself is empty.
bool LoadNoCache(const std::string &filename)
Loads a geometry, without caching.
Definition: ManagedGeometry.h:142
const ManagedGeometry & operator=(const ManagedGeometry &rhs)
assignment is a shallow copy
void RemoveFromCache()
Remove self from cache, if in it.
void TransformGeometry(const Math3D::Matrix4 &xform)
bool IsAppearanceShared() const
const std::string & CachedFilename() const
Returns the filename to which this object is cached.
bool IsDynamicGeometry() const
Returns true if this geometry is connected to a dynamic source.
Definition: ContactDistance.h:6