Index: /branches/playability/ChangeLog
===================================================================
--- /branches/playability/ChangeLog	(revision 10003)
+++ /branches/playability/ChangeLog	(revision 10004)
@@ -3,4 +3,5 @@
   Multiple weapons per ship added
   Several small tweaks needed to make the above working added
+  Addition of SwarmMissile and SwarmProjectile
 
 
Index: /branches/playability/src/defs/class_id_DEPRECATED.h
===================================================================
--- /branches/playability/src/defs/class_id_DEPRECATED.h	(revision 10003)
+++ /branches/playability/src/defs/class_id_DEPRECATED.h	(revision 10004)
@@ -238,4 +238,5 @@
   CL_HYPERBLAST                 =    0x000003e9,
   CL_BOOMERANG_PROJECTILE       =    0x000003ea,
+  CL_SWARM_PROJECTILE           =    0x000003eb,
 
   // NPC's
Index: /branches/playability/src/world_entities/WorldEntities.am
===================================================================
--- /branches/playability/src/world_entities/WorldEntities.am	(revision 10003)
+++ /branches/playability/src/world_entities/WorldEntities.am	(revision 10004)
@@ -40,8 +40,10 @@
                 world_entities/weapons/medium_blaster.cc \
                 world_entities/weapons/heavy_blaster.cc \
+                world_entities/weapons/swarm_missile.cc \
                 \
                 world_entities/projectiles/bolt.cc \
                 world_entities/projectiles/mbolt.cc \
                 world_entities/projectiles/hbolt.cc \
+                world_entities/projectiles/swarm_projectile.cc \
                 world_entities/projectiles/bomb.cc \
                 world_entities/projectiles/laser.cc \
@@ -150,8 +152,10 @@
                 weapons/medium_blaster.h \
                 weapons/heavy_blaster.h \
+                weapons/swarm_missile.h \
                 \
                 projectiles/bolt.h \
                 projectiles/mbolt.h \
                 projectiles/hbolt.h \
+                projectiles/swarm_projectile.h \
                 projectiles/bomb.h \
                 projectiles/laser.h \
Index: /branches/playability/src/world_entities/projectiles/hbolt.cc
===================================================================
--- /branches/playability/src/world_entities/projectiles/hbolt.cc	(revision 10003)
+++ /branches/playability/src/world_entities/projectiles/hbolt.cc	(revision 10004)
@@ -47,4 +47,5 @@
   this->angle = 0;
   this->rotationSpeed = 1000;
+
 
   this->emitter = new DotEmitter(100, 5, M_2_PI);
@@ -118,5 +119,9 @@
 void HBolt::updateAngle (float time)
 {
+<<<<<<< .mine
+  this->angle += this->rotationSpeed * time;
+=======
   this->angle = this->angle + this->rotationSpeed * time;
+>>>>>>> .r10003
 }
 
@@ -173,4 +178,14 @@
   //this->updateAngle();
 
+<<<<<<< .mine
+  //glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
+  //glRotatef(this->angle, 0.0, 0.0, -1.0);
+  glTranslatef (this->getAbsCoor ().x,
+                  this->getAbsCoor ().y,
+                  this->getAbsCoor ().z);
+  Vector tmpRot = this->getAbsDir().getSpacialAxis();
+  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
+  glRotatef(this->angle, 0.0, 0.0, -1.0);
+=======
   //glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
   //glRotatef(this->angle, 0.0, 0.0, -1.0);
@@ -181,4 +196,5 @@
   glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
   glRotatef(this->angle, 0.0, 0.0, 1.0);
+>>>>>>> .r10003
   this->getModel()->draw();
   glPopMatrix();
Index: /branches/playability/src/world_entities/projectiles/swarm_projectile.cc
===================================================================
--- /branches/playability/src/world_entities/projectiles/swarm_projectile.cc	(revision 10004)
+++ /branches/playability/src/world_entities/projectiles/swarm_projectile.cc	(revision 10004)
@@ -0,0 +1,216 @@
+
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific
+   main-programmer: Silvan Nellen
+   co-programmer:
+
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
+
+#include "swarm_projectile.h"
+
+#include "state.h"
+
+#include "particles/dot_emitter.h"
+#include "particles/sprite_particles.h"
+
+#include "debug.h"
+
+#include "class_id_DEPRECATED.h"
+
+ObjectListDefinitionID(SwarmProjectile, CL_SWARM_PROJECTILE);
+CREATE_FAST_FACTORY_STATIC(SwarmProjectile);
+
+/**
+ *  standard constructor
+*/
+SwarmProjectile::SwarmProjectile () : Projectile()
+{
+
+  this->loadModel("models/projectiles/orx-rocket.obj", 0.5);
+  this->loadExplosionSound("sound/explosions/explosion_4.wav");
+
+
+  this->setMinEnergy(1);
+  this->setHealthMax(10);
+  this->lifeSpan = 2.0;
+  this->agility = 3.5;
+  this->maxVelocity = 150;
+
+  this->emitter = new DotEmitter(100, 5, M_2_PI);
+  this->emitter->setParent(this);
+  this->emitter->setSpread(M_PI, M_PI);
+}
+
+
+/**
+ *  standard deconstructor
+*/
+SwarmProjectile::~SwarmProjectile ()
+{
+  // delete this->emitter;
+
+  /* this is normaly done by World.cc by deleting the ParticleEngine */
+  if (SwarmProjectile::trailParticles != NULL && SwarmProjectile::objectList().size() <= 1)
+  {
+    if (ParticleSystem::objectList().exists(SwarmProjectile::trailParticles))
+      delete SwarmProjectile::trailParticles;
+    SwarmProjectile::trailParticles = NULL;
+  }
+  if (SwarmProjectile::explosionParticles != NULL && SwarmProjectile::objectList().size() <= 1)
+  {
+    if (ParticleSystem::objectList().exists(SwarmProjectile::explosionParticles))
+      delete SwarmProjectile::explosionParticles;
+    SwarmProjectile::explosionParticles = NULL;
+  }
+
+}
+
+SpriteParticles* SwarmProjectile::trailParticles = NULL;
+SpriteParticles* SwarmProjectile::explosionParticles = NULL;
+
+
+
+void SwarmProjectile::activate()
+{
+  if (unlikely(SwarmProjectile::trailParticles == NULL))
+  {
+    SwarmProjectile::trailParticles = new SpriteParticles(2000);
+    SwarmProjectile::trailParticles->setName("BoomerangProjectileTrailParticles");
+    SwarmProjectile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");
+    SwarmProjectile::trailParticles->setLifeSpan(1.0, .3);
+    SwarmProjectile::trailParticles->setRadius(0.0, .5);
+    SwarmProjectile::trailParticles->setRadius(0.2, 4.0);
+    SwarmProjectile::trailParticles->setRadius(.5, 1.5);
+    SwarmProjectile::trailParticles->setRadius(1.0, 1.5);
+    SwarmProjectile::trailParticles->setColor(0.0, 1,0,0,.7);
+    SwarmProjectile::trailParticles->setColor(0.2, .8,.8,0,.5);
+    SwarmProjectile::trailParticles->setColor(0.5, .8,.8,.8,.8);
+    SwarmProjectile::trailParticles->setColor(1.0, .8,.8,.8,.0);
+  }
+  if (unlikely(SwarmProjectile::explosionParticles == NULL))
+  {
+    SwarmProjectile::explosionParticles = new SpriteParticles(200);
+    SwarmProjectile::explosionParticles->setName("BoomerangProjectileExplosionParticles");
+    SwarmProjectile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");
+    SwarmProjectile::explosionParticles->setLifeSpan(.5, .3);
+    SwarmProjectile::explosionParticles->setRadius(0.0, 10);
+    SwarmProjectile::explosionParticles->setRadius(.5, 15.0);
+    SwarmProjectile::explosionParticles->setRadius(1.0, 10.0);
+    SwarmProjectile::explosionParticles->setColor(0.0, 0,1,0,1);
+    SwarmProjectile::explosionParticles->setColor(0.5, .8,.8,0,.8);
+    SwarmProjectile::explosionParticles->setColor(0.8, .8,.8,.3,.8);
+    SwarmProjectile::explosionParticles->setColor(1.0, 1,1,1,.0);
+  }
+
+  this->emitter->setSystem(SwarmProjectile::trailParticles);
+
+  this->updateNode(0);
+  this->emitter->setEmissionRate(45.0);
+  this->emitter->setEmissionVelocity(0.0);
+
+  this->setHealth(10.0* (float)rand()/(float)RAND_MAX);
+}
+
+
+void SwarmProjectile::deactivate()
+{
+  this->emitter->setSystem(NULL);
+  this->lifeCycle = 0.0;
+
+  this->toList(OM_DEAD);
+  this->removeNode();
+  SwarmProjectile::fastFactory->kill(this);
+}
+
+
+void SwarmProjectile::collidesWith(WorldEntity* entity, const Vector& location)
+{
+  if (this->hitEntity != entity)
+    this->destroy( entity );
+  this->hitEntity = entity;
+}
+
+/**
+ *  signal tick, time dependent things will be handled here
+ * @param time since last tick
+*/
+void SwarmProjectile::tick (float time)
+{
+
+  Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0);
+
+  {
+    speed = velocity.len();
+    diffVector = ((targetFarFarAway - this->getAbsCoor()).getNormalized());
+
+    if(velocity.dot(diffVector) != 0)
+    {
+      correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
+
+      if( (diffVector *  (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility )
+        velocity = ((diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;
+      else if(velocity.dot(diffVector) > 0)
+        velocity += correctionVector;
+      else if (velocity.dot(diffVector) < 0)
+        velocity -= correctionVector;
+    }
+    else
+      velocity += diffVector * agility;
+
+    this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
+  }
+
+  velocity *= maxVelocity/velocity.len();
+  Vector v = this->velocity * (time);
+  this->shiftCoor(v);
+
+  if(this->tickLifeCycle(time))
+    this->deactivate();
+}
+
+/**
+ *  the function gets called, when the projectile is destroyed
+ */
+void SwarmProjectile::destroy (WorldEntity* killer)
+{
+
+  printf("THIS SHOULD WORLk\n");
+
+  Projectile::destroy( killer );
+  PRINTF(5)("DESTROY SwarmProjectile\n");
+  this->lifeCycle = .95; //!< @todo calculate this usefully.
+  this->emitter->setSystem(SwarmProjectile::explosionParticles);
+
+  this->emitter->setEmissionRate(1000.0);
+  this->emitter->setEmissionVelocity(50.0);
+  //  this->deactivate();
+
+}
+
+
+void SwarmProjectile::draw () const
+{
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+
+  float matrix[4][4];
+  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
+  this->getAbsDir().matrix (matrix);
+  glMultMatrixf((float*)matrix);
+  glScalef(2.0, 2.0, 2.0);
+  this->getModel()->draw();
+
+  glPopMatrix();
+
+}
+
Index: /branches/playability/src/world_entities/projectiles/swarm_projectile.h
===================================================================
--- /branches/playability/src/world_entities/projectiles/swarm_projectile.h	(revision 10004)
+++ /branches/playability/src/world_entities/projectiles/swarm_projectile.h	(revision 10004)
@@ -0,0 +1,51 @@
+/*!
+ * @file swarm_projectile.h
+ * @brief a SwarmProjectile Projectile
+*/
+
+#ifndef _SWARM_PROJECTILE_H
+#define _SWARM_PROJECTILE_H
+
+#include "projectile.h"
+
+class Weapon;
+class SpriteParticles;
+class ParticleEmitter;
+class FastFactory;
+class Aim;
+
+class SwarmProjectile : public Projectile
+{
+  ObjectListDeclaration(SwarmProjectile);
+  public:
+    SwarmProjectile ();
+    virtual ~SwarmProjectile ();
+
+    virtual void activate();
+    virtual void deactivate();
+
+    virtual void collidesWith(WorldEntity* entity, const Vector& location);
+
+    virtual void destroy (WorldEntity* killer);
+
+    virtual void tick (float time);
+    virtual void draw () const;
+
+
+  private:
+    static FastFactory*               fastFactory;
+    static SpriteParticles*           trailParticles;
+    static SpriteParticles*           explosionParticles;
+
+    ParticleEmitter*                  emitter;
+    float                             agility;
+    float                             maxVelocity;
+    float                             speed;
+    Vector                            diffVector ;
+    Vector                            correctionVector;
+
+    WorldEntity* hitEntity; // FIXME TEMPORARY
+
+};
+
+#endif /* _SWARM_PROJECTILE_H */
Index: /branches/playability/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /branches/playability/src/world_entities/space_ships/space_ship.cc	(revision 10003)
+++ /branches/playability/src/world_entities/space_ships/space_ship.cc	(revision 10004)
@@ -26,4 +26,5 @@
 #include "weapons/medium_blaster.h"
 #include "weapons/heavy_blaster.h"
+#include "weapons/swarm_missile.h"
 #include "weapons/boomerang_gun.h"
 #include "weapons/turret.h"
@@ -152,6 +153,7 @@
   wpLeft3->setName("Heavy Blaster Left");
 
-  Weapon* cannon = new BoomerangGun();//Cannon();
-  cannon->setName("End of World");
+  Weapon* cannon = new SwarmMissile();
+  cannon->setName("Swarm Missile");
+  
 
 
@@ -273,5 +275,5 @@
   this->secWeaponMan.setSlotCount(6);
 
-  this->secWeaponMan.setSlotPosition(0, Vector(2.6, -2.5, 0));
+  this->secWeaponMan.setSlotPosition(0, Vector(1.5, -1, 0));
   this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
 
@@ -300,7 +302,9 @@
   this->weaponMan.getFixedTarget()->setParent(this);
   this->weaponMan.getFixedTarget()->setRelCoor(100000,0,0);
+
   
   this->secWeaponMan.getFixedTarget()->setParent(this);
   this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
+  this->secWeaponMan.setRotationSpeed(0);
 
   dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false);
@@ -367,5 +371,6 @@
 void SpaceShip::enter()
 {
-  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
+  this->secWeaponMan.showCrosshair();
+  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
   this->attachCamera();
 }
@@ -373,5 +378,6 @@
 void SpaceShip::leave()
 {
-  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
+  this->secWeaponMan.hideCrosshair();
+  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
   this->detachCamera();
 }
Index: /branches/playability/src/world_entities/weapons/swarm_missile.cc
===================================================================
--- /branches/playability/src/world_entities/weapons/swarm_missile.cc	(revision 10004)
+++ /branches/playability/src/world_entities/weapons/swarm_missile.cc	(revision 10004)
@@ -0,0 +1,146 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific
+   main-programmer: Benjamin Grauer
+   co-programmer:
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
+
+#include "swarm_missile.h"
+
+#include "weapon_manager.h"
+#include "world_entities/projectiles/projectile.h"
+
+#include "model.h"
+
+#include "state.h"
+#include "animation3d.h"
+
+#include "util/loading/factory.h"
+
+#include "class_id_DEPRECATED.h"
+CREATE_FACTORY(SwarmMissile);
+
+
+/**
+ *  standard constructor
+ *
+ * creates a new SwarmMissile
+ */
+SwarmMissile::SwarmMissile()
+  : Weapon()
+{
+  this->init();
+}
+
+/**
+ * creates a new SwarmMissile from a TiXmlElement
+ */
+SwarmMissile::SwarmMissile(const TiXmlElement* root)
+{
+  this->init();
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+/**
+ *  standard deconstructor
+*/
+SwarmMissile::~SwarmMissile ()
+{
+  // model will be deleted from WorldEntity-destructor
+}
+
+void SwarmMissile::init()
+{
+  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
+  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
+
+  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
+  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
+  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
+  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
+
+  animation1->setInfinity(ANIM_INF_CONSTANT);
+  animation2->setInfinity(ANIM_INF_CONSTANT);
+
+  this->setStateDuration(WS_SHOOTING, .6);
+  this->setStateDuration(WS_RELOADING, 1.0f);
+  this->setStateDuration(WS_ACTIVATING, .4);
+  this->setStateDuration(WS_DEACTIVATING, .4);
+
+  this->setEnergyMax(100);
+  this->increaseEnergy(100);
+  //this->minCharge = 2;
+
+  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
+  this->setProjectileTypeC("SwarmProjectile");
+
+  this->loadModel("models/guns/turret1.obj", 1.0);
+
+  this->setEmissionPoint(1.684, 0.472, 0);
+  //this->getProjectileFactory()->prepare(100);
+
+  this->setActionSound(WA_SHOOT, "sound/explosions/explosion_3.wav");
+  this->setActionSound(WA_ACTIVATE, "sound/vocals/missiles.wav");
+  this->setActionSound(WA_RELOAD, "sound/vocals/reload.wav");
+
+}
+
+void SwarmMissile::loadParams(const TiXmlElement* root)
+{
+  Weapon::loadParams(root);
+}
+
+void SwarmMissile::activate()
+{
+}
+
+void SwarmMissile::deactivate()
+{
+}
+
+void SwarmMissile::tick(float dt)
+{
+  if (!Weapon::tickW(dt))
+    return;
+
+  Quaternion quat;
+  Vector direction;
+  if (this->getDefaultTarget() == NULL)
+    direction = this->getAbsCoor();
+  else
+    direction = this->getDefaultTarget()->getAbsCoor() - this->getAbsCoor();
+
+  direction.normalize();
+
+  if (likely (this->getParent() != NULL))
+    quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
+  else
+    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
+
+  this->setAbsDirSoft(quat, 5);
+}
+
+void SwarmMissile::fire()
+{
+  Projectile* pj = this->getProjectile();
+  if (pj == NULL)
+    return;
+
+  pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 /*+ VECTOR_RAND(13) */
+            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
+
+  pj->setParent(PNode::getNullParent());
+  pj->setAbsCoor(this->getEmissionPoint());
+  pj->setAbsDir(this->getAbsDir());
+  pj->activate();
+}
Index: /branches/playability/src/world_entities/weapons/swarm_missile.h
===================================================================
--- /branches/playability/src/world_entities/weapons/swarm_missile.h	(revision 10004)
+++ /branches/playability/src/world_entities/weapons/swarm_missile.h	(revision 10004)
@@ -0,0 +1,32 @@
+/*!
+ * @file swarm_missile.h
+*/
+
+
+#ifndef _SWARM_MISSILE_H
+#define _SWARM_MISSILE_H
+
+#include "weapon.h"
+
+class SwarmMissile : public Weapon
+  {
+  
+  public:
+    SwarmMissile ();
+    SwarmMissile(const TiXmlElement* root);
+    virtual ~SwarmMissile ();
+
+    void init();
+    virtual void loadParams(const TiXmlElement* root);
+
+    virtual void activate();
+    virtual void deactivate();
+
+    virtual void tick(float dt);
+    virtual void fire();
+
+
+  private:
+  };
+
+#endif /* _BOOMERANG_GUN_H */
Index: /branches/playability/src/world_entities/weapons/weapon_manager.cc
===================================================================
--- /branches/playability/src/world_entities/weapons/weapon_manager.cc	(revision 10003)
+++ /branches/playability/src/world_entities/weapons/weapon_manager.cc	(revision 10004)
@@ -126,4 +126,9 @@
 {
   this->crosshair->setVisibility( false);
+}
+
+void WeaponManager::setRotationSpeed(float speed)
+{
+  this->crosshair->setRotationSpeed(speed);
 }
 
@@ -431,9 +436,7 @@
 
   /*
-  if( this->crosshair != NULL)
-  {
 	this->crosshair->setRotationSpeed(500);
 	this->crossHairSizeAnim->replay();
-  } */
+  */
 }
 
Index: /branches/playability/src/world_entities/weapons/weapon_manager.h
===================================================================
--- /branches/playability/src/world_entities/weapons/weapon_manager.h	(revision 10003)
+++ /branches/playability/src/world_entities/weapons/weapon_manager.h	(revision 10004)
@@ -62,4 +62,5 @@
     void showCrosshair();
     void hideCrosshair();
+    void setRotationSpeed(float speed);
 
     void setSlotCount(unsigned int slotCount);
