RenderWObjectContainer class. More...
Public Member Functions | |
RenderWObjectContainer (QString wResName="world") | |
Constructor. | |
virtual | ~RenderWObjectContainer () |
Destructor. | |
bool | addTextureImage (QString filename, QString texturename) |
Add a new texture image associating with it the name specified. | |
void | applyTexture (QGLContext *gw, QString texts) |
Setup only the Texture. | |
void | drawSkyGroundBox (QGLContext *) |
Draw a Sky and a Ground (not static because it uses world dimensions) | |
const QVector< RenderWObject * > | graphics () |
return all RenderWObject presents | |
RenderWObject * | operator[] (const WObject *) |
This operator return the RenderWObject associate with WObject passed. | |
void | setupColorTexture (QGLContext *, RenderWObject *obj) |
Setup the Color and Texture into the OpenGL Context for RenderWObject passed. | |
void | setWorld (World *newworld) |
Set the World to render. | |
QImage | textureImage (QString texture) |
Return the corresponding QImage for the texture name passed. | |
Public Member Functions inherited from ConcurrentResourcesUser | |
void | addUsableResource (QString resource) |
void | addUsableResources (QStringList resources) |
void | declareResource (QString name, T *resource, QString lockBuddy="") |
void | deleteResource (QString name) |
T * | getResource (QString name, bool *resourceExists=NULL) |
bool | hasResource (QString name) const |
void | removeAllUsableResources () |
void | removeUsableResource (QString resource) |
void | removeUsableResources (QStringList resources) |
virtual void | shareResourcesWith (ResourcesUser *buddy) |
void | usableResources (QStringList resources) |
bool | usedResourcesExist (QStringList *nonExistingResources=NULL) const |
Static Public Member Functions | |
static RenderWObject * | createRenderWObjectFor (const WObject *, RenderWObjectContainer *) |
Create a suitable RenderWObject to render the WObject passed. | |
static void | drawCylinder (wVector axis, wVector centre, float len, float radius, QColor c=Qt::green) |
draw a cylinder with aligned with axis given | |
static void | drawCylinder (wVector start, wVector end, float radius, QColor c=Qt::green) |
draw a cylinder from start to end | |
static void | drawCylinder (const wMatrix &mat, float len, float radius, QColor c=Qt::green) |
draw a cylinder | |
static void | drawSphere (wVector pos, real radius) |
draw a sphere in position indicate with radius specified | |
static void | drawTorus (real outRad, real innRad, const wMatrix &mat, real angle=2.0 *PI_GRECO, QColor c=Qt::red) |
draw a Torus | |
static void | drawTorus (wVector axis, wVector centre, real outRad, real innRad, real angle=2.0 *PI_GRECO) |
draw a Torus | |
static void | drawWireBox (wVector dims, wMatrix matrix) |
draw a wireframe Box | |
static void | drawWireBox (wVector min, wVector max, const wMatrix &tm) |
draw a wireframe Box | |
static void | drawWireBox (wVector min, wVector max) |
draw a wireframe Box | |
template<class renderwobject > | |
static void | registerRenderWObjectFor (QString classname) |
template method for register new RenderWObject classes for new WObject | |
Protected Member Functions | |
void | addObject (WObject *) |
add an Object | |
void | removeObject (WObject *) |
remove an Object | |
virtual void | resourceChanged (QString name, ResourceChangeType changeType) |
The function called when a resource you use is changed. | |
World * | world () |
return the World. | |
Protected Member Functions inherited from ConcurrentResourcesUser | |
T * | getResource () |
ResourcesUser & | operator= (const ResourcesUser &other) |
ResourcesUser () | |
ResourcesUser (const ResourcesUser &other) | |
Protected Member Functions inherited from ResourcesUser | |
ResourcesUser (const ResourcesUser &other) | |
virtual void | notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0 |
ResourcesUser & | operator= (const ResourcesUser &other) |
Protected Attributes | |
QMutex | mutex |
The mutex protecting accesses to members of this class. | |
Protected Attributes inherited from ConcurrentResourcesUser | |
ResourceCollectionHolder | m_resources |
Protected Attributes inherited from ResourcesUser | |
ResourceCollectionHolder | m_resources |
Additional Inherited Members | |
Public Types inherited from ConcurrentResourcesUser | |
typedef Resource::ResourceChangeType | ResourceChangeType |
Detailed Description
RenderWObjectContainer class.
This class is thread-safe
- Motivation
- This class implement a common interface among 3D viewers, cameras, etc.
- Description
- Description
- Warnings
- The world is a resource, here. If you use the resource system, simply pass to the constructor the name of the resource with the world; if you don't use the resource system, use the setWorld function (which internally creates a resource). DO NOT use setWorld if you use resources!!!
Definition at line 161 of file renderworld.h.
Constructor & Destructor Documentation
RenderWObjectContainer | ( | QString | wResName = "world" | ) |
Constructor.
Definition at line 58 of file renderworld.cpp.
References ConcurrentResourcesUser::usableResources().
|
virtual |
Destructor.
Definition at line 106 of file renderworld.cpp.
Member Function Documentation
|
protected |
add an Object
Definition at line 156 of file renderworld.cpp.
References RenderWObjectContainer::createRenderWObjectFor(), and RenderWObjectContainer::mutex.
bool addTextureImage | ( | QString | filename, |
QString | texturename | ||
) |
Add a new texture image associating with it the name specified.
- Parameters
-
filename the path where find the image texturename the name associated with this texture (see WObject::texture)
- Returns
- true if the image has been successfull loaded.
- Warning
- it does not check if a texturename already exists and it always overwrite previous data stored
- Note
- it return true if it loads the image file, but this not assure that it is visualizable on openGL context.
Definition at line 117 of file renderworld.cpp.
References RenderWObjectContainer::mutex.
void applyTexture | ( | QGLContext * | gw, |
QString | texts | ||
) |
Setup only the Texture.
Definition at line 211 of file renderworld.cpp.
References RenderWObjectContainer::mutex.
Referenced by RenderWObjectContainer::drawSkyGroundBox(), and RenderWObjectContainer::setupColorTexture().
|
static |
Create a suitable RenderWObject to render the WObject passed.
- Warning
- this method will not automatically add the RenderWObject to the list of RenderWObject rendered by this object
Definition at line 140 of file renderworld.cpp.
Referenced by RenderWObjectContainer::addObject(), and RenderWObjectContainer::resourceChanged().
|
static |
draw a cylinder with aligned with axis given
Definition at line 937 of file renderworld.cpp.
References Quaternion::matrix(), and wVectorT< Shared >::scale().
draw a cylinder from start to end
Definition at line 971 of file renderworld.cpp.
References wVectorT< false >::distance(), wMatrix::grammSchmidt(), and wVectorT< Shared >::normalize().
|
static |
draw a cylinder
Definition at line 1006 of file renderworld.cpp.
void drawSkyGroundBox | ( | QGLContext * | gw | ) |
Draw a Sky and a Ground (not static because it uses world dimensions)
Definition at line 248 of file renderworld.cpp.
References RenderWObjectContainer::applyTexture(), farsa::max(), farsa::min(), RenderWObjectContainer::mutex, World::size(), and ResourcesLocker::unlock().
Referenced by RenderWorld::draw(), and RenderCamera::paintGL().
|
static |
draw a sphere in position indicate with radius specified
Definition at line 912 of file renderworld.cpp.
References wMatrix::identity(), and wVectorT< Shared >::scale().
Referenced by RenderWorld::draw().
|
static |
draw a Torus
Definition at line 1173 of file renderworld.cpp.
draw a wireframe Box
Definition at line 1034 of file renderworld.cpp.
Referenced by RenderWorld::draw(), RenderWObjectContainer::drawWireBox(), RenderGenericObject::renderAABB(), RenderPhyBox::renderAABB(), RenderPhySphere::renderAABB(), RenderPhyCylinder::renderAABB(), RenderPhyCone::renderAABB(), RenderCompoundObject::renderAABB(), and RenderWCamera::renderAABB().
draw a wireframe Box
Definition at line 1097 of file renderworld.cpp.
References RenderWObjectContainer::drawWireBox().
draw a wireframe Box
Definition at line 1104 of file renderworld.cpp.
|
inline |
return all RenderWObject presents
Definition at line 168 of file renderworld.h.
Referenced by RenderWorld::draw(), RenderWorld::drawWithNames(), RenderCamera::paintGL(), RenderWorld::postSelection(), and SimpleControl::updateInfoObject().
RenderWObject * operator[] | ( | const WObject * | obj | ) |
This operator return the RenderWObject associate with WObject passed.
Definition at line 128 of file renderworld.cpp.
References RenderWObjectContainer::mutex.
|
inlinestatic |
template method for register new RenderWObject classes for new WObject
- Parameters
-
classname is the class name of the WObject that the renderwobject class is delegated to render
Definition at line 197 of file renderworld.h.
|
protected |
remove an Object
Definition at line 164 of file renderworld.cpp.
References RenderWObjectContainer::mutex, and RenderWObject::objectAlreadyDestroyed().
|
protectedvirtual |
The function called when a resource you use is changed.
When this function is called, the lock on the resource is acquired, so you can safely call getResource(). Note however that only the resource being changed is locked, a getResource() on other resources will fail because the lock on them is not acquired. Of course no lock is acquired if the resource was deleted. The default implementation of this function does nothing
- Parameters
-
name the name of the resource that has changed. chageType the type of change the resource has gone through (whether it was created, modified or deleted)
- Note
- In multithread applications this function could be called from a thread different from the one this object lives in
Reimplemented from ConcurrentResourcesUser.
Reimplemented in RenderWorld.
Definition at line 180 of file renderworld.cpp.
References RenderWObjectContainer::createRenderWObjectFor(), RenderWObjectContainer::mutex, and World::objects().
Referenced by RenderWorld::resourceChanged().
void setupColorTexture | ( | QGLContext * | gw, |
RenderWObject * | obj | ||
) |
Setup the Color and Texture into the OpenGL Context for RenderWObject passed.
Definition at line 225 of file renderworld.cpp.
References RenderWObjectContainer::applyTexture(), WObject::color(), RenderWObjectContainer::mutex, RenderWObject::object(), Ownable::owner(), WObject::texture(), and WObject::useColorTextureOfOwner().
Referenced by CircularGraphicalMarker::render(), PlanarArrowGraphicalMarker::render(), and SingleIRGraphic::render().
void setWorld | ( | World * | newworld | ) |
Set the World to render.
World can be NULL. Use this function only if you do not use resources. This internally declares a resource
Definition at line 123 of file renderworld.cpp.
References ConcurrentResourcesUser::declareResource().
Referenced by WCamera::WCamera().
|
inline |
Return the corresponding QImage for the texture name passed.
Definition at line 175 of file renderworld.h.
|
inlineprotected |
return the World.
World is a resource, so this function is meant to be used only by subclasses
Definition at line 227 of file renderworld.h.
Referenced by RenderWorld::draw(), RenderWorld::init(), and RenderWorld::resourceChanged().
Member Data Documentation
|
protected |
The mutex protecting accesses to members of this class.
Definition at line 254 of file renderworld.h.
Referenced by RenderWObjectContainer::addObject(), RenderWObjectContainer::addTextureImage(), RenderWObjectContainer::applyTexture(), RenderWorld::draw(), RenderWObjectContainer::drawSkyGroundBox(), RenderWorld::drawWithNames(), RenderWorld::init(), RenderWorld::keyPressEvent(), RenderCamera::moveRotatePointOfView(), RenderWObjectContainer::operator[](), RenderCamera::paintGL(), RenderWorld::postSelection(), RenderWObjectContainer::removeObject(), RenderWObjectContainer::resourceChanged(), RenderWorld::resourceChanged(), RenderWObjectContainer::setupColorTexture(), RenderWorld::showAABBs(), RenderWorld::showContacts(), RenderWorld::showForces(), RenderWorld::showJoints(), RenderWorld::showObjects(), RenderWorld::showSkyGround(), and RenderWorld::wireframe().
The documentation for this class was generated from the following files:
- worldsim/include/renderworld.h
- worldsim/src/renderwobjecthierarchy.cpp
- worldsim/src/renderworld.cpp