Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7673


Ignore:
Timestamp:
Nov 25, 2010, 11:24:50 PM (13 years ago)
Author:
dafrick
Message:

Documenting and extending ForceField.
A little cleaning up in The Time Machine level.
Adding a Bond villain…

Location:
code/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/levels/The Time Machine.oxw

    r7648 r7673  
    22 name = "The Time Machine"
    33 description = "A simple level. The only goal is to defeat as much enemies as you can."
    4  tags = ""
     4 tags = "singleplayer"
    55/>
    66
     
    4343      <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
    4444      <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
    45       <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger-->
     45      <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTriggerBeacon-->
    4646    </attached>
    4747    <collisionShapes>
     
    6161<!--*****************************************************************************************************************************************************************************************-->
    6262
    63 
    64 
    65 
    66 <!--CREATING SPAWNPOINTS______________________________________________________________________________________________________________________________________________________________OK-->
    6763<Level
    6864    name="The Time Machine"
     
    7066    gametype=TeamDeathmatch
    7167>
    72   <templates>
    73     <Template link=lodtemplate_default />
    74   </templates>
     68    <templates>
     69        <Template link=lodtemplate_default />
     70    </templates>
    7571    <Scene
    7672        ambientlight="0.8,0.8,0.8"
     
    8076        <Light type=directional position="0,0,0" direction="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 1.0, 0.9" />
    8177
     78<!--CREATING SPAWNPOINTS_____________________________________________________________________________________________________________________________________________________________________-->
    8279<?lua for i=0,4,1 do
    83 x=500
     80    x=500
    8481?>   
    8582
     
    8986
    9087<!--enemy spaceship spawnpoint-->
    91         <!-- TeamSpawnPoint team=1 position="4000,0,<?lua print(i*x-1000) ?>" lookat="-5000,0,<?lua print(i*x-1000) ?>" spawnclass=SpaceShip pawndesign=spaceshippirate /-->
     88        <!--TeamSpawnPoint team=1 position="4000,0,<?lua print(i*x-1000) ?>" lookat="-5000,0,<?lua print(i*x-1000) ?>" spawnclass=SpaceShip pawndesign=spaceshippirate /-->
    9289<?lua end ?>
    9390
     
    9592
    9693
    97 <!--Triggers (used for the Time Machine effect)_________________________________________________________________________________________________________________________partially working-->
     94<!--Triggers (used for the Time Machine effect)___________________________________________________________________________________________________________________________________________-->
    9895   
    9996        <!--TRIGGERS IF THE PLAYERS REACHES THE "TIME MACHINE"-->
     
    144141        </Trigger>
    145142
    146         <!-- This Trigger is true iff the player is in the TimeMachine and has shot another player -->
     143        <!-- This Trigger is true if the player is in the TimeMachine and has shot another player -->
    147144        <EventTrigger name=trigger2 switch=true >
    148145            <events>
     
    175172<!--Triggers (used for the Time Machine effect)_____________________________________________________________________________________________________________________________________________-->
    176173
    177 <!--Creating Spaceships___________________________________________________________________________________________________________________________________________________________________OK-->
     174<!--Creating Spaceships_____________________________________________________________________________________________________________________________________________________________________-->
    178175   
    179176<?lua for i=0,5,1 do
    180 y=math.random(-500,500)
    181 z=math.random(-1000,1000)
    182 y2=math.random(-500,500)
    183 z2=math.random(-1000,1000)
    184 health=230
    185 addh=100
     177    y=math.random(-500,500)
     178    z=math.random(-1000,1000)
     179    y2=math.random(-500,500)
     180    z2=math.random(-1000,1000)
     181    health=230
     182    addh=100
    186183?>
    187184   
     
    265262<?lua end ?>
    266263
    267 <!--Creating Spaceships_____END___________________________________________________________________________________________________________________________________________________________OK-->
     264<!--Creating Spaceships_____END_____________________________________________________________________________________________________________________________________________________________-->
    268265
    269266<!--BILLBOARD IN THE MIDDLE OF THE BATTLEFIELD-->
     
    320317                                <MovableEntity position="<?lua print(1500-3000*i) ?>,0,0">
    321318                                    <attached>
     319                                        <ForceField position="0,0,0" mode="sphere" diameter=500 velocity=100000 />
    322320                                        <Billboard position="0,0,0" material="Examples/Flare" colour="1.0,1.0,1.0" scale=0.3/>
    323321                                        <MovableEntity    position="0,0,0" rotationaxis="1,1,0" rotationrate=-255 >
     
    367365                                <MovableEntity position="0,<?lua print(1500-3000*i) ?>,0">
    368366                                    <attached>
     367                                        <ForceField position="0,0,0" mode="sphere" diameter=500 velocity=100000 />
    369368                                        <Billboard position="0,0,0" material="Examples/Flare" colour="1.0,1.0,1.0" scale=0.3/>
    370369                                        <MovableEntity    position="0,0,0" rotationaxis="1,1,0" rotationrate=-255 >
     
    414413                                <MovableEntity position="<?lua print(1000-2000*i) ?>,<?lua print(-1000+2000*i) ?>,0">
    415414                                    <attached>
     415                                        <ForceField position="0,0,0" mode="sphere" diameter=500 velocity=100000 />
    416416                                        <Billboard position="0,0,0" material="Examples/Flare" colour="1.0,1.0,1.0" scale=0.3/>
    417417                                        <MovableEntity    position="0,0,0" rotationaxis="1,1,0" rotationrate=-255 >
     
    461461                                <MovableEntity position="<?lua print(1000-2000*i) ?>,<?lua print(-1000+2000*i) ?>,0">
    462462                                    <attached>
     463                                        <ForceField position="0,0,0" mode="sphere" diameter=500 velocity=100000 />
    463464                                        <Billboard position="0,0,0" material="Examples/Flare" colour="1.0,1.0,1.0" scale=0.3/>
    464465                                        <MovableEntity    position="0,0,0" rotationaxis="1,1,0" rotationrate=-255 >
     
    508509                                <MovableEntity position="<?lua print(1000-2000*i) ?>,0,<?lua print(-1000+2000*i) ?>">
    509510                                    <attached>
     511                                        <ForceField position="0,0,0" mode="sphere" diameter=500 velocity=100000 />
    510512                                        <Billboard position="0,0,0" material="Examples/Flare" colour="1.0,1.0,1.0" scale=0.3/>
    511513                                        <MovableEntity    position="0,0,0" rotationaxis="1,1,0" rotationrate=-255 >
  • code/trunk/src/modules/objects/ForceField.cc

    r5781 r7673  
    2727 */
    2828
     29/**
     30@file ForceField.cc
     31@brief Implementation of the ForceField class.
     32*/
     33
    2934#include "ForceField.h"
    3035
     
    3641{
    3742    CreateFactory(ForceField);
     43   
     44    /*static*/ const std::string modeStringNormal_s = "tube";
     45    /*static*/ const std::string modeStringSphere_s = "sphere";
    3846
    3947    ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
     
    4351        //Standard Values
    4452        this->setDirection(Vector3::ZERO);
    45         velocity_ = 100;
    46         diameter_ = 500;
    47         length_ = 5000;
     53        this->velocity_ = 100;
     54        this->diameter_ = 500;
     55        this->length_ = 5000;
     56        this->mode_ = ForceFieldMode::tube;
    4857    }
    4958
    50     ForceField::~ForceField() {}
     59    ForceField::~ForceField()
     60    {
     61    }
    5162
    5263    void ForceField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    5869        XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
    5970        XMLPortParam(ForceField, "length"  , setLength  , getLength  , xmlelement, mode).defaultValues(2000);
     71        XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode);
    6072    }
    6173
    6274    void ForceField::tick(float dt)
    6375    {
     76        // Iterate over all objects that could possibly be affected by the ForceField.
    6477        for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    6578        {
    66             //calculate from
    67             Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
    68             directionVec.normalise();
     79            if(this->mode_ == ForceFieldMode::tube)
     80            {
     81                // The direction of the orientation of the force field.
     82                Vector3 direction = this->getOrientation() * WorldEntity::FRONT;
     83                direction.normalise();
    6984
    70             Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
     85                // Vector from the center of the force field to the object its acting on.
     86                // TODO: This could probably be simplified.
     87                Vector3 distanceVector = it->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));
     88               
     89                // The object is outside of the length of the ForceField.
     90                if(distanceVector.length() > this->halfLength_)
     91                    return;
    7192
    72             //distance from centervector of the field (
    73             float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
     93                // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector)
     94                float distanceFromDirectionVector = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
     95               
     96                // If the object in a tube of radius diameter/2 around the direction of orientation.
     97                if(distanceFromDirectionVector >= this->radius_)
     98                    return;
    7499
    75             if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
     100                // Apply a force to the object in the direction of the orientation.
     101                // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius.
     102                it->applyCentralForce(((this->radius_ - distanceFromDirectionVector)/(this->radius_)) * this->velocity_ * direction);
     103            }
     104            else if(this->mode_ == ForceFieldMode::sphere)
    76105            {
    77                 //normalize distance from center
    78                 it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
     106                Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     107                float distance = distanceVector.length();
     108                if (distance < this->radius_)
     109                {
     110                    distanceVector.normalise();
     111                    it->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);
     112                }
    79113            }
     114        }
     115    }
     116   
     117    void ForceField::setMode(const std::string& mode)
     118    {
     119        if(mode == ForceField::modeStringTube_s)
     120            this->mode_ = ForceFieldMode::tube;
     121        else if(mode == ForceField::modeStringSphere_s)
     122            this->mode_ = ForceFieldMode::sphere;
     123        else
     124        {
     125            COUT(2) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << std::endl;
     126            this->mode_ = ForceFieldMode::tube;
     127        }
     128    }
     129   
     130    inline const std::string& ForceField::getMode(void)
     131    {
     132        switch(this->mode_)
     133        {
     134            case ForceFieldMode::tube:
     135                return ForceField::modeStringTube_s;
     136            case ForceFieldMode::sphere:
     137                return ForceField::modeStringSphere_s;
     138            default:
     139                return ForceField::modeStringTube_s;
    80140        }
    81141    }
  • code/trunk/src/modules/objects/ForceField.h

    r7601 r7673  
    2323 *      Aurelian Jaggi
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     
    3131    @brief Definition of the ForceField class.
    3232    @ingroup Objects
     33*/
     34
     35/**
     36@file ForceField.h
     37@brief Definition of the ForceField class.
     38@inGroup Objects
    3339*/
    3440
     
    4349namespace orxonox
    4450{
     51
     52    /**
     53    @brief
     54        The mode of the ForceField.
     55   
     56    @inGroup Objects
     57    */
     58    namespace ForceFieldMode
     59    {
     60        enum Value {
     61            tube, //!< The ForceField has a tube shape.
     62            sphere //!< The ForceField has a spherical shape.
     63           
     64        };
     65    }
     66
     67    /**
     68    @brief
     69        Implements a force field, that applies a force to any @ref orxonox::MoblieEnity "MobileEntity" that enters its range.
     70       
     71        The following parameters can be set to specify the behavior of the ForceField.
     72        - @b velocity The amount of force the ForceField excerts.
     73        - @b diameter The diameter of the ForceField.
     74        - @b length The length of the ForceField.
     75        - @b mode The mode the ForceField is in. For mode:
     76        -- <em>tube</em> A ForceField which exerts force only in the direction it is oriented. The force is only exerted on objects that are in a tube of length <em>length</em> and diameter <em>diameter</em>. The magintude of the force is proportional to the <em><velocity/em>, being highest when an object is in the middle of the tube (radius-wise), linearly decreasing with greater radii and finally reaching zero, when the object is <code>diameter/2</code> away from the orientation vector.
     77        -- <em>sphere</em> A Force Field which exerts force radially away from itself, with the greatest magnitude (proportional to <em>velocity</em>) being in the origin of the ForceField, linearly decreasing with respect to the distance to the origin and finally reaching zero at distance <code>diameter/2</code>.
     78       
     79    @author
     80        Aurelian Jaggi
     81       
     82    @author
     83        Damian 'Mozork' Frick
     84       
     85    @inGroup Objects
     86    */
    4587    class _ObjectsExport ForceField : public StaticEntity, public Tickable
    4688    {
    47     public:
    48         ForceField(BaseObject* creator);
    49         virtual ~ForceField();
    50         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    51         virtual void tick(float dt);
     89        public:
     90            ForceField(BaseObject* creator);
     91            virtual ~ForceField();
     92            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     93            virtual void tick(float dt);
    5294
    53         inline void setVelocity(float vel)
    54             { this->velocity_ = vel; }
     95            inline void setVelocity(float vel)
     96                { this->velocity_ = vel; }
    5597
    56         inline float getVelocity()
    57             { return velocity_; }
     98            inline float getVelocity()
     99                { return this->velocity_; }
    58100
    59         inline void setDiameter(float diam)
    60             { this->diameter_ = diam; }
     101            inline void setDiameter(float diam)
     102                { this->diameter_ = diam; this->radius_ = diam/2; }
    61103
    62         inline float getDiameter()
    63             { return diameter_; }
     104            inline float getDiameter()
     105                { return this->diameter_; }
    64106
    65         inline void setLength(float l)
    66             { this->length_ = l; }
     107            inline void setLength(float l)
     108                { this->length_ = l; this->halfLength_ = l/2; }
    67109
    68         inline float getLength()
    69             { return length_; }
     110            inline float getLength()
     111                { return this->length_; }
     112               
     113            void setMode(const std::string& mode);
     114               
     115            inline const std::string& getMode(void);
    70116
    71     private:
    72         float velocity_;
    73         float diameter_;
    74         float length_;
     117        private:
     118            static const std::string modeStringTube_s;
     119            static const std::string modeStringSphere_s;
     120       
     121            float velocity_;
     122            float diameter_;
     123            float radius_;
     124            float length_;
     125            float halfLength_;
     126            ForceFieldMode::Value mode_;
    75127  };
    76128}
  • code/trunk/src/orxonox/infos/Bot.cc

    r6417 r7673  
    8282            "Max Zorin",
    8383            "Brad Whitaker",
    84             "General Koskov",
     84            "General Georgi Koskov",
    8585            "Franz Sanchez",
    8686            "Alec Trevelyan",
    8787            "Elliot Carver",
     88            "Elektra King"
    8889            "Viktor Zokas",
    8990            "Gustav Graves",
Note: See TracChangeset for help on using the changeset viewer.