An helper class to draw stuffs in the world. More...
Public Member Functions | |
GraphicalWObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity()) | |
Constructor. | |
virtual | ~GraphicalWObject () |
Destructor. | |
WObject * | attachedObject () const |
The object to which we are attached. | |
void | attachToObject (WObject *object, bool makeOwner=false, const wMatrix &displacement=wMatrix::identity()) |
Attaches this object to another WObject. | |
const wMatrix & | getDisplacement () const |
Returns the displacement matrix relative to the object to which we are attached. | |
void | setDisplacement (const wMatrix &displacement) |
Sets the displacement matrix relative to the object to which we are attached. | |
void | updateAndCalculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm) |
Returns the min and max points of the Axis-Aligned Bounding Box (AABB) | |
void | updateAndCalculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint) |
Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame. | |
void | updateAndRender (RenderWObject *renderer, QGLContext *gw) |
Performs the actual drawing. | |
void | updateAndRenderAABB (RenderWObject *renderer, RenderWorld *gw) |
The function rendering the Axis-Aligned Bounding Box (AABB) | |
Public Member Functions inherited from WObject | |
WObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity(), bool addToWorld=true) | |
create the object and automatically put this into the world | |
virtual | ~WObject () |
destroy the Object and drop it from the world | |
QColor | color () const |
return the color of this object | |
bool | isInvisible () |
return if it is invisible | |
const wMatrix & | matrix () const |
return a reference to the transformation matrix | |
QString | name () const |
Return the name of this object. | |
virtual void | postUpdate () |
postUpdate the WObject this method is called at each step of the world just after the physic update | |
virtual void | preUpdate () |
preUpdate the WObject this method is called at each step of the world just before the physic update | |
void | setAlpha (int alpha) |
set the value of alpha channel (the transparency) | |
void | setColor (QColor c) |
Set the color to use on rendering. | |
void | setInvisible (bool b) |
set invisibility | |
void | setMatrix (const wMatrix &newm) |
set a new matrix | |
void | setPosition (const wVector &newpos) |
set the position specified in global coordinate frame | |
void | setPosition (real x, real y, real z) |
set the position specified in global coordinate frame | |
void | setTexture (QString textureName) |
Set the texture to use for this WObject when rendered. | |
void | setUseColorTextureOfOwner (bool b) |
set if the object will be rendered with the color and texture of our owner (if we have one) | |
QString | texture () const |
Return the texture name. | |
bool | useColorTextureOfOwner () const |
if true, we will use color and texture of our owner (if we have one) | |
World * | world () |
Return the world. | |
const World * | world () const |
Return the world (const version) | |
Public Member Functions inherited from Ownable | |
Ownable () | |
Constructor. | |
virtual | ~Ownable () |
Destructor. | |
const QList< Owned > & | owned () const |
Returns the list of objects owned by this one. | |
Ownable * | owner () const |
Returns the owner of this object. | |
void | setOwner (Ownable *owner, bool destroy=true) |
Sets the owner of this object. | |
Protected Member Functions | |
virtual void | calculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm) |
Returns the min and max points of the Axis-Aligned Bounding Box (AABB) | |
virtual void | calculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint) |
Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame If there is no meaningful OBB, set dimension, minPoint and maxPoint to (0, 0, 0), as the default implementation does. | |
virtual void | render (RenderWObject *renderer, QGLContext *gw)=0 |
Performs the actual drawing. | |
virtual void | renderAABB (RenderWObject *renderer, RenderWorld *gw) |
The function rendering the Axis-Aligned Bounding Box (AABB) | |
void | updateMatrixFromAttachedObject () |
Updates the transformation matrix from the object to which we are attached (if there is one) | |
Protected Member Functions inherited from WObject | |
virtual void | changedMatrix () |
virtual function called when the transformation matrix change | |
Additional Inherited Members | |
Public Types inherited from Ownable | |
typedef QList< Owned > | OwnedList |
The type for the list of owned objects. | |
Protected Attributes inherited from WObject | |
QColor | colorv |
Color, it contains also alpha channel. | |
bool | invisible |
if TRUE it will not renderized | |
QString | namev |
Name of the WObject. | |
QString | texturev |
Texture name. | |
wMatrix | tm |
Trasformation matrix. | |
bool | usecolortextureofowner |
if true, we will use color and texture of our owner (if we have one). | |
World * | worldv |
World. | |
Detailed Description
An helper class to draw stuffs in the world.
This class is useful to add to the world purely graphical objects. All the drawing can be done directly inside child of this classes (without the need for a separate RenderWObject class). Moreover it is possible to attach object of this type to another WObject: the transformation matrix of this object will be set to be the same as the one of the WObject to which this one is attached when drawing is required. It is also possible to specify a displacement matrix relative to the object to which we are attached: in this case the transformation matrix of this object is set to the combination of the transformation matrix of the object to which we are attached and the displacement matrix when drawing is required
Definition at line 48 of file graphicalwobject.h.
Constructor & Destructor Documentation
GraphicalWObject | ( | World * | world, |
QString | name = "unamed" , |
||
const wMatrix & | tm = wMatrix::identity() |
||
) |
Constructor.
- Parameters
-
world the world the object lives in name the name of this object tm the transformation matrix for this object
Definition at line 28 of file graphicalwobject.cpp.
|
virtual |
Destructor.
Definition at line 38 of file graphicalwobject.cpp.
Member Function Documentation
|
inline |
The object to which we are attached.
- Returns
- the object to which we are attached
Definition at line 88 of file graphicalwobject.h.
void attachToObject | ( | WObject * | object, |
bool | makeOwner = false , |
||
const wMatrix & | displacement = wMatrix::identity() |
||
) |
Attaches this object to another WObject.
When we are attached to an object, our transformation matrix is set to the one of the object to which we are attached before drawing is performed
- Parameters
-
object the WObject to which we are attached. If NULL we are not attached to any object makeOwner if true object is made the owner of this so that when object is destroyed this one is destroyed too displacement the transformation matrix relative to the object to which we are attached. This matrix is ignored if we are not attached to any object
Definition at line 43 of file graphicalwobject.cpp.
References Ownable::setOwner().
Referenced by PhyMarXbot::setDrawFrontMarker(), PhyKhepera::setDrawFrontMarker(), PhyEpuck::setDrawFrontMarker(), and SingleIRGraphic::SingleIRGraphic().
Returns the min and max points of the Axis-Aligned Bounding Box (AABB)
If there is no meaningful AABB, set both minPoint and maxPoint to (0, 0, 0), as the default implementation does
- Parameters
-
minPoint the minimum point of the AABB maxPoint the maximum point of the AABB tm the transformation matrix with respect to which the minPoint and maxPoint of AABB have to be calculated
Definition at line 93 of file graphicalwobject.cpp.
Referenced by GraphicalWObject::updateAndCalculateAABB().
Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame If there is no meaningful OBB, set dimension, minPoint and maxPoint to (0, 0, 0), as the default implementation does.
- Parameters
-
dimension the dimension of the OBB minPoint the minimum point of the OBB maxPoint the maximum point of the OBB
Definition at line 100 of file graphicalwobject.cpp.
Referenced by GraphicalWObject::updateAndCalculateOBB().
|
inline |
Returns the displacement matrix relative to the object to which we are attached.
This matrix is ignored if we are not attached to any object
- Returns
- the displacement matrix relative to the object to which we are attached
Definition at line 111 of file graphicalwobject.h.
|
protectedpure virtual |
Performs the actual drawing.
Reimplement to draw what you need
- Parameters
-
renderer the RenderWObject object associated with this one. Use it e.g. to access the container gw the OpenGL context
Implemented in SingleIRGraphic, PlanarArrowGraphicalMarker, and CircularGraphicalMarker.
Referenced by GraphicalWObject::updateAndRender().
|
protectedvirtual |
The function rendering the Axis-Aligned Bounding Box (AABB)
The default implementation does nothing
- Parameters
-
renderer the RenderWObject object associated with this one. Use it e.g. to access the container gw the object rendering the world
Definition at line 88 of file graphicalwobject.cpp.
Referenced by GraphicalWObject::updateAndRenderAABB().
void setDisplacement | ( | const wMatrix & | displacement | ) |
Sets the displacement matrix relative to the object to which we are attached.
This matrix is ignored if we are not attached to any object
- Parameters
-
displacement the displacement matrix relative to the object to which we are attached
Definition at line 55 of file graphicalwobject.cpp.
Returns the min and max points of the Axis-Aligned Bounding Box (AABB)
This calls the calculateAABB() function after updating the transformation matrix. See the description of that function for more details
- Parameters
-
minPoint the minimum point of the AABB maxPoint the maximum point of the AABB tm the transformation matrix with respect to which the minPoint and maxPoint of AABB have to be calculated
Definition at line 74 of file graphicalwobject.cpp.
References GraphicalWObject::calculateAABB(), and GraphicalWObject::updateMatrixFromAttachedObject().
Referenced by GraphicalWObjectRenderer::calculateAABB().
Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame.
This calls the calculateOBB() function after updating the transformation matrix. See the description of that function for more details
- Parameters
-
dimension the dimension of the OBB minPoint the minimum point of the OBB maxPoint the maximum point of the OBB
Definition at line 81 of file graphicalwobject.cpp.
References GraphicalWObject::calculateOBB(), and GraphicalWObject::updateMatrixFromAttachedObject().
Referenced by GraphicalWObjectRenderer::calculateOBB().
void updateAndRender | ( | RenderWObject * | renderer, |
QGLContext * | gw | ||
) |
Performs the actual drawing.
This calls the render() function after updating the transformation matrix. See the description of that function for more details
- Parameters
-
renderer the RenderWObject object associated with this one. Use it e.g. to access the container gw the OpenGL context
Definition at line 60 of file graphicalwobject.cpp.
References GraphicalWObject::render(), and GraphicalWObject::updateMatrixFromAttachedObject().
void updateAndRenderAABB | ( | RenderWObject * | renderer, |
RenderWorld * | gw | ||
) |
The function rendering the Axis-Aligned Bounding Box (AABB)
This calls the renderAABB() function after updating the transformation matrix. See the description of that function for more details
- Parameters
-
renderer the RenderWObject object associated with this one. Use it e.g. to access the container gw the object rendering the world
Definition at line 67 of file graphicalwobject.cpp.
References GraphicalWObject::renderAABB(), and GraphicalWObject::updateMatrixFromAttachedObject().
Referenced by GraphicalWObjectRenderer::renderAABB().
|
protected |
Updates the transformation matrix from the object to which we are attached (if there is one)
Definition at line 108 of file graphicalwobject.cpp.
References WObject::matrix(), and WObject::setMatrix().
Referenced by GraphicalWObject::updateAndCalculateAABB(), GraphicalWObject::updateAndCalculateOBB(), GraphicalWObject::updateAndRender(), and GraphicalWObject::updateAndRenderAABB().
The documentation for this class was generated from the following files:
- worldsim/include/graphicalwobject.h
- worldsim/src/graphicalwobject.cpp