RenderWObjectContainer class. More...

Inheritance diagram for RenderWObjectContainer:

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
 
RenderWObjectoperator[] (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 RenderWObjectcreateRenderWObjectFor (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.
 
Worldworld ()
 return the World.
 
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
 
ResourcesUseroperator= (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
 
ResourcesUseroperator= (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().

~RenderWObjectContainer ( )
virtual

Destructor.

Definition at line 106 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 
)

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 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().

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 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 937 of file renderworld.cpp.

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

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

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().

void drawCylinder ( const wMatrix mat,
float  len,
float  radius,
QColor  c = Qt::green 
)
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().

void drawSphere ( wVector  pos,
real  radius 
)
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().

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 1173 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 1208 of file renderworld.cpp.

References wMatrix::grammSchmidt().

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

draw a wireframe Box

Definition at line 1097 of file renderworld.cpp.

References RenderWObjectContainer::drawWireBox().

void drawWireBox ( wVector  min,
wVector  max 
)
static

draw a wireframe Box

Definition at line 1104 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 197 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().

Referenced by WCamera::WCamera().

QImage textureImage ( QString  texture)
inline

Return the corresponding QImage for the texture name passed.

Definition at line 175 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 227 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: