Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9857


Ignore:
Timestamp:
Dec 2, 2013, 4:05:10 PM (11 years ago)
Author:
agermann
Message:

Docking funktioniert nun mit einem eingebauten Trigger ueber undocking XMLPort. Jedoch immer noch mit cmdUndock(). Forcefield wurde um eine homogenes Kraftfeld erweitert, dass Kugelfoermig und mit einer bestimmten Richtung gemacht werden kann.

Location:
code/branches/spacestationentry
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spacestationentry/data/levels/dockingToASpaceStation.oxw

    r9820 r9857  
    7171    </StaticEntity>
    7272
    73    <!-- Docking (Andocken) -->
     73<!-- Docking -->
    7474    <Dock position="2830,20,50" roll=0 yaw=0 >
    7575        <animations>
     
    8383                <EventListener event="dockMe" />
    8484            </execute>
     85
     86            <undocking>
     87                <EventListener event="undockMe" />
     88            </undocking>
    8589       
    8690            <activity>
     
    9397                beaconMode="exclude" targetname="bcnDestroyer" name="dockMe"
    9498            />
     99
     100            <Billboard position="-2730,-19970,50" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 />
     101            <DistanceTrigger position="-2730,-19970,50" distance="50" target="Pawn"
     102                beaconMode="identify" targetname="bcnDestroyer" name="undockMe"
     103            />
    95104        </attached>
    96105
    97106    </Dock>
    98 
    99 
    100        
    101 
    102107   
    103     <!--SpaceShip
    104         template            = "spaceshipcollateraldamage"
    105         team                = "0"
    106         position            = "2890,-40,6"
    107         orientation         = "-0.14, 0.68, 0.68, 0.223"
    108         lookat              = "0,0,0"
    109         roll                = "180"
    110         name                = "collateralDamage"
    111         radarname           = "Collateral Damage" >
    112       <attached>
    113         <DockingTarget name="spaceShip" />
    114         <DistanceTriggerBeacon name="bcnDestroyer" />
    115         <DockingTarget name="destroyer" />
    116       </attached>
    117     </SpaceShip-->
    118    
    119 <FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-1900,0" >
     108<FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-19900,0" >
    120109      <attached>
    121110        <DockingTarget name="spaceShip" />
     
    127116<!-- Wuerfel -->
    128117
    129   <StaticEntity position="0,-2000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
     118  <StaticEntity position="0,-20000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
    130119      <attached>
    131         <Model position="0,0,0" mesh="crate.mesh" scale3D="66,15,5" />
    132        
     120        <Model position="0,0,0" mesh="crate.mesh" scale3D="80,80,5" />
    133121      </attached>
    134122      <collisionShapes>
    135         <BoxCollisionShape position="0,0,0" halfExtents="330,330,10" />
     123        <BoxCollisionShape position="0,0,0" halfExtents="400,400,25" />
    136124      </collisionShapes>
    137125  </StaticEntity>
     
    139127<!-- Schwerkraftfeld -->
    140128
    141 <ForceField position="2500,-92000,2500" mode="sphere" diameter="184000" velocity="-5000" />
    142 <ForceField position="2500,-92000,-2500" mode="sphere" diameter="184000" velocity="-5000" />
    143 <ForceField position="-2500,-92000,2500" mode="sphere" diameter="184000" velocity="-5000" />
    144 <ForceField position="-2500,-92000,-2500" mode="sphere" diameter="184000" velocity="-5000" />
    145 
    146 <!-- Ausgang - Trigger -->
    147 
    148 <Billboard position="150,-1950,150" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 />
    149 
    150 <DistanceTrigger name="ausgang" position="100,-1950,100"  target="Pawn" distance=50 stayActive="false" delay=0 />
    151     <Script code="undock" onLoad="false">
    152         <events>
    153             <trigger>
    154                 <EventListener event=ausgang />
    155             </trigger>
    156         </events>
    157     </Script>
    158 
     129<ForceField position="0,-20000,0" mode="homogen" diameter="2000" forcedirection = "0,-400,0" />
    159130
    160131<!-- Rest -->
  • code/branches/spacestationentry/src/modules/docking/Dock.cc

    r9820 r9857  
    6969        XMLPortObject(Dock, DockingAnimation, "animations", addAnimation, getAnimation, xmlelement, mode);
    7070        XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
    71         //XMLPortEventSink(Dock, BaseObject, "undocking", undocking, xmlelement, mode);
     71        XMLPortEventSink(Dock, BaseObject, "undocking", undocking, xmlelement, mode);
    7272
    7373    }
     
    7979        XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
    8080
    81         //XMLPortEventSink(Dock, BaseObject, "undocking", undocking, xmlelement, mode);
    82     }
    83 
    84     /*
     81        XMLPortEventSink(Dock, BaseObject, "undocking", undocking, xmlelement, mode);
     82    }
     83
     84
    8585    bool Dock::undocking(bool bTriggered, BaseObject* trigger)
    8686    {
    87         orxout(user_warning)<<"undocking"<<endl;
    88 
    89         return true;
    90     }
    91 
    92     */
     87        // Noch lange nicht fertig (leich veraenderte Kopie von execute())
     88        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
     89                PlayerInfo* player = NULL;
     90
     91                // Check whether it is a player trigger and extract pawn from it
     92                if(pTrigger != NULL)
     93                {
     94                    if(!pTrigger->isForPlayer()) {  // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
     95                        orxout(verbose, context::docking) << "Docking:execute PlayerTrigger was not triggered by a player.." << endl;
     96                        return false;
     97                    }
     98                    player = pTrigger->getTriggeringPlayer();
     99                }
     100                else
     101                {
     102                    orxout(verbose, context::docking) << "Docking::execute Not a player trigger, can't extract pawn from it.." << endl;
     103                    return false;
     104                }
     105                if(player == NULL)
     106                {
     107                    orxout(verbose, context::docking) << "Docking::execute Can't retrieve PlayerInfo from Trigger. (" << trigger->getIdentifier()->getName() << ")" << endl;
     108                    return false;
     109                }
     110
     111                if(bTriggered)
     112                {
     113                    cmdUndock();
     114                }
     115                else
     116                {
     117                    // Remove player from candidates list
     118                    candidates_.erase(player);
     119                }
     120
     121                return true;
     122    }
     123
     124
    93125
    94126    bool Dock::execute(bool bTriggered, BaseObject* trigger)
  • code/branches/spacestationentry/src/modules/docking/Dock.h

    r9820 r9857  
    6262            // Trigger interface
    6363            bool execute(bool bTriggered, BaseObject* trigger);
    64             //bool undocking(bool bTriggered, BaseObject* trigger);
     64            bool undocking(bool bTriggered, BaseObject* trigger);
    6565
    6666            // XML interface
  • code/branches/spacestationentry/src/modules/objects/ForceField.cc

    r9667 r9857  
    4545    /*static*/ const std::string ForceField::modeSphere_s = "sphere";
    4646    /*static*/ const std::string ForceField::modeInvertedSphere_s = "invertedSphere";
     47
     48    /*static*/ const std::string ForceField::modeHomogen_s = "homogen";
     49
    4750    /*static*/ const std::string ForceField::modeNewtonianGravity_s = "newtonianGravity";
    4851    /*static*/ const float ForceField::gravConstant_ = 6.673e-11;
    4952    /*static*/ const float ForceField::attenFactor_ = 1;
     53
    5054
    5155    /**
     
    8993        XMLPortParam(ForceField, "length", setLength  , getLength  , xmlelement, mode).defaultValues(2000);
    9094        XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode);
     95        XMLPortParam(ForceField, "forcedirection", setForceDirection, getForceDirection, xmlelement, mode).defaultValues(Vector3(0,-400,0));
    9196    }
    9297   
     
    196201            }
    197202        }
     203        else if(this->mode_ == forceFieldMode::homogen)
     204        {
     205                // Iterate over all objects that could possibly be affected by the ForceField.
     206                for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
     207                {
     208                        Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     209                    float distance = distanceVector.length();
     210                    if (distance < this->radius_ && distance > this->massRadius_)
     211                    {
     212                        // Add a Acceleration in forceDirection_.
     213                        // Vector3(0,0,0) is the direction, where the force should work.
     214                        it->addAcceleration(forceDirection_ , Vector3(0,0,0));
     215                    }
     216                }
     217        }
    198218    }
    199219
     
    214234        else if(mode == ForceField::modeNewtonianGravity_s)
    215235            this->mode_ = forceFieldMode::newtonianGravity;
     236
     237        else if(mode == ForceField::modeHomogen_s)
     238            this->mode_ = forceFieldMode::homogen;
     239
    216240        else
    217241        {
     
    239263            case forceFieldMode::newtonianGravity:
    240264                return ForceField::modeNewtonianGravity_s;
     265
     266            case forceFieldMode::homogen:
     267                return ForceField::modeHomogen_s;
     268
    241269            default:
    242270                return ForceField::modeTube_s;
  • code/branches/spacestationentry/src/modules/objects/ForceField.h

    r9667 r9857  
     1
    12/*
    23 *   ORXONOX - the hottest 3D action shooter ever to exist
     
    5758            sphere, //!< The ForceField has a spherical shape.
    5859            invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior.
    59             newtonianGravity //!< The ForceField imitates Newtonian gravitation for use in stellar bodies.
     60            newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies.
     61            homogen //!< Local homogenous Force field with changeable direction for the Space Station
    6062        };
    6163    }
     
    6668
    6769        The following parameters can be set to specify the behavior of the ForceField.
     70        - @b forcedirection The direction and the strength of the homogenous force field. Default is 0,-400,0.
    6871        - @b velocity The amount of force the ForceField excerts. Default is 100.
    6972        - @b diameter The diameter of the ForceField. Default is 500.
     
    147150                { return this->halfLength_*2; }
    148151
     152            inline void setForceDirection(Vector3 forcedir)
     153                { this->forceDirection_ = forcedir; }
     154
     155            inline Vector3 getForceDirection()
     156                { return this->forceDirection_; }
     157
     158
    149159            void setMode(const std::string& mode); //!< Set the mode of the ForceField.
    150160            const std::string& getMode(void); //!< Get the mode of the ForceField.
     
    156166            static const std::string modeInvertedSphere_s;
    157167            static const std::string modeNewtonianGravity_s;
     168
     169            static const std::string modeHomogen_s;
    158170
    159171            float velocity_; //!< The velocity of the ForceField.
     
    167179            //! Attenuation factor for Newtonian ForceFields
    168180            static const float attenFactor_;
     181            Vector3 forceDirection_;
    169182  };
    170183}
Note: See TracChangeset for help on using the changeset viewer.