Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6918


Ignore:
Timestamp:
May 17, 2010, 4:36:18 PM (15 years ago)
Author:
gasserlu
Message:

drone follows in realistic matter

Location:
code/branches/ai
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/data/levels/pickup.oxw

    r6891 r6918  
    2323?>
    2424
    25     <Template name=droneTemplate>
    26         <Drone name="meineDrohne"  mass= "50" linearDamping = "0.9" angularDamping = "0.7">
    27         <attached>
    28             <Model scale="1" mesh="drone.mesh"/>
    29         </attached>
    30         <collisionShapes>
    31             <BoxCollisionShape position="0,0,0"      halfExtents="1, 1, 1" />
    32         </collisionShapes>
    33    
    34 
    35     <weaponslots>
    36       <WeaponSlot position="    0,   0,0" />
    37     </weaponslots>
    38     <weaponsets>
    39       <WeaponSet firemode=0 />
    40     </weaponsets>
    41     <weapons>
    42       <WeaponPack>
    43         <links>
    44           <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
    45         </links>
    46         <Weapon>
    47           <attached>
    48             <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
    49             <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
    50           </attached>
    51           <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
    52           <HsW01 mode=0 munitionpershot=0 delay=0     material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
    53         </Weapon>
    54       </WeaponPack>
    55     </weapons>
    56 
    57 
    58         </Drone>
    59      </Template>
    6025
    6126    <PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
     
    6429        </pickup>
    6530    </PickupSpawner>
    66 
    67 
    6831
    6932    <PickupSpawner position="-75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
  • code/branches/ai/data/levels/templates/pickup_representation_templates.oxt

    r6524 r6918  
    107107    </PickupCollection>
    108108</Template>
    109    
     109
     110
     111<Template name=droneTemplate>
     112    <Drone name="meineDrohne"  mass= "50" linearDamping = "0.7" angularDamping = "0.9999999" primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>
     113        <attached>
     114            <Model scale="1" mesh="drone.mesh"/>
     115        </attached>
     116        <collisionShapes>
     117            <BoxCollisionShape position="0,0,0"      halfExtents="1, 1, 1" />
     118        </collisionShapes>
     119        <weaponslots>
     120            <WeaponSlot position="    0,   0,0" />
     121        </weaponslots>
     122        <weaponsets>
     123            <WeaponSet firemode=0 />
     124        </weaponsets>
     125        <weapons>
     126            <WeaponPack>
     127                <links>
     128                    <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
     129                </links>
     130                <Weapon>
     131                    <attached>
     132                        <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
     133                        <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
     134                    </attached>
     135                    <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
     136                    <HsW01 mode=0 munitionpershot=0 delay=0     material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
     137                </Weapon>
     138            </WeaponPack>
     139        </weapons>
     140    </Drone>
     141</Template>
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6891 r6918  
    3636#include "gametypes/TeamDeathmatch.h"
    3737#include "controllers/WaypointPatrolController.h"
     38#include "controllers/DroneController.h"
    3839#include "util/Math.h"
    3940
     
    348349    void ArtificialController::searchNewTarget()
    349350    {
     351COUT(0) << "search new target - start" << std::endl;
    350352        if (!this->getControllableEntity())
    351353            return;
     
    372374            }
    373375        }
     376COUT(0) << "search new target - end: " << this->target_ << std::endl;
    374377    }
    375378
  • code/branches/ai/src/orxonox/controllers/CMakeLists.txt

    r6854 r6918  
    88  WaypointController.cc
    99  WaypointPatrolController.cc
    10   DroneController.cc 
     10  DroneController.cc
    1111)
  • code/branches/ai/src/orxonox/controllers/DroneController.cc

    r6891 r6918  
    4747    DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
    4848    {
    49         // - do any kind of initialisation
    50 
    51         // this checks that our creator really is a drone
    52         // and saves the pointer to the drone for the controlling commands
    53 
    54    
    5549        RegisterObject(DroneController);
    5650
     
    8680
    8781        const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
    88 
    89         int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
    90                            + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
    91                            + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z)); //distance to Owner
    92 
    93         if (distance > 500) { //TODO: variable implementation of maxdistance
    94             drone_->moveUpDown(locOwnerDir.y);
    95             drone_->moveFrontBack(-locOwnerDir.z);
    96             drone_->moveRightLeft(locOwnerDir.x);
    97         }
    98 
    99 
     82/*
     83        int distance_square  = (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
     84                             + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
     85                             + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z); //distance to Owner squared
     86*/
    10087        random = rnd(maxrand);
    10188        if ( random < 30 && (!this->target_))
    10289            this->searchNewTarget();
    103 
    104 
    105         this->aimAtTarget();
    106         drone_->fire(0);
     90/*
     91        //face target
     92        drone_->rotateYaw(-targetPosition_.x);
     93        drone_->rotatePitch(targetPosition_.y);
     94  */     
     95        if (this->target_)
     96        {
     97            this->aimAtTarget();
     98            drone_->fire(0);
     99        }
    107100         
    108101
    109102
    110 
    111         //COUT(0) << "Drone: " << dronePosition << endl;
    112         //COUT(0) << "Distance: " << distance << endl;
     103/*
     104        COUT(0) << "Drone: " << dronePosition << endl;
     105        COUT(0) << "Distance: " << distance << endl;
    113106        COUT(0) << "locDrone: " << locOwnerDir << endl;
    114107        COUT(0) << "target: " << targetPosition_ << endl;
    115108        COUT(0) << "Owner: " << ownerPosition << endl;
    116109        COUT(0) << "Rand: " << random << endl;
    117 
     110*/
    118111/*
    119112        // search enemy
     
    171164        Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
    172165
    173         if(myDrone != NULL) {
    174 
    175         setTargetPosition(this->getControllableEntity()->getPosition());
     166        if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength()  > 150*150) { //TODO: variable implementation of maxdistance
     167            this->moveToPosition(this->getOwner()->getWorldPosition());
    176168
    177169        }
  • code/branches/ai/src/orxonox/controllers/DroneController.h

    r6891 r6918  
    4747        Oli Scheuss
    4848    */
    49     class _OrxonoxExport DroneController : public ArtificialController
     49    class _OrxonoxExport DroneController : public ArtificialController, public Tickable
    5050    {
    5151        public:
  • code/branches/ai/src/orxonox/worldentities/Drone.cc

    r6847 r6918  
    169169    void Drone::rotateYaw(const Vector2& value)
    170170    {
    171         this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
     171        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
    172172    }
    173173
Note: See TracChangeset for help on using the changeset viewer.