RenderWObjectContainer class. More...

Inheritance diagram for RenderWObjectContainer:

Public Member Functions

 RenderWObjectContainer (QString wResName="world")
 Constructor. More...
 
virtual ~RenderWObjectContainer ()
 Destructor. More...
 
void applyTexture (QGLContext *gw, QString texts)
 Setup only the Texture. More...
 
void drawSkyGroundBox (QGLContext *)
 Draw a Sky and a Ground (not static because it uses world dimensions) More...
 
const QVector< RenderWObject * > graphics ()
 return all RenderWObject presents More...
 
RenderWObjectoperator[] (const WObject *)
 This operator return the RenderWObject associate with WObject passed. More...
 
void setupColorTexture (QGLContext *, RenderWObject *obj)
 Setup the Color and Texture into the OpenGL Context for RenderWObject passed. More...
 
void setWorld (World *newworld)
 Set the World to render. More...
 
QImage textureImage (QString texture)
 Return the corresponding QImage for the texture name passed. More...
 
- 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 bool addTextureImage (QString filename, QString texturename)
 Add a new texture image associating with it the name specified. More...
 
static RenderWObjectcreateRenderWObjectFor (const WObject *, RenderWObjectContainer *)
 Create a suitable RenderWObject to render the WObject passed. More...
 
static void drawArrow (const wVector &direction, const wVector &start, float radius, float tipRadius, float tipLength, QColor c=Qt::green)
 draw an arrow More...
 
static void drawCone (const wMatrix &mat, float len, float radius, QColor c=Qt::green)
 draw a cone (the main axis is z, mat center is on the base) More...
 
static void drawCylinder (wVector axis, wVector centre, float len, float radius, QColor c=Qt::green)
 draw a cylinder with aligned with axis given More...
 
static void drawCylinder (wVector start, wVector end, float radius, QColor c=Qt::green)
 draw a cylinder from start to end More...
 
static void drawCylinder (const wMatrix &mat, float len, float radius, QColor c=Qt::green)
 draw a cylinder (the main axis is z, mat center is on the lower base) More...
 
static void drawSphere (wVector pos, real radius)
 draw a sphere in position indicate with radius specified More...
 
static void drawTorus (real outRad, real innRad, const wMatrix &mat, real angle=2.0 *PI_GRECO, QColor c=Qt::red)
 draw a Torus More...
 
static void drawTorus (wVector axis, wVector centre, real outRad, real innRad, real angle=2.0 *PI_GRECO)
 draw a Torus More...
 
static void drawWireBox (wVector dims, wMatrix matrix)
 draw a wireframe Box More...
 
static void drawWireBox (wVector min, wVector max, const wMatrix &tm)
 draw a wireframe Box More...
 
static void drawWireBox (wVector min, wVector max)
 draw a wireframe Box More...
 
template<class renderwobject >
static void registerRenderWObjectFor (QString classname)
 template method for register new RenderWObject classes for new WObject More...
 

Protected Member Functions

void addObject (WObject *)
 add an Object More...
 
void removeObject (WObject *)
 remove an Object More...
 
virtual void resourceChanged (QString name, ResourceChangeType changeType)
 The function called when a resource you use is changed. More...
 
Worldworld ()
 return the World. More...
 
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
 
- Protected Member Functions inherited from ResourcesUser
 ResourcesUser (const ResourcesUser &other)
 
virtual void notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0
 
ResourcesUseroperator= (const ResourcesUser &other)
 

Protected Attributes

QMutex mutex
 The mutex protecting accesses to members of this class. More...
 
- Protected Attributes inherited from ResourcesUser
ResourceCollectionHolder m_resources
 

Additional Inherited Members

- Public Types inherited from ResourcesUser
typedef Resource::ResourceChangeType ResourceChangeType
 
- Public Types inherited from Resource
enum  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 168 of file renderworld.h.

Constructor & Destructor Documentation

RenderWObjectContainer ( QString  wResName = "world")

Constructor.

Definition at line 88 of file renderworld.cpp.

References ConcurrentResourcesUser::usableResources().

~RenderWObjectContainer ( )
virtual

Destructor.

Definition at line 102 of file renderworld.cpp.

Member Function Documentation

void addObject ( WObject wobj)
protected

add an Object

Definition at line 156 of file renderworld.cpp.

References RenderWObjectContainer::createRenderWObjectFor(), and RenderWObjectContainer::mutex.

bool addTextureImage ( QString  filename,
QString  texturename 
)
static

Add a new texture image associating with it the name specified.

Parameters
filenamethe path where find the image
texturenamethe 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 115 of file renderworld.cpp.

void applyTexture ( QGLContext *  gw,
QString  texts 
)

Setup only the Texture.

Definition at line 253 of file renderworld.cpp.

References RenderWObjectContainer::mutex.

Referenced by RenderWObjectContainer::drawSkyGroundBox(), and RenderWObjectContainer::setupColorTexture().

RenderWObject * createRenderWObjectFor ( const WObject obj,
RenderWObjectContainer container 
)
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().

void drawArrow ( const wVector direction,
const wVector start,
float  radius,
float  tipRadius,
float  tipLength,
QColor  c = Qt::green 
)
static
void drawCone ( const wMatrix mat,
float  len,
float  radius,
QColor  c = Qt::green 
)
static

draw a cone (the main axis is z, mat center is on the base)

Definition at line 1137 of file renderworld.cpp.

Referenced by RenderWObjectContainer::drawArrow().

void drawCylinder ( wVector  axis,
wVector  centre,
float  len,
float  radius,
QColor  c = Qt::green 
)
static

draw a cylinder with aligned with axis given

Definition at line 1033 of file renderworld.cpp.

References Quaternion::matrix(), and wVectorT< Shared >::scale().

Referenced by RenderWObjectContainer::drawArrow(), and RenderWObjectContainer::drawCylinder().

void drawCylinder ( wVector  start,
wVector  end,
float  radius,
QColor  c = Qt::green 
)
static

draw a cylinder from start to end

Definition at line 1067 of file renderworld.cpp.

References RenderWObjectContainer::drawCylinder().

void drawCylinder ( const wMatrix mat,
float  len,
float  radius,
QColor  c = Qt::green 
)
static

draw a cylinder (the main axis is z, mat center is on the lower base)

Definition at line 1109 of file renderworld.cpp.

void drawSkyGroundBox ( QGLContext *  gw)

Draw a Sky and a Ground (not static because it uses world dimensions)

Definition at line 291 of file renderworld.cpp.

References RenderWObjectContainer::applyTexture(), farsa::max(), farsa::min(), RenderWObjectContainer::mutex, World::size(), and ResourcesLocker::unlock().

Referenced by RenderWorld::draw().

void drawSphere ( wVector  pos,
real  radius 
)
static

draw a sphere in position indicate with radius specified

Definition at line 1008 of file renderworld.cpp.

References wMatrix::identity(), and wVectorT< Shared >::scale().

Referenced by RenderWorld::draw().

void drawTorus ( real  outRad,
real  innRad,
const wMatrix mat,
real  angle = 2.0*PI_GRECO,
QColor  c = Qt::red 
)
static

draw a Torus

Definition at line 1324 of file renderworld.cpp.

void drawTorus ( wVector  axis,
wVector  centre,
real  outRad,
real  innRad,
real  angle = 2.0*PI_GRECO 
)
static

draw a Torus

Definition at line 1359 of file renderworld.cpp.

References wMatrix::grammSchmidt().

void drawWireBox ( wVector  min,
wVector  max,
const wMatrix tm 
)
static

draw a wireframe Box

Definition at line 1248 of file renderworld.cpp.

References RenderWObjectContainer::drawWireBox().

void drawWireBox ( wVector  min,
wVector  max 
)
static

draw a wireframe Box

Definition at line 1255 of file renderworld.cpp.

const QVector<RenderWObject*> graphics ( )
inline
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.

static void registerRenderWObjectFor ( QString  classname)
inlinestatic

template method for register new RenderWObject classes for new WObject

Parameters
classnameis the class name of the WObject that the renderwobject class is delegated to render

Definition at line 204 of file renderworld.h.

void removeObject ( WObject wobj)
protected

remove an Object

Definition at line 164 of file renderworld.cpp.

References RenderWObjectContainer::mutex, and RenderWObject::objectAlreadyDestroyed().

void resourceChanged ( QString  name,
ResourceChangeType  changeType 
)
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
namethe name of the resource that has changed.
chageTypethe 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 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().

QImage textureImage ( QString  texture)
inline

Return the corresponding QImage for the texture name passed.

Definition at line 182 of file renderworld.h.

World* world ( )
inlineprotected

return the World.

World is a resource, so this function is meant to be used only by subclasses

Definition at line 238 of file renderworld.h.

Referenced by RenderWorld::draw(), RenderWorld::init(), and RenderWorld::resourceChanged().

Member Data Documentation


The documentation for this class was generated from the following files: