Klamp't
0.8.1
|
A "smart" geometry loading class that caches previous geometries, and does not re-load or re-initialize existing collision detection data structures if the item has already been loaded. More...
#include <ManagedGeometry.h>
Public Types | |
typedef std::shared_ptr< Geometry::AnyCollisionGeometry3D > | GeometryPtr |
typedef std::shared_ptr< GLDraw::GeometryAppearance > | AppearancePtr |
Public Member Functions | |
ManagedGeometry (const ManagedGeometry &rhs) | |
Copy constructor is a shallow copy. | |
void | Clear () |
Erases the items in this geometry. | |
bool | Empty () const |
Returns true if the pointer is NULL or the geometry itself is empty. | |
GeometryPtr | CreateEmpty () |
Creates an empty geometry. | |
bool | Load (const std::string &filename) |
Loads a geometry, with caching. | |
bool | LoadNoCache (const std::string &filename) |
Loads a geometry, without caching. | |
bool | IsCached () const |
Returns true if this instance is cached. | |
void | AddToCache (const std::string &filename) |
Adds to cache, if not already in it. | |
const std::string & | CachedFilename () const |
Returns the filename to which this object is cached. | |
void | RemoveFromCache () |
Remove self from cache, if in it. | |
void | TransformGeometry (const Math3D::Matrix4 &xform) |
AppearancePtr | Appearance () const |
Returns the shared appearance data. | |
bool | IsAppearanceShared () const |
void | SetUnique () |
void | SetUniqueAppearance () |
void | OnGeometryChange () |
If the geometry is changed, call this to update the appearance. | |
void | DrawGL () |
Renders the object using OpenGL. | |
bool | IsDynamicGeometry () const |
Returns true if this geometry is connected to a dynamic source. | |
bool | DynamicGeometryUpdate () |
const ManagedGeometry & | operator= (const ManagedGeometry &rhs) |
assignment is a shallow copy | |
operator bool () const | |
bool | operator! () const |
operator GeometryPtr () | |
Dereferencing by cast, pointer access ->, or *. | |
operator GeometryPtr () const | |
GeometryPtr | operator-> () |
const GeometryPtr | operator-> () const |
Geometry::AnyCollisionGeometry3D & | operator* () |
const Geometry::AnyCollisionGeometry3D & | operator* () const |
Static Public Member Functions | |
static ManagedGeometry * | IsCached (const std::string &filename) |
Static Public Attributes | |
static GeometryManager | manager |
Friends | |
class | GeometryManager |
A "smart" geometry loading class that caches previous geometries, and does not re-load or re-initialize existing collision detection data structures if the item has already been loaded.
Note: the standard Load function will load a file if it hasn't been loaded before, or if it has, it will copy the existing data structures from a prior loaded value. If the collision data structure of the prior geometry haven't been created, they will be created and copied to the new geometry.
Note: if you wish to transform a geometry by a non-rigid transformation, you will need to call RemoveFromCache. Otherwise, all subsequent Load calls will load the transformed geometry. Here, the TransformGeometry method of this class does this for you.
Note: geometries are not shared, but rather cached-and-copied. Appearances on the other hand are by default shared. To make an object have its own custom appearance, call SetUniqueAppearance().
Note: the Load / LoadNoCache functions can also accept strings of the form "ros://[ROS_TOPIC]" or "ros:PointCloud2//[ROS_TOPIC]" to load dynamic point clouds from ROS topics. Only PointCloud2 messages are accepted for now.
bool ManagedGeometry::DynamicGeometryUpdate | ( | ) |
Updates dynamic geometry, if an update is available. If no update, returns false
bool ManagedGeometry::IsAppearanceShared | ( | ) | const |
Returns true if there are multiple objects sharing the appearance data. If it is shared, then changing one appearance affects multiple objects.
|
static |
Returns NULL if the file hasn't been cached. Otherwise, returns a prior instance of the geometry.
void ManagedGeometry::SetUnique | ( | ) |
Removes this geometry from the cache and separates its appearance data from all other instances of this object.
void ManagedGeometry::SetUniqueAppearance | ( | ) |
Makes this item have its own appearance data separate from all other instances of this object.
void ManagedGeometry::TransformGeometry | ( | const Math3D::Matrix4 & | xform | ) |
Transforms the geometry (requires removing from cache, and re-initializing collision data).