PhyCylinder class. More...

Inheritance diagram for PhyCylinder:

Classes

struct  SegmentColor
 The structure used to define the color of intervals of the cylinder. More...
 

Public Member Functions

 PhyCylinder (real radius, real height, World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity())
 Create a physics cylinder object and insert it in the world passed. More...
 
virtual ~PhyCylinder ()
 Destroy this object. More...
 
bool graphicalRepresentationNeedsUpdate (void *renderer=NULL)
 Whether the graphical representation should be updated or not. More...
 
real height () const
 return the height More...
 
const QColor & lowerBaseColor () const
 Returns the color of the lower base. More...
 
real radius () const
 return the radius More...
 
const QList< SegmentColor > & segmentsColor () const
 Returns the color of segments of the cylinder. More...
 
void setLowerBaseColor (QColor color)
 Sets the color of the lower base. More...
 
void setSegmentsColor (QColor base, const QList< SegmentColor > &segmentsColor)
 Sets the color of segments of the cylinder. More...
 
void setUpperBaseColor (QColor color)
 Sets the color of the upper base. More...
 
const QColor & upperBaseColor () const
 Returns the color of the upper base. More...
 
- Public Member Functions inherited from PhyObject
 PhyObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity(), bool cp=true)
 Create a physics object with no-collision-shape and insert it in the world passed. More...
 
virtual ~PhyObject ()
 Destroy this object. More...
 
void addForce (const wVector &force)
 
void addImpulse (const wVector &pointDeltaVeloc, const wVector &pointPosit)
 
void addTorque (const wVector &torque)
 
wVector force ()
 
bool getKinematic () const
 Returns true if the object has kinematic behaviour. More...
 
bool getStatic () const
 Returns true if the object is static. More...
 
wVector inertiaVec () const
 
wVector invInertiaVec () const
 Return the inverse of Inertia. More...
 
wVector invMassInertiaVec () const
 
bool isCollidable () const
 Returns true if this object collides with other object. More...
 
real mass ()
 Return the mass. More...
 
wVector massInertiaVec () const
 Return the Mass and momentum of Inertia. More...
 
QString material () const
 
wVector omega ()
 
void reset ()
 reset the object:

set the velocity to zero

set the angural velocity to zero

set any residual forces and torques to zero

remove any pending collision

More...
 
void setForce (const wVector &force)
 
void setKinematic (bool b, bool c=false)
 Changes between kinematic/dynamic behaviour for the object. More...
 
void setMass (real)
 Set the mass without touching the Inertia data. More...
 
void setMassInertiaVec (const wVector &)
 Set the Mass and momentum of Inertia: ( mass, Ixx, Iyy, Izz ) More...
 
void setMaterial (QString material)
 
void setOmega (const wVector &omega)
 
void setStatic (bool b)
 Makes the object static or not. More...
 
void setTorque (const wVector &torque)
 
void setVelocity (const wVector &velocity)
 
wVector torque ()
 
wVector velocity ()
 
- 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 More...
 
virtual ~WObject ()
 destroy the Object and drop it from the world More...
 
QColor color () const
 return the color of this object More...
 
void drawLocalAxes (bool d)
 Sets whether the object local frame of reference should be drawn or not. More...
 
bool isInvisible () const
 return if it is invisible More...
 
const QString & label () const
 Returns the text label to render along with the object. More...
 
const QColor & labelColor () const
 Returns the color of the label. More...
 
const wVectorlabelPosition () const
 Returns the label position relative to this object. More...
 
bool labelShown () const
 Returns whether the label is shown or not. More...
 
bool localAxesDrawn () const
 Returns true if the local frame of refecence of the object should be drawn. More...
 
const wMatrixmatrix () const
 return a reference to the transformation matrix More...
 
QString name () const
 Return the name of this object. More...
 
virtual void postUpdate ()
 postUpdate the WObject this method is called at each step of the world just after the physic update More...
 
virtual void preUpdate ()
 preUpdate the WObject this method is called at each step of the world just before the physic update More...
 
void setAlpha (int alpha)
 set the value of alpha channel (the transparency) More...
 
void setColor (QColor c)
 Set the color to use on rendering. More...
 
void setInvisible (bool b)
 set invisibility More...
 
void setLabel (QString label)
 Sets a text label to render along with the object. More...
 
void setLabel (QString label, wVector pos)
 Sets a text label to render along with the object and its position. More...
 
void setLabel (QString label, wVector pos, QColor color)
 Sets a text label to render along with the object and its position and color. More...
 
void setLabelColor (const QColor &color)
 Sets the color of the label. More...
 
void setLabelPosition (const wVector &pos)
 Sets the label position relative to this object. More...
 
void setMatrix (const wMatrix &newm)
 set a new matrix More...
 
void setPosition (const wVector &newpos)
 set the position specified in global coordinate frame More...
 
void setPosition (real x, real y, real z)
 set the position specified in global coordinate frame More...
 
void setTexture (QString textureName)
 Set the texture to use for this WObject when rendered. More...
 
void setUseColorTextureOfOwner (bool b)
 set if the object will be rendered with the color and texture of our owner (if we have one) More...
 
void showLabel (bool show)
 Sets whether to show the label or not. More...
 
QString texture () const
 Return the texture name. More...
 
bool useColorTextureOfOwner () const
 if true, we will use color and texture of our owner (if we have one) More...
 
Worldworld ()
 Return the world. More...
 
const Worldworld () const
 Return the world (const version) More...
 
- Public Member Functions inherited from Ownable
 Ownable ()
 Constructor. More...
 
virtual ~Ownable ()
 Destructor. More...
 
const QList< Owned > & owned () const
 Returns the list of objects owned by this one. More...
 
Ownableowner () const
 Returns the owner of this object. More...
 
void setOwner (Ownable *owner, bool destroy=true)
 Sets the owner of this object. More...
 

Protected Member Functions

void createPrivateObject ()
 Engine encapsulation. More...
 
- Protected Member Functions inherited from PhyObject
virtual void changedMatrix ()
 syncronize this object with underlying physic object More...
 
void createPrivateObject ()
 

Additional Inherited Members

- Public Types inherited from Ownable
typedef QList< OwnedOwnedList
 The type for the list of owned objects. More...
 
- Protected Attributes inherited from PhyObject
PhyObjectPrivate * priv
 Engine encapsulation. More...
 
WorldPrivate * worldpriv
 
- Protected Attributes inherited from WObject
QColor colorv
 Color, it contains also alpha channel. More...
 
bool invisible
 if TRUE it will not renderized More...
 
QColor labelcol
 The color of the label. More...
 
bool labeldrawn
 Whether the label should be rendered or not. More...
 
wVector labelpos
 The position of the label in the object frame of reference. More...
 
QString labelv
 The text label of the object. More...
 
bool localFrameOfReferenceDrawn
 If true, the local frame of reference of the object is drawn. More...
 
QString namev
 Name of the WObject. More...
 
QString texturev
 Texture name. More...
 
wMatrix tm
 Trasformation matrix. More...
 
bool usecolortextureofowner
 if true, we will use color and texture of our owner (if we have one). More...
 
Worldworldv
 World. More...
 

Detailed Description

PhyCylinder class.

Motivation
Represent a physical cylinder object.
Description
The cylinder is described by the radius and the height. The local frame of reference has the x axis along the line connecting the center of the two bases and the center of the frame is in the middle of that line. For this object you can either specify a single color (using methods inherited from WObject) or you can use functions provided here to separately specify the colors of the two bases and of sectors of the cylinder (see function description for more information). If you use functions specific to this class, the color of the object retuned by WObject::color() will be invalid. To set a single color for the whole cylinder, simply use WObject::setColor with a valid color. More precisely, as soon as you use one of the functions defined here to set colors (setUpperBaseColor, setLowerBaseColor or setSegmentsColor) those colors are used to draw the cylinder and the WObject::color property is set to an invalid color (the color of other parts of the cylinder are set to WObject::color before making it invalid); if you explicitly use WObject::setColor, the cylinder is drawn with a single color
Warnings
Warnings

Definition at line 53 of file phycylinder.h.

Constructor & Destructor Documentation

PhyCylinder ( real  radius,
real  height,
World world,
QString  name = "unamed",
const wMatrix tm = wMatrix::identity() 
)

Create a physics cylinder object and insert it in the world passed.

Parameters
radiusradius of cylinder
heightthe height of cylinder (cylinder 'grows up' along its local X axis)
worldThe World which object will be inserted
tmrotation and position at the moment of creation

Definition at line 27 of file phycylinder.cpp.

References PhyObject::changedMatrix(), WObject::colorv, and PhyCylinder::createPrivateObject().

~PhyCylinder ( )
virtual

Destroy this object.

Definition at line 45 of file phycylinder.cpp.

Member Function Documentation

void createPrivateObject ( )
protected

Engine encapsulation.

Definition at line 196 of file phycylinder.cpp.

References wMatrix::identity(), PhyObject::priv, and PhyObject::setMass().

Referenced by PhyCylinder::PhyCylinder().

bool graphicalRepresentationNeedsUpdate ( void *  renderer = NULL)

Whether the graphical representation should be updated or not.

This function is called by RenderPhyCylinder to check if a new representation of the cylinder should be generated since the last time this function was called. This function only considers changes to properties like dimensions and color, not position or orientation. This function also takes a pointer which is used to keep separate states. This means that if there is a change and the graphical representatation needs to be updated, this function will return true not only on the first call but also in all subsequent calls with a different renderer parameter

Parameters
renderera pointer to the renderer, to keep separate states
Returns
true if the phycylinder representation should be updated

Definition at line 158 of file phycylinder.cpp.

References WObject::color(), Ownable::owner(), and WObject::useColorTextureOfOwner().

real height ( ) const
inline

return the height

Definition at line 113 of file phycylinder.h.

const QColor& lowerBaseColor ( ) const
inline

Returns the color of the lower base.

Returns
the color of the lower base

Definition at line 150 of file phycylinder.h.

real radius ( ) const
inline

return the radius

Definition at line 109 of file phycylinder.h.

const QList<SegmentColor>& segmentsColor ( ) const
inline

Returns the color of segments of the cylinder.

Note
All intervals are simple intervals, contiguous and go from -pi to pi
Returns
the color of segments of the cylinder

Definition at line 180 of file phycylinder.h.

Referenced by PhyMarXbot::segmentsColor(), and PhyEpuck::segmentsColor().

void setLowerBaseColor ( QColor  color)

Sets the color of the lower base.

Parameters
colorthe new color of the upper base. If this is invalid, the base is drawn with slices corresponding to those defined by setSegmentsColor

Definition at line 64 of file phycylinder.cpp.

References WObject::color(), and WObject::colorv.

Referenced by PhyMarXbot::setLedColors(), and PhyEpuck::setLedColors().

void setSegmentsColor ( QColor  base,
const QList< SegmentColor > &  segmentsColor 
)

Sets the color of segments of the cylinder.

This function takes a base color and a list of SegmentColor objects. The base color is used for all the portions of the cylinder which are not covered by SegmentColor specified in the list. The intervals in the list are clamped to [-pi, pi], values outside are discarded. A color later in the list is covered by earlier one. All angles are in radians and are counterclockwise from the Y axis looking at the cylinder from the tip of the X axis (on the YZ plane, remember that the cylinder grows along X). Note that internally the list of colors is stored in a different format, so the list you pass here is probably not the one you get with the function segmentsColor()

Parameters
basethe base color of the cylinder
segmentColorsthe list of colors of segments

Definition at line 104 of file phycylinder.cpp.

References WObject::color(), WObject::colorv, and Intervals::isEmpty().

Referenced by PhyMarXbot::setLedColors(), and PhyEpuck::setLedColors().

void setUpperBaseColor ( QColor  color)

Sets the color of the upper base.

Parameters
colorthe new color of the upper base. If this is invalid, the base is drawn with slices corresponding to those defined by setSegmentsColor

Definition at line 51 of file phycylinder.cpp.

References WObject::color(), and WObject::colorv.

Referenced by PhyMarXbot::setLedColors(), and PhyEpuck::setLedColors().

const QColor& upperBaseColor ( ) const
inline

Returns the color of the upper base.

Returns
the color of the upper base

Definition at line 131 of file phycylinder.h.


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