[Orxonox-commit 511] r3064 - in trunk/src/orxonox/objects: . gametypes worldentities worldentities/triggers
Aurelian at orxonox.net
Aurelian at orxonox.net
Mon May 25 17:54:42 CEST 2009
Author: Aurelian
Date: 2009-05-25 17:54:42 +0200 (Mon, 25 May 2009)
New Revision: 3064
Modified:
trunk/src/orxonox/objects/Radar.cc
trunk/src/orxonox/objects/RadarViewable.cc
trunk/src/orxonox/objects/RadarViewable.h
trunk/src/orxonox/objects/gametypes/Asteroids.h
trunk/src/orxonox/objects/worldentities/ForceField.cc
trunk/src/orxonox/objects/worldentities/ForceField.h
trunk/src/orxonox/objects/worldentities/MovableEntity.cc
trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h
Log:
Final commit of gametype asteroids for presentation. everything working. New gadget: Radar displays the next checkpoint to reach!
Modified: trunk/src/orxonox/objects/Radar.cc
===================================================================
--- trunk/src/orxonox/objects/Radar.cc 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/Radar.cc 2009-05-25 15:54:42 UTC (rev 3064)
@@ -113,8 +113,9 @@
for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
{
- if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
- (*itListener)->displayObject(*itElement, *itElement == this->focus_);
+ if ((*itElement)->getRadarVisibility())
+ if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
+ (*itListener)->displayObject(*itElement, *itElement == this->focus_);
}
}
}
Modified: trunk/src/orxonox/objects/RadarViewable.cc
===================================================================
--- trunk/src/orxonox/objects/RadarViewable.cc 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/RadarViewable.cc 2009-05-25 15:54:42 UTC (rev 3064)
@@ -46,6 +46,8 @@
, radarObjectDescription_("staticObject")
{
RegisterRootObject(RadarViewable);
+
+ this->bVisibility_ = true;
}
void RadarViewable::setRadarObjectDescription(const std::string& str)
Modified: trunk/src/orxonox/objects/RadarViewable.h
===================================================================
--- trunk/src/orxonox/objects/RadarViewable.h 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/RadarViewable.h 2009-05-25 15:54:42 UTC (rev 3064)
@@ -69,6 +69,11 @@
inline const std::string& getRadarObjectDescription() const
{ return this->radarObjectDescription_; }
+ inline void setRadarVisibility(bool b)
+ { this->bVisibility_ = b; }
+ inline bool getRadarVisibility() const
+ { return this->bVisibility_; }
+
virtual const WorldEntity* getWorldEntity() const = 0;
const Vector3& getRVWorldPosition() const;
@@ -88,7 +93,8 @@
assert(0);
}
}
-
+
+ bool bVisibility_;
float radarObjectCamouflage_;
Shape radarObjectShape_;
std::string radarObjectDescription_;
Modified: trunk/src/orxonox/objects/gametypes/Asteroids.h
===================================================================
--- trunk/src/orxonox/objects/gametypes/Asteroids.h 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/gametypes/Asteroids.h 2009-05-25 15:54:42 UTC (rev 3064)
@@ -47,7 +47,7 @@
virtual void end();
inline void firstCheckpointReached(bool reached)
- { this->firstCheckpointReached_ = reached; }
+ { this->firstCheckpointReached_ = reached; }
protected:
virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
Modified: trunk/src/orxonox/objects/worldentities/ForceField.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ForceField.cc 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/worldentities/ForceField.cc 2009-05-25 15:54:42 UTC (rev 3064)
@@ -34,55 +34,51 @@
namespace orxonox
{
- CreateFactory(ForceField);
+ CreateFactory(ForceField);
ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
{
- RegisterObject(ForceField);
+ RegisterObject(ForceField);
- //Standard Values
- this->setDirection(Vector3::ZERO);
- velocity_ = 100;
- diameter_ = 500;
- length_ = 2000;
+ //Standard Values
+ this->setDirection(Vector3::ZERO);
+ velocity_ = 100;
+ diameter_ = 500;
+ length_ = 5000;
}
ForceField::~ForceField() {}
void ForceField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
- SUPER(ForceField, XMLPort, xmlelement, mode);
-
- //For correct xml import use: position, direction, velocity, scale
-
- XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
- XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
- XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000);
+ SUPER(ForceField, XMLPort, xmlelement, mode);
+
+ //For correct xml import use: position, direction, velocity, scale
+ XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
+ XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
+ XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000);
}
void ForceField::tick(float dt)
{
+ for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
+ {
+ //calculate from
+ Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
+ directionVec.normalise();
- for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
- {
+ Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
- //calculate from
- Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
- directionVec.normalise();
+ //distance from centervector of the field (
+ float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
- Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
-
- //distance from centervector of the field (
- float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
-
- if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
- {
- //normalize distance from center
- it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
+ if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
+ {
+ //normalize distance from center
+ it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
+ }
}
-
- }
- }
+ }
}
Modified: trunk/src/orxonox/objects/worldentities/ForceField.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ForceField.h 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/worldentities/ForceField.h 2009-05-25 15:54:42 UTC (rev 3064)
@@ -35,36 +35,36 @@
namespace orxonox
{
- class _OrxonoxExport ForceField : public StaticEntity, public Tickable
- {
+ class _OrxonoxExport ForceField : public StaticEntity, public Tickable
+ {
public:
- ForceField(BaseObject* creator);
- virtual ~ForceField();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
- virtual void tick(float dt);
+ ForceField(BaseObject* creator);
+ virtual ~ForceField();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+ virtual void tick(float dt);
- inline void setVelocity(float vel)
- { this->velocity_ = vel; }
+ inline void setVelocity(float vel)
+ { this->velocity_ = vel; }
- inline float getVelocity()
- { return velocity_; }
+ inline float getVelocity()
+ { return velocity_; }
- inline void setDiameter(float diam)
- { this->diameter_ = diam; }
+ inline void setDiameter(float diam)
+ { this->diameter_ = diam; }
- inline float getDiameter()
- { return diameter_; }
+ inline float getDiameter()
+ { return diameter_; }
- inline void setLength(float l)
- { this->length_ = l; }
+ inline void setLength(float l)
+ { this->length_ = l; }
- inline float getLength()
- { return length_; }
+ inline float getLength()
+ { return length_; }
private:
- float velocity_;
- float diameter_;
- float length_;
+ float velocity_;
+ float diameter_;
+ float length_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-05-25 15:54:42 UTC (rev 3064)
@@ -79,7 +79,7 @@
Pawn* victim = dynamic_cast<Pawn*>(otherObject);
if (victim)
{
- victim->damage(this->collisionDamage_ * victim->getVelocity().dotProduct(this->getVelocity()));
+ victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
}
}
Modified: trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc 2009-05-25 15:54:42 UTC (rev 3064)
@@ -37,59 +37,79 @@
namespace orxonox
{
- CreateFactory(CheckPoint);
+ CreateFactory(CheckPoint);
- CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
- {
- RegisterObject(CheckPoint);
+ CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
+ {
+ RegisterObject(CheckPoint);
- this->setStayActive(true);
- this->setDistance(50);
- this->bIsFirst_ = false;
- this->bIsDestination_ = false;
- //this->setVisible(true);
+ this->setStayActive(true);
+ this->setDistance(50);
+ this->bIsFirst_ = false;
+ this->bIsDestination_ = false;
- this->notifyMaskUpdate();
- }
+ this->setRadarObjectColour(ColourValue::Green);
+ this->setRadarObjectShape(RadarViewable::Dot);
+ this->setRadarVisibility(false);
- CheckPoint::~CheckPoint()
- {
- }
+ this->notifyMaskUpdate();
+ }
- void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(CheckPoint, XMLPort, xmlelement, mode);
+ CheckPoint::~CheckPoint()
+ {
+ }
- XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
- XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
- XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
- }
+ void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(CheckPoint, XMLPort, xmlelement, mode);
- void CheckPoint::triggered(bool bIsTriggered)
- {
- DistanceTrigger::triggered(bIsTriggered);
+ XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
+ XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
+ XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
+ }
- Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
- if (gametype)
+ void CheckPoint::changedActivity()
{
- gametype->addTime(addTime_);
-
- if (bIsTriggered && bIsFirst_)
+ SUPER(CheckPoint, changedActivity);
+
+ if (this->BaseObject::isActive())
{
- gametype->setTimeLimit(addTime_);
- gametype->firstCheckpointReached(true);
+COUT(0) << "active " << this << std::endl;
+ this->setRadarVisibility(true);
}
+ else
+ {
+COUT(0) << "inactive " << this << std::endl;
+ this->setRadarVisibility(false);
+ }
+ }
- if (bIsTriggered && bIsDestination_)
+ void CheckPoint::triggered(bool bIsTriggered)
+ {
+ DistanceTrigger::triggered(bIsTriggered);
+
+ Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
+ if (gametype)
{
- gametype->end();
+ gametype->addTime(addTime_);
+ this->setRadarVisibility(false);
+
+ if (bIsTriggered && bIsFirst_)
+ {
+ gametype->setTimeLimit(addTime_);
+ gametype->firstCheckpointReached(true);
+ }
+
+ if (bIsTriggered && bIsDestination_)
+ {
+ gametype->end();
+ }
}
- }
- }
+ }
- void CheckPoint::notifyMaskUpdate()
- {
- this->targetMask_.exclude(Class(BaseObject));
- this->targetMask_.include(Class(Pawn));
- }
+ void CheckPoint::notifyMaskUpdate()
+ {
+ this->targetMask_.exclude(Class(BaseObject));
+ this->targetMask_.include(Class(Pawn));
+ }
}
Modified: trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h 2009-05-25 15:38:00 UTC (rev 3063)
+++ trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h 2009-05-25 15:54:42 UTC (rev 3064)
@@ -35,43 +35,48 @@
#define _CheckPoint_H__
#include "DistanceTrigger.h"
+#include "objects/RadarViewable.h"
namespace orxonox
{
- class _OrxonoxExport CheckPoint : public DistanceTrigger
- {
+ class _OrxonoxExport CheckPoint : public DistanceTrigger, public RadarViewable
+ {
public:
- CheckPoint(BaseObject* creator);
- virtual ~CheckPoint();
+ CheckPoint(BaseObject* creator);
+ virtual ~CheckPoint();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+ virtual void changedActivity();
private:
- virtual void triggered(bool bIsTriggered);
- virtual void notifyMaskUpdate();
+ virtual void triggered(bool bIsTriggered);
+ virtual void notifyMaskUpdate();
- inline void setDestination(bool isDestination)
- { bIsDestination_ = isDestination; }
+ inline void setDestination(bool isDestination)
+ { bIsDestination_ = isDestination; }
- inline bool getDestination()
- { return bIsDestination_; }
+ inline const WorldEntity* getWorldEntity() const
+ { return this; }
- inline void setFirst(bool isFirst)
- { this->bIsFirst_ = isFirst; }
+ inline bool getDestination()
+ { return bIsDestination_; }
- inline bool getFirst()
- { return this->bIsFirst_; }
+ inline void setFirst(bool isFirst)
+ { this->bIsFirst_ = isFirst; }
- inline void setAddTime(float time)
- { this->addTime_ = time; }
+ inline bool getFirst()
+ { return this->bIsFirst_; }
- inline bool getAddTime()
- { return this->addTime_; }
+ inline void setAddTime(float time)
+ { this->addTime_ = time; }
- bool bIsFirst_;
- bool bIsDestination_;
- float addTime_;
- };
+ inline bool getAddTime()
+ { return this->addTime_; }
+
+ bool bIsFirst_;
+ bool bIsDestination_;
+ float addTime_;
+ };
}
#endif /* _CheckPoint_H__ */
More information about the Orxonox-commit
mailing list