#include <Sprite.h>
Inheritance diagram for Sprite:
Public Types | |
| typedef Network::uri_t | uri_t |
| typedef CompModel * | ModelPtr |
| typedef CompModel * | ConstModelPtr |
Public Member Functions | |
| Sprite () | |
| Create a new Sprite object, zeroing all physics variables. | |
| virtual | ~Sprite () |
| virtual void | paint ()=0 |
| Draw this sprite on screen. | |
| virtual void | update ()=0 |
| Update this sprite's pysics and stuff. | |
| bool | isVisible () const |
| Returns true if the sprite is visible. | |
| void | setVisible (bool b) |
| Tell this sprite if it should be drawn or not. | |
| bool | isActive () const |
| Returns true if the sprite is visible. | |
| void | setActive (bool b) |
| Tell this sprite if it should be updated or not. | |
| bool | isAlive () const |
| Returns true if the sprite is alive (i.e. | |
| void | setAlive (bool b) |
| Tell this sprite if is considered alive or not. | |
| virtual void | suspend () |
| Suspend the sprite. | |
| virtual void | restore () |
| Restore the sprite. | |
| virtual bool | checkCollision (Sprite *with, bool fromSelf=false) |
| Performe collision detection and handling between two sprites. | |
| virtual bool | notifyCollision (Sprite *sender) |
| Notify an other sprite that we think we have collided with it. | |
| virtual void | inflictDamage (DamageType dmg, float strength) |
| Inflict damage on this sprite. | |
| virtual const uri_t | getURI () const |
| Get a Unique Resource Identifier (URI) for this sprite. | |
| virtual void | setURI (const uri_t &u) |
| int | getOwner () |
| Get the owner of this sprite. | |
| virtual ConstModelPtr | getModel () const |
| virtual ModelPtr | getModel () |
| virtual void | computeTransform () |
| virtual Packet | packObject () const |
| Create a network packet representing vital data about this Sprite. | |
| virtual void | setObject (Packet &p) |
| Set this object's data to that represented by the packet p. | |
| virtual void | resetView () |
| bool | operator== (const Sprite &rhs) const |
| Compare two sprites and see if they are the same (they have the same URI). | |
Public Attributes | |
| float | radius |
| radius of bounding sphere used in collision detection | |
| unsigned int | spaceId |
| float | camRelFollow [3] |
| The position the camera follows if this Sprite has focus. | |
| float | camRelTrack [3] |
| The position the camera looks at if this Sprite has focus. | |
| int | owner |
Static Public Attributes | |
| static int | time |
| Current "time". | |
| static float | dTime |
| Time since last physics timestep (update). | |
Protected Member Functions | |
| virtual void | print (std::ostream &os) const |
| Print info about the sprite to an output stream. | |
| void | setModel (ModelPtr model) |
Protected Attributes | |
| uri_t | uri |
| Unique identier for this object. | |
| bool | visible |
| is sprite visible | |
| bool | active |
| is sprite updateable | |
| bool | alive |
| is sprite alive (i.e. shold still be updated/drawn etc) | |
| ModelPtr | m_model |
| The model used to draw this sprite on screen, should be 0 if the paint function should be used instead. | |
Static Protected Attributes | |
| static const char * | spriteDataDir |
| Where is sprite data files located? | |
Private Member Functions | |
| Sprite (const Sprite &) | |
| Sprite & | operator= (const Sprite &) |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Sprite &s) |
| Sprite output operator. | |
Contains methods for abstraction of physics modelling (update()) and screen drawing (paint()). A Sprite has three binary states: visible, active and alive. A visible sprite should have its paint method called when the scene is drawn (note that a visible sprite does not have to apear on screen). An active sprite should have its update method called when the world physics is updated (note make sure dTime is set). A dead sprite is of no further interest to the world and should be deallocated ASAP.
| typedef CompModel* Sprite::ConstModelPtr |
| typedef CompModel* Sprite::ModelPtr |
| typedef Network::uri_t Sprite::uri_t |
| Sprite::Sprite | ( | ) |
Create a new Sprite object, zeroing all physics variables.
| virtual Sprite::~Sprite | ( | ) | [virtual] |
| Sprite::Sprite | ( | const Sprite & | ) | [private] |
| virtual bool Sprite::checkCollision | ( | Sprite * | with, | |
| bool | fromSelf = false | |||
| ) | [inline, virtual] |
Performe collision detection and handling between two sprites.
| with | The sprite to performe collision detection with. | |
| fromSelf | set this to true when the collision check originates from one self, normally all external callers should leave this variable at the default (false) value. |
Reimplemented in BirdSprite, ExplosionSprite, GroundVehicleSprite, ShellSprite, StoneSprite, and TreeSprite.
| virtual void Sprite::computeTransform | ( | ) | [virtual] |
| virtual ModelPtr Sprite::getModel | ( | ) | [inline, virtual] |
| virtual ConstModelPtr Sprite::getModel | ( | ) | const [inline, virtual] |
| int Sprite::getOwner | ( | ) | [inline] |
Get the owner of this sprite.
| virtual const uri_t Sprite::getURI | ( | ) | const [virtual] |
| virtual void Sprite::inflictDamage | ( | DamageType | dmg, | |
| float | strength | |||
| ) | [inline, virtual] |
Inflict damage on this sprite.
By default sprites are immune to damage.
| dmg | the type of damage, different types of damages affect different sprites in different ways. | |
| strength | the amount of damage to deliver (values are usually in range 20-100 but can be anything) |
Reimplemented in GroundVehicleSprite, and TreeSprite.
| bool Sprite::isActive | ( | void | ) | const [inline] |
Returns true if the sprite is visible.
(Note the spriet may not be visible to the viewer, this simply means the sprite should be drawn).
| bool Sprite::isAlive | ( | ) | const [inline] |
Returns true if the sprite is alive (i.e.
shold still be updated/drawn etc)
| bool Sprite::isVisible | ( | void | ) | const [inline] |
Returns true if the sprite is visible.
(Note the spriet may not be visible to the viewer, this simply means the sprite should be drawn).
| virtual bool Sprite::notifyCollision | ( | Sprite * | sender | ) | [inline, virtual] |
Notify an other sprite that we think we have collided with it.
| sender | Pointer to the sprite that detected the collision. |
Reimplemented in BirdSprite, ExplosionSprite, GroundVehicleSprite, ShellSprite, StoneSprite, and TreeSprite.
| bool Sprite::operator== | ( | const Sprite & | rhs | ) | const [inline] |
Compare two sprites and see if they are the same (they have the same URI).
| virtual Packet Sprite::packObject | ( | ) | const [virtual] |
Create a network packet representing vital data about this Sprite.
The default implementation packs an SPRITE_UDATE string followed by the sprites URI and all physics data in the form pos[0] rot[0] vel[0] ... aVel[3].
Reimplemented in ExplosionSprite, ShellSprite, TankSprite, and TrackedVehicleSprite.
| virtual void Sprite::paint | ( | ) | [pure virtual] |
Draw this sprite on screen.
The paint method is allowed to change the model-view matrix and any pushable attributes.
Implemented in BirdSprite, DustSprite, ExplosionSprite, FireSprite, FlagSprite, GroundVehicleSprite, ShellSprite, Smoke, StoneSprite, and TreeSprite.
| virtual void Sprite::print | ( | std::ostream & | os | ) | const [protected, virtual] |
Print info about the sprite to an output stream.
| virtual void Sprite::resetView | ( | ) | [inline, virtual] |
| virtual void Sprite::restore | ( | ) | [virtual] |
Restore the sprite.
Make sure this sprite is updated and drawn. This is the same as calling setActive(true); followed by setVisible(true);.
| void Sprite::setActive | ( | bool | b | ) | [inline] |
Tell this sprite if it should be updated or not.
| b | true if the sprite should be updated, false otherwise. |
| void Sprite::setAlive | ( | bool | b | ) | [inline] |
Tell this sprite if is considered alive or not.
A "dead" sprite should be removed from any update/paint loops.
| b | false if the sprite should be killed, true otherwise. |
| void Sprite::setModel | ( | ModelPtr | model | ) | [protected] |
| virtual void Sprite::setObject | ( | Packet & | p | ) | [virtual] |
Set this object's data to that represented by the packet p.
The default implementation unpacks a packet created by the default impl. of packObject().
Reimplemented in ExplosionSprite, ShellSprite, TankSprite, and TrackedVehicleSprite.
| virtual void Sprite::setURI | ( | const uri_t & | u | ) | [inline, virtual] |
| void Sprite::setVisible | ( | bool | b | ) | [inline] |
Tell this sprite if it should be drawn or not.
| b | The visibility of the sprite. |
| virtual void Sprite::suspend | ( | ) | [virtual] |
Suspend the sprite.
This sprite is no longer updated or drawn. This is the same as calling setActive(false); followed by setVisible(false);.
| virtual void Sprite::update | ( | ) | [pure virtual] |
Update this sprite's pysics and stuff.
Note that the update method should use the static dTime variable to check the time since last invokation. The caller is responsible for setting this variable to an apropriate value!
Implemented in BirdSprite, DustSprite, ExplosionSprite, FireSprite, FlagSprite, ShellSprite, Smoke, StoneSprite, TankSprite, TrackedVehicleSprite, and TreeSprite.
bool Sprite::active [protected] |
is sprite updateable
bool Sprite::alive [protected] |
is sprite alive (i.e. shold still be updated/drawn etc)
| float Sprite::camRelFollow[3] |
The position the camera follows if this Sprite has focus.
| float Sprite::camRelTrack[3] |
The position the camera looks at if this Sprite has focus.
float Sprite::dTime [static] |
Time since last physics timestep (update).
ModelPtr Sprite::m_model [protected] |
The model used to draw this sprite on screen, should be 0 if the paint function should be used instead.
| int Sprite::owner |
| float Sprite::radius |
radius of bounding sphere used in collision detection
| unsigned int Sprite::spaceId |
const char* Sprite::spriteDataDir [static, protected] |
Where is sprite data files located?
int Sprite::time [static] |
uri_t Sprite::uri [protected] |
Unique identier for this object.
bool Sprite::visible [protected] |
is sprite visible
1.4.7