Index: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	(revision 5265)
+++ trunk/src/Makefile.am	(revision 5266)
@@ -55,4 +55,5 @@
                   world_entities/player.cc \
                   world_entities/npc.cc \
+                  world_entities/npc2.cc \
                   world_entities/environment.cc \
                   world_entities/skysphere.cc \
@@ -114,4 +115,5 @@
                  world_entities/player.h \
                  world_entities/npc.h \
+                 world_entities/npc2.h \
                  world_entities/environment.h \
                  world_entities/skysphere.h \
Index: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	(revision 5265)
+++ trunk/src/Makefile.in	(revision 5266)
@@ -66,7 +66,7 @@
 	orxonox-world_entity.$(OBJEXT) orxonox-camera.$(OBJEXT) \
 	orxonox-player.$(OBJEXT) orxonox-npc.$(OBJEXT) \
-	orxonox-environment.$(OBJEXT) orxonox-skysphere.$(OBJEXT) \
-	orxonox-skybox.$(OBJEXT) orxonox-terrain.$(OBJEXT) \
-	orxonox-satellite.$(OBJEXT) \
+	orxonox-npc2.$(OBJEXT) orxonox-environment.$(OBJEXT) \
+	orxonox-skysphere.$(OBJEXT) orxonox-skybox.$(OBJEXT) \
+	orxonox-terrain.$(OBJEXT) orxonox-satellite.$(OBJEXT) \
 	orxonox-character_attributes.$(OBJEXT) \
 	orxonox-test_entity.$(OBJEXT) orxonox-weapon_manager.$(OBJEXT) \
@@ -114,4 +114,5 @@
 @AMDEP_TRUE@	./$(DEPDIR)/orxonox-load_param.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/orxonox-npc.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/orxonox-npc2.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/orxonox-null_parent.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/orxonox-orxonox.Po \
@@ -316,4 +317,5 @@
                   world_entities/player.cc \
                   world_entities/npc.cc \
+                  world_entities/npc2.cc \
                   world_entities/environment.cc \
                   world_entities/skysphere.cc \
@@ -375,4 +377,5 @@
                  world_entities/player.h \
                  world_entities/npc.h \
+                 world_entities/npc2.h \
                  world_entities/environment.h \
                  world_entities/skysphere.h \
@@ -526,4 +529,5 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-load_param.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-npc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-npc2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-null_parent.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-orxonox.Po@am__quote@
@@ -923,4 +927,20 @@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-npc.obj `if test -f 'world_entities/npc.cc'; then $(CYGPATH_W) 'world_entities/npc.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/npc.cc'; fi`
+
+orxonox-npc2.o: world_entities/npc2.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-npc2.o -MD -MP -MF "$(DEPDIR)/orxonox-npc2.Tpo" -c -o orxonox-npc2.o `test -f 'world_entities/npc2.cc' || echo '$(srcdir)/'`world_entities/npc2.cc; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/orxonox-npc2.Tpo" "$(DEPDIR)/orxonox-npc2.Po"; else rm -f "$(DEPDIR)/orxonox-npc2.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='world_entities/npc2.cc' object='orxonox-npc2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/orxonox-npc2.Po' tmpdepfile='$(DEPDIR)/orxonox-npc2.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-npc2.o `test -f 'world_entities/npc2.cc' || echo '$(srcdir)/'`world_entities/npc2.cc
+
+orxonox-npc2.obj: world_entities/npc2.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-npc2.obj -MD -MP -MF "$(DEPDIR)/orxonox-npc2.Tpo" -c -o orxonox-npc2.obj `if test -f 'world_entities/npc2.cc'; then $(CYGPATH_W) 'world_entities/npc2.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/npc2.cc'; fi`; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/orxonox-npc2.Tpo" "$(DEPDIR)/orxonox-npc2.Po"; else rm -f "$(DEPDIR)/orxonox-npc2.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='world_entities/npc2.cc' object='orxonox-npc2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/orxonox-npc2.Po' tmpdepfile='$(DEPDIR)/orxonox-npc2.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-npc2.obj `if test -f 'world_entities/npc2.cc'; then $(CYGPATH_W) 'world_entities/npc2.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/npc2.cc'; fi`
 
 orxonox-environment.o: world_entities/environment.cc
Index: trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- trunk/src/lib/graphics/graphics_engine.cc	(revision 5265)
+++ trunk/src/lib/graphics/graphics_engine.cc	(revision 5266)
@@ -29,7 +29,4 @@
 
 using namespace std;
-
-
-#include "shader.h"
 
 /**
@@ -274,9 +271,4 @@
   PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
 
-  Shader* shader = new Shader("test.txt", "shader.cg");
-//  delete shader;
-  shader->activateShader();
-//  exit(-1);
-
 }
 
@@ -301,4 +293,6 @@
       //    return -1;
     }
+    glMatrixMode(GL_PROJECTION_MATRIX);
+    glLoadIdentity();
     glViewport(0,0,width,height);                                                   // Reset The Current Viewport
 }
Index: trunk/src/lib/graphics/shader.cc
===================================================================
--- trunk/src/lib/graphics/shader.cc	(revision 5265)
+++ trunk/src/lib/graphics/shader.cc	(revision 5266)
@@ -18,6 +18,4 @@
 #include "shader.h"
 
-
-#include "array.h"
 #include "stdlibincl.h"
 #include <stdio.h>
@@ -41,8 +39,4 @@
    this->fragmentShaderFile = NULL;
    this->vertexShaderFile = NULL;
-   this->fragmentShaderSource = NULL;
-   this->vertexShaderSource = NULL;
-   this->fragmentShaderLengths = NULL;
-   this->vertexShaderLenghts = NULL;
    this->shaderProgram = 0;
    this->vertexShader = 0;
@@ -50,5 +44,5 @@
 
    if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
-     this->shaderProgram = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
+     this->shaderProgram = glCreateProgramObjectARB();
 
    if (vertexShaderFile != NULL)
@@ -81,57 +75,14 @@
   this->deleteProgram(type);
 
-  FILE*    stream;           //< The stream we use to read the file.
 
-  if( (stream = fopen (fileName, "r")) == NULL)
-  {
-    PRINTF(1)("Shader could not open %s\n", fileName);
-    return false;
-  }
-  Array<char*>* program = new Array<char*>;
-  Array<int>* lengths = new Array<int>;
-  if (type == SHADER_VERTEX)
+  const char* program = fileRead(fileName);
+
+  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
   {
     this->vertexShaderFile = new char[strlen(fileName)+1];
     strcpy(this->vertexShaderFile, fileName);
-    this->vertexShaderSource = program;
-    this->vertexShaderLenghts = lengths;
-  }
-  else
-  {
-    this->fragmentShaderFile = new char[strlen(fileName)+1];
-    strcpy(this->fragmentShaderFile, fileName);
-    this->fragmentShaderSource = program;
-    this->fragmentShaderLengths = lengths;
-  }
 
-  char lineBuffer[PARSELINELENGHT];
-  char* addString;
-  while( !feof( stream))
-  {
-      // get next line
-    fgets (lineBuffer, PARSELINELENGHT, stream);
-//     if (strchr(lineBuffer, '\n'))
-//     {
-//       addString = new char[strlen(lineBuffer)];
-//       strncpy(addString, lineBuffer, strlen (lineBuffer)-1);
-//       addString[strlen(lineBuffer)-1] ='\0';
-//     }
-//     else
-    {
-      addString = new char[strlen(lineBuffer)+1];
-      strcpy(addString, lineBuffer);
-    }
-    program->addEntry(addString);
-    lengths->addEntry(strlen(addString));
-  }
-  fclose(stream);
-
-  program->finalizeArray();
-  lengths->finalizeArray();
-
-  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
-  {
     this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
-    glShaderSourceARB(this->vertexShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
+    glShaderSourceARB(this->vertexShader, 1, (const GLcharARB**)&program, NULL);
     glCompileShaderARB(this->vertexShader);
     glAttachObjectARB(this->shaderProgram, this->vertexShader);
@@ -141,15 +92,53 @@
   if (type == SHADER_FRAGMENT && GLEW_ARB_fragment_shader)
   {
+    this->fragmentShaderFile = new char[strlen(fileName)+1];
+    strcpy(this->fragmentShaderFile, fileName);
+
     this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
-    glShaderSourceARB(this->fragmentShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
+    glShaderSourceARB(this->fragmentShader, 1, (const GLcharARB**)&program, NULL);
     glCompileShaderARB(this->fragmentShader);
     glAttachObjectARB(this->shaderProgram, this->fragmentShader);
     this->printError(this->fragmentShader);
   }
+
+  delete[] program;
 }
 
-bool Shader::activateShader()
+
+char* Shader::fileRead(const char* fileName)
+{
+  FILE* fileHandle;
+  char* content = NULL;
+
+  int count = 0;
+
+  if (fileName != NULL) {
+    fileHandle = fopen(fileName, "rt");
+
+    if (fileHandle != NULL) {
+
+      fseek(fileHandle, 0, SEEK_END);
+      count = ftell(fileHandle);
+      rewind(fileHandle);
+
+      if (count > 0) {
+        content = new char[count+1];
+        count = fread(content, sizeof(char), count, fileHandle);
+        content[count] = '\0';
+      }
+      fclose(fileHandle);
+    }
+  }
+  return content;
+}
+
+void Shader::activateShader()
 {
   glUseProgramObjectARB(this->shaderProgram);
+}
+
+void Shader::deactivateShader()
+{
+  glUseProgramObjectARB(0);
 }
 
@@ -157,11 +146,6 @@
 void Shader::deleteProgram(SHADER_TYPE type)
 {
-  Array<char*>* deleteArray = NULL;
   if (type == SHADER_VERTEX)
   {
-    deleteArray = this->vertexShaderSource;
-    this->vertexShaderSource = NULL;
-    delete this->vertexShaderLenghts;
-    this->vertexShaderLenghts = NULL;
     delete[] this->vertexShaderFile;
     this->vertexShaderFile = NULL;
@@ -171,8 +155,4 @@
   else if (type == SHADER_FRAGMENT)
   {
-    deleteArray = this->fragmentShaderSource;
-    delete this->fragmentShaderLengths;
-    this->fragmentShaderLengths = NULL;
-    this->fragmentShaderSource = NULL;
     delete[] this->fragmentShaderFile;
     this->fragmentShaderFile = NULL;
@@ -182,16 +162,4 @@
   else
     return;
-
-  if (deleteArray == NULL)
-    return;
-  else
-  {
-    deleteArray->finalizeArray();
-    for (unsigned int i = 0; i < deleteArray->getCount(); i++)
-    {
-      delete[] deleteArray->getEntry(i);
-    }
-    delete deleteArray;
-  }
 }
 
@@ -214,5 +182,5 @@
   if (this->vertexShader != 0)
   {
-    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
+/*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
     if (this->vertexShaderSource != NULL)
       for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
@@ -224,5 +192,5 @@
     if (this->fragmentShaderSource != NULL)
       for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
-        PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));
+        PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
   }
 
Index: trunk/src/lib/graphics/shader.h
===================================================================
--- trunk/src/lib/graphics/shader.h	(revision 5265)
+++ trunk/src/lib/graphics/shader.h	(revision 5266)
@@ -20,5 +20,4 @@
 
 // FORWARD DECLARATION
-template<class T> class Array;
 
 
@@ -31,6 +30,9 @@
 
   bool loadShaderProgramm(SHADER_TYPE type, const char* fileName);
-  bool activateShader();
+  void activateShader();
+  static void deactivateShader();
   void deleteProgram(SHADER_TYPE type);
+
+  char* fileRead(const char* fileName);
 
   void printError(GLenum program);
@@ -42,8 +44,4 @@
    char*                  fragmentShaderFile;
    char*                  vertexShaderFile;
-   Array<char*>*          fragmentShaderSource;
-   Array<char*>*          vertexShaderSource;
-   Array<int>*            fragmentShaderLengths;
-   Array<int>*            vertexShaderLenghts;
    GLenum                 shaderProgram;
    GLenum                 vertexShader;
Index: trunk/src/story_entities/world.cc
===================================================================
--- trunk/src/story_entities/world.cc	(revision 5265)
+++ trunk/src/story_entities/world.cc	(revision 5266)
@@ -73,4 +73,5 @@
 #include "cd_engine.h"
 #include "npc.h"
+#include "npc2.h"
 
 SHELL_COMMAND(speed, World, setSpeed);
@@ -462,5 +463,5 @@
   for(int i = 0; i < 100; i++)
   {
-    WorldEntity* tmp = new NPC();
+    WorldEntity* tmp = new NPC2();
     char npcChar[10];
     sprintf (npcChar, "NPC_%d", i);
Index: trunk/src/world_entities/npc.cc
===================================================================
--- trunk/src/world_entities/npc.cc	(revision 5265)
+++ trunk/src/world_entities/npc.cc	(revision 5266)
@@ -30,5 +30,5 @@
   this->setClassID(CL_NPC, "NPC");
 
-  this->loadModelWithScale("models/ships/bolido.obj", 5);
+  this->loadModelWithScale("models/ships/bolido.obj", 2);
 
   this->randomRotAxis = VECTOR_RAND(1);
Index: trunk/src/world_entities/npc2.cc
===================================================================
--- trunk/src/world_entities/npc2.cc	(revision 5266)
+++ trunk/src/world_entities/npc2.cc	(revision 5266)
@@ -0,0 +1,106 @@
+
+
+/*
+   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: Patrick Boenzli
+   co-programmer:
+*/
+
+
+#include "npc2.h"
+#include "obb_tree.h"
+
+#include "shader.h"
+#include "state.h"
+#include "list.h"
+
+using namespace std;
+
+
+NPC2::NPC2()
+{
+  this->setClassID(CL_NPC, "NPC");
+
+  this->loadModelWithScale("models/ships/bolido.obj", 3);
+  this->shader = new Shader("toon.vert", "toon.frag");
+//  this->shader->activateShader();
+  //exit(-1);
+
+  this->obj = gluNewQuadric();
+
+  this->randomRotAxis = VECTOR_RAND(1);
+}
+
+
+NPC2::~NPC2 () {}
+
+
+void NPC2::collidesWith(WorldEntity* entity, const Vector& location)
+{
+  if (entity->isA(CL_PROJECTILE))
+  {
+    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
+    this->applyForce(Vector(0,0,0)-location*1000);
+  }
+  else if (entity->isA(CL_PLAYER))
+    this->applyForce(Vector(0,0,0)-location*100);
+  else
+  {
+    this->setVisibiliy(false);
+   State::getWorldEntityList()->remove(this);
+  }
+}
+
+
+/**
+ *  the entity is drawn onto the screen with this function
+ *
+ * This is a central function of an entity: call it to let the entity painted to the screen.
+ * Just override this function with whatever you want to be drawn.
+ */
+void NPC2::draw()
+{
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+  float matrix[4][4];
+
+  /* translate */
+  glTranslatef (this->getAbsCoor ().x,
+                this->getAbsCoor ().y,
+                this->getAbsCoor ().z);
+  /* rotate */
+  this->getAbsDir ().matrix (matrix);
+  glMultMatrixf((float*)matrix);
+
+  shader->activateShader();
+  gluSphere(this->obj, 3, 20, 20);
+  shader->deactivateShader();
+
+
+/*  if (this->model)
+    this->model->draw();*/
+  glPopMatrix();
+}
+
+
+void NPC2::tick(float dt)
+{
+//  Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
+
+  //if (directin.len() < 100)
+//  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
+  this->shiftDir(Quaternion(dt, this->randomRotAxis));
+
+}
+
+
+
Index: trunk/src/world_entities/npc2.h
===================================================================
--- trunk/src/world_entities/npc2.h	(revision 5266)
+++ trunk/src/world_entities/npc2.h	(revision 5266)
@@ -0,0 +1,33 @@
+
+#ifndef _NPC22_H
+#define _NPC2_H
+
+#include "world_entity.h"
+#include "physics_interface.h"
+
+class AI;
+class Shader;
+
+class NPC2 : public WorldEntity, public PhysicsInterface {
+
+ public:
+  NPC2 ();
+  ~NPC2 ();
+
+
+  void addAI(AI* ai);
+
+  virtual void tick(float dt);
+  virtual void draw();
+
+  virtual void collidesWith (WorldEntity* entity, const Vector& location);
+
+
+ private:
+   Vector   randomRotAxis;
+   Shader*  shader;
+   GLUquadricObj* obj;
+
+};
+
+#endif /* _NPC2_H */
