Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3151 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Dec 11, 2004, 5:26:18 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/dave: src of trunk copied into branches/dave/src

Location:
orxonox/branches/dave/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/dave/src/Makefile.am

    r2860 r3151  
    88
    99orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc
    10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h
     10noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h
    1111
    1212
    1313
    14 #  uncomment the following if bencoder requires the math library
     14#  uncomment the following if orxonox requires the math library
    1515#orxonox_LDADD=-lm
    1616
  • orxonox/branches/dave/src/Makefile.in

    r2860 r3151  
    3838PRE_UNINSTALL = :
    3939POST_UNINSTALL = :
     40host_triplet = @host@
    4041bin_PROGRAMS = orxonox$(EXEEXT)
    4142subdir = src
     
    113114EGREP = @EGREP@
    114115EXEEXT = @EXEEXT@
     116GTK2_CFLAGS = @GTK2_CFLAGS@
     117GTK2_LIBS = @GTK2_LIBS@
     118HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
     119HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
    115120INSTALL_DATA = @INSTALL_DATA@
    116121INSTALL_PROGRAM = @INSTALL_PROGRAM@
     
    146151am__quote = @am__quote@
    147152bindir = @bindir@
     153build = @build@
    148154build_alias = @build_alias@
     155build_cpu = @build_cpu@
     156build_os = @build_os@
     157build_vendor = @build_vendor@
    149158datadir = @datadir@
    150159exec_prefix = @exec_prefix@
     160host = @host@
    151161host_alias = @host_alias@
     162host_cpu = @host_cpu@
     163host_os = @host_os@
     164host_vendor = @host_vendor@
    152165includedir = @includedir@
    153166infodir = @infodir@
     
    164177sharedstatedir = @sharedstatedir@
    165178sysconfdir = @sysconfdir@
     179target = @target@
    166180target_alias = @target_alias@
     181target_cpu = @target_cpu@
     182target_os = @target_os@
     183target_vendor = @target_vendor@
    167184AM_CXXFLAGS = "-I/usr/X11R6/include"
    168185AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib  -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS)
    169186orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc
    170 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h
     187noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h
    171188all: all-am
    172189
     
    441458
    442459
    443 #  uncomment the following if bencoder requires the math library
     460#  uncomment the following if orxonox requires the math library
    444461#orxonox_LDADD=-lm
    445462
  • orxonox/branches/dave/src/array.cc

    r2860 r3151  
    6969    printf ("Finalizing array.\n"); 
    7070  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
     71  //  if ((array = new GLfloat [entryCount]) == NULL)
    7172    printf ("could not allocate %i data Blocks\n", entryCount);
    7273  Entry* walker = firstEntry;
     
    7778    }
    7879  finalized = true;
     80
    7981  return;
    8082}
     
    9193        printf ("adding new Entry to Array: %f\n", entry);
    9294     
    93       entryCount++;
    9495      currentEntry->value = entry;
    9596      currentEntry->next = new Entry;
    9697      currentEntry = currentEntry->next;
    9798      currentEntry->next = NULL;
     99      ++entryCount;
    98100    }
    99101  else
  • orxonox/branches/dave/src/keynames.cc

    r2551 r3151  
    1313   co-programmer: ...
    1414*/
    15 #include <SDL/SDL.h>
    1615
    1716#include "keynames.h"
  • orxonox/branches/dave/src/keynames.h

    r2551 r3151  
    1010#endif
    1111
     12#ifndef __APPLE__
    1213#include <SDL/SDL.h>
     14#else
     15#include <SDL.h>
     16#endif
    1317
    1418/**
  • orxonox/branches/dave/src/object.cc

    r2860 r3151  
    119119
    120120/**
    121    \brief finalizes an Object.
     121  \brief finalizes an Object.
    122122   This funcion is needed, to close the glList and all the other lists.
    123123*/
     
    226226  if (verbose >= 2)
    227227    printf("Adding new Group\n");
     228  group->name = "";
    228229  group->faceMode = -1;
    229   group->name = "";
     230  group->faceCount =0; 
    230231  if ((group->listNumber = glGenLists(1)) == 0 )
    231232    {
     
    246247      group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2;
    247248    }
    248 
     249  if (verbose >=2)
     250    printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal);
    249251  group->vertices = new Array();
    250252  group->normals = new Array();
     
    256258/**
    257259   \brief finalizes a Group.
     260   \param group the group to finalize.
    258261*/
    259262bool Object::finalizeGroup(Group* group)
    260263{
     264  if (verbose >=2)
     265    printf ("Finalize group %s.\n", group->name);
    261266  glEnd();
    262267  glEndList();
     268}
     269/**
     270   \brief deletes the Arrays of the Group to save space.
     271   \param group the group to delete the arrays from.
     272*/
     273bool Object::cleanupGroup(Group* group)
     274{
     275  if (verbose >=2)
     276    printf ("cleaning up group %s.\n", group->name);
    263277 
    264278  delete group->vertices;
     
    266280  delete group->vTexture;
    267281}
     282
    268283/**
    269284   \brief Reads in the .obj File and sets all the Values.
     
    282297    }
    283298  objFileName = fileName;
    284   char Buffer[500];
     299  char Buffer[10000];
    285300  while(!OBJ_FILE->eof())
    286301    {
    287       OBJ_FILE->getline(Buffer, 500);
     302      OBJ_FILE->getline(Buffer, 10000);
    288303      if (verbose >=4)
    289304        printf ("Read input line: %s\n",Buffer);
     
    330345    }
    331346  OBJ_FILE->close();
     347  return true;
    332348
    333349}
     
    363379    {
    364380      currentGroup->vertices->finalizeArray();
    365       glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
     381      //      glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
    366382      currentGroup->normals->finalizeArray();
    367       glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
     383      //      glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
    368384      currentGroup->vTexture->finalizeArray();
    369385    }
    370386
    371387  readingVertices = false;
    372   char subbuffer1[20];
    373   char subbuffer2[20];
    374   char subbuffer3[20];
    375   char subbuffer4[20] ="";
    376   sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    377   if (!strcmp(subbuffer4, ""))
     388  currentGroup->faceCount++;
     389
     390  int elemCount = 0;
     391 
     392  FaceElement* firstElem = new FaceElement;
     393  FaceElement* tmpElem = firstElem;
     394
     395 
     396  while(strcmp (faceString, "\0"))
     397    {
     398      if (elemCount>0)
     399          tmpElem = tmpElem->next = new FaceElement;
     400      tmpElem->next = NULL;
     401
     402
     403      sscanf (faceString, "%s", tmpElem->value);
     404      faceString += strlen(tmpElem->value);
     405      if (strcmp (faceString, "\0"))
     406        faceString++;
     407      elemCount++;
     408
     409
     410    }
     411 
     412 
     413  if (elemCount == 3)
    378414    {
    379415      if (currentGroup->faceMode != 3)
     
    386422      currentGroup->faceMode = 3;
    387423      if (verbose >=3)
    388         printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3);
    389       addGLElement(subbuffer1);
    390       addGLElement(subbuffer2);
    391       addGLElement(subbuffer3);
    392       return true;
    393     }
    394   else
     424        printf ("found triag.\n");
     425    }
     426 
     427  else if (elemCount == 4)
    395428    {
    396429      if (currentGroup->faceMode != 4)
     
    402435      currentGroup->faceMode = 4;
    403436      if (verbose >=3 )
    404         printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    405       addGLElement(subbuffer1);
    406       addGLElement(subbuffer2);
    407       addGLElement(subbuffer3);
    408       addGLElement(subbuffer4);
    409       return true;
    410     }
     437        printf ("found quad.\n");
     438    }
     439 
     440  else if (elemCount > 4)
     441    {
     442      if (currentGroup->faceMode != -1)
     443        glEnd();
     444      glBegin(GL_POLYGON);
     445      if (verbose >=3)
     446        printf ("Polygon with %i faces found.", elemCount);
     447      currentGroup->faceMode = elemCount;
     448    }
     449
     450  tmpElem = firstElem;
     451  while (tmpElem != NULL)
     452    {
     453      //      printf ("%s\n", tmpElem->value);
     454      addGLElement(tmpElem->value);
     455      tmpElem = tmpElem->next;
     456    }
     457
    411458}
    412459
     
    423470{
    424471  if (verbose >=3)
    425     printf ("importing grafical Element.... including to openGL\n");
     472    printf ("importing grafical Element to openGL\n");
    426473  char* vertex = elementString;
    427474
    428475  char* texture;
    429   texture = strstr (vertex, "/");
    430   texture[0] = '\0';
    431   texture ++;
    432   glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
    433 
    434   char* normal;
    435   if ((normal = strstr (texture, "/")) !=NULL)
    436     {
    437       normal[0] = '\0';
    438       normal ++;
    439       //glArrayElement(atoi(vertex)-1);
    440       glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
    441     }
     476  if ((texture = strstr (vertex, "/")) != NULL)
     477    {
     478      texture[0] = '\0';
     479      texture ++;
     480      if (verbose>=3)
     481        printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount());
     482      glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
     483
     484      char* normal;
     485      if ((normal = strstr (texture, "/")) !=NULL)
     486        {
     487          normal[0] = '\0';
     488          normal ++;
     489          //glArrayElement(atoi(vertex)-1);
     490          glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     491        }
     492    }
     493  if (verbose>=3)
     494    printf ("includeing vertex #%i, and mapping it to group vertex #%i, vertexArray has %i entries.\n", atoi(vertex), (atoi(vertex)-1 - currentGroup->firstVertex)*3, currentGroup->vertices->getCount());
    442495  glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3);
    443496
     
    488541bool Object::readGroup (char* groupString)
    489542{
    490   //  printf ("test\n");
    491   if (!strcmp(groupString, "default"))
    492     {
    493       if (groupCount != 0)
    494         {
    495           Group* newGroup = new Group;
    496           finalizeGroup(currentGroup);
    497           currentGroup->nextGroup = newGroup;
    498           initGroup(newGroup);
    499           currentGroup = newGroup; // must be after init see initGroup for more info
    500         }
    501       ++groupCount;
    502     }
    503   else
    504     {
    505      
    506       currentGroup->name = new char [strlen(groupString)];     
     543  // setting the group name if not default.
     544  if (strcmp(currentGroup->name, "default"))
     545    {
     546      currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char));
    507547      strcpy(currentGroup->name, groupString);
    508548    }
     549  if (groupCount != 0 && currentGroup->faceCount>0)
     550    {
     551      Group* newGroup = new Group;
     552      finalizeGroup(currentGroup);
     553      currentGroup->nextGroup = newGroup;
     554      initGroup(newGroup);
     555      cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup.
     556      currentGroup = newGroup; // must be after init see initGroup for more info
     557    }
     558
     559  ++groupCount;
     560
    509561}
    510562
  • orxonox/branches/dave/src/object.h

    r2860 r3151  
    1818extern int verbose; //!< fill be removed and added again as a verbose-class
    1919
     20
     21struct FaceElement
     22{
     23  char value[20];
     24  FaceElement* next;
     25};
    2026
    2127//! Class that handles 3D-Objects. it can also read them in and display them.
     
    4955    Array* vTexture;
    5056    int faceMode;
     57    int faceCount;
    5158
    5259    int firstVertex;
     
    7481  bool initGroup(Group* group);
    7582  bool finalizeGroup (Group* group);
     83  bool cleanupGroup(Group* group);
    7684
    7785
  • orxonox/branches/dave/src/orxonox.cc

    r2860 r3151  
    148148 
    149149  // Set window labeling
    150   // TO DO: Add version information to caption
    151   SDL_WM_SetCaption( "Orxonox", "Orxonox");
     150  SDL_WM_SetCaption( "Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
    152151 
    153152  // TO DO: Create a cool icon and use it here
  • orxonox/branches/dave/src/orxonox.h

    r2636 r3151  
    77#define ORXONOX_H
    88
    9 #include <SDL/SDL.h>
     9// this includes the information from configure/makefiles
     10#if HAVE_CONFIG_H
     11#include <config.h>
     12#endif
    1013
    1114#include "stdincl.h"
  • orxonox/branches/dave/src/player.cc

    r2860 r3151  
    2626{
    2727
    28   obj = new Object ("reaphigh.obj");
     28  obj = new Object ("reaplow.obj");
    2929  /*
    3030  objectList = glGenLists(1);
  • orxonox/branches/dave/src/stdincl.h

    r2860 r3151  
    88#include <windows.h>
    99#endif
     10
     11#ifndef __APPLE__
    1012#include <SDL/SDL.h>
     13#else
     14#include <SDL.h>
     15#endif
     16
    1117#include <GL/gl.h>
    1218#include <GL/glu.h>
  • orxonox/branches/dave/src/vector.cc

    r2860 r3151  
    843843  return (n.dot(p) + k);
    844844}
     845
     846
     847/**
     848   \brief Creates a new BezierCurve
     849*/
     850BezierCurve::BezierCurve (void)
     851{
     852  nodeCount = 0;
     853  firstNode = new PathNode;
     854  currentNode = firstNode;
     855
     856  firstNode->position = Vector (.0, .0, .0);
     857  firstNode->number = 0;
     858  firstNode->next = 0; // not sure if this really points to NULL!!
     859
     860  return;
     861}
     862
     863/**
     864   \brief Deletes a BezierCurve.
     865   It does this by freeing all the space taken over from the nodes
     866*/
     867BezierCurve::~BezierCurve (void)
     868{
     869  PathNode* tmpNode;
     870  currentNode = firstNode;
     871  while (tmpNode != 0)
     872    {
     873      tmpNode = currentNode;
     874      currentNode = currentNode->next;
     875      delete tmpNode;
     876    }
     877}
     878
     879/**
     880   \brief adds a new Node to the bezier Curve
     881   \param newNode a Vector to the position of the new node
     882*/
     883void BezierCurve::addNode(const Vector& newNode)
     884{
     885  PathNode* tmpNode;
     886  if (nodeCount == 0 )
     887    tmpNode = firstNode;
     888  else
     889    {
     890      tmpNode = new PathNode;
     891      currentNode = currentNode->next = tmpNode;
     892    }
     893  tmpNode->position = newNode;
     894  tmpNode->next = 0; // not sure if this really points to NULL!!
     895  tmpNode->number = (++nodeCount);
     896  return;
     897}
     898
     899/**
     900   \brief calculates the Position on the curve
     901   \param t The position on the Curve (0<=t<=1)
     902   \return the Position on the Path
     903*/
     904Vector BezierCurve::calcPos(float t)
     905{
     906  if (nodeCount <=4)
     907    {
     908      //      if (verbose >= 1)
     909      //      printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);
     910      curvePoint = Vector(0,0,0);
     911    }
     912  PathNode* tmpNode = firstNode;
     913   
     914  int k,kn,nn,nkn;
     915  double blend,muk,munk;
     916  Vector b = Vector(0.0,0.0,0.0);
     917 
     918  muk = 1;
     919  munk = pow(1-t,(double)nodeCount);
     920 
     921  for (k=0; k<=nodeCount; k++) {
     922    nn = nodeCount;
     923    kn = k;
     924    nkn = nodeCount - k;
     925    blend = muk * munk;
     926    muk *= t;
     927    munk /= (1-t);
     928    while (nn >= 1) {
     929      blend *= nn;
     930      nn--;
     931      if (kn > 1) {
     932        blend /= (double)kn;
     933        kn--;
     934      }
     935      if (nkn > 1) {
     936        blend /= (double)nkn;
     937        nkn--;
     938      }
     939    }
     940    b.x += tmpNode->position.x * blend;
     941    b.y += tmpNode->position.y * blend;
     942    b.z += tmpNode->position.z * blend;
     943
     944    tmpNode = tmpNode->next;
     945  }
     946  return b;
     947}
     948
     949Vector BezierCurve::calcDirection (float t)
     950{
     951  double diff = .00000000001;
     952 
     953  Vector diffV = ((calcPos(t+diff) - calcPos(t))/diff);
     954  diffV.normalize();
     955  return diffV;
     956}
     957
     958/**
     959  \brief returns the Position of the point calculated on the Curve
     960  \return a Vector to the calculated position
     961*/
     962Vector BezierCurve::getPos() const
     963{
     964  return curvePoint;
     965}
  • orxonox/branches/dave/src/vector.h

    r2551 r3151  
    149149};
    150150
     151
     152
     153//! Bezier Curve
     154/**
     155   Class to handle bezier curves in 3-dimesnsional space
     156   
     157   needed for  the Tracking system in OrxOnoX.
     158*/
     159class BezierCurve
     160{
     161 private:
     162  int nodeCount;
     163  Vector curvePoint;
     164 
     165  struct PathNode
     166  {
     167    int number;
     168    Vector position;
     169    PathNode* next;
     170  };
     171
     172  PathNode* firstNode;
     173  PathNode* currentNode;
     174
     175 public:
     176  BezierCurve (void);
     177  ~BezierCurve (void);
     178  void addNode (const Vector& newNode);
     179  Vector calcPos (float t);
     180  Vector calcDirection (float t);
     181 
     182  Vector getPos () const;
     183};
     184
     185
     186
    151187#endif
Note: See TracChangeset for help on using the changeset viewer.