Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2860 in orxonox.OLD for orxonox/branches/dave


Ignore:
Timestamp:
Nov 15, 2004, 11:13:21 PM (20 years ago)
Author:
dave
Message:

orxonox/branches/dave: das level hat jetzt form angenommen, stand:nach der Convention vom Samstag….

Location:
orxonox/branches/dave
Files:
22 edited
20 copied

Legend:

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

    r1956 r2860  
    1 SUBDIRS = src console gui
     1SUBDIRS = src console gui importer
  • orxonox/branches/dave/Makefile.in

    r2711 r2860  
    146146sysconfdir = @sysconfdir@
    147147target_alias = @target_alias@
    148 SUBDIRS = src console gui
     148SUBDIRS = src console gui importer
    149149all: config.h
    150150        $(MAKE) $(AM_MAKEFLAGS) all-recursive
  • orxonox/branches/dave/aclocal.m4

    r2706 r2860  
    1 # generated automatically by aclocal 1.8.2 -*- Autoconf -*-
     1# generated automatically by aclocal 1.8.5 -*- Autoconf -*-
    22
    33# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
     
    4141# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
    4242AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
    43          [AM_AUTOMAKE_VERSION([1.8.2])])
     43         [AM_AUTOMAKE_VERSION([1.8.5])])
    4444
    4545# AM_AUX_DIR_EXPAND
     
    150150fi])])
    151151
    152 # serial 6                                              -*- Autoconf -*-
     152# serial 7                                              -*- Autoconf -*-
    153153
    154154# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
     
    237237    for i in 1 2 3 4 5 6; do
    238238      echo '#include "conftst'$i'.h"' >> sub/conftest.c
    239       : > sub/conftst$i.h
     239      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
     240      # Solaris 8's {/usr,}/bin/sh.
     241      touch sub/conftst$i.h
    240242    done
    241243    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    265267       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    266268      # icc doesn't choke on unknown options, it will just issue warnings
    267       # (even with -Werror).  So we grep stderr for any message
    268       # that says an option was ignored.
    269       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
     269      # or remarks (even with -Werror).  So we grep stderr for any message
     270      # that says an option was ignored or not supported.
     271      # When given -MP, icc 7.0 and 7.1 complain thusly:
     272      #   icc: Command line warning: ignoring option '-M'; no argument required
     273      # The diagnosis changed in icc 8.0:
     274      #   icc: Command line remark: option '-MP' not supported
     275      if (grep 'ignoring option' conftest.err ||
     276          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
    270277        am_cv_$1_dependencies_compiler_type=$depmode
    271278        break
     
    313320# Generate code to set up dependency tracking.   -*- Autoconf -*-
    314321
    315 # Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     322# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    316323
    317324# This program is free software; you can redistribute it and/or modify
     
    352359  # Extract the definition of DEP_FILES from the Makefile without
    353360  # running `make'.
    354   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
     361  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
    355362  test -z "$DEPDIR" && continue
    356363  # When using ansi2knr, U may be empty or an underscore; expand it
    357   U=`sed -n -e '/^U = / s///p' < "$mf"`
     364  U=`sed -n 's/^U = //p' < "$mf"`
    358365  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
    359366  # We invoke sed twice because it is the simplest approach to
    360367  # changing $(DEPDIR) to its actual value in the expansion.
    361   for file in `sed -n -e '
     368  for file in `sed -n '
    362369    /^DEP_FILES = .*\\\\$/ {
    363370      s/^DEP_FILES = //
     
    718725# Do not use -m 0755 and let people choose whatever they expect by
    719726# setting umask.
     727#
     728# We cannot accept any implementation of `mkdir' that recognizes `-p'.
     729# Some implementations (such as Solaris 8's) are not thread-safe: if a
     730# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
     731# concurrently, both version can detect that a/ is missing, but only
     732# one can create it and the other will error out.  Consequently we
     733# restrict ourselves to GNU make (using the --version option ensures
     734# this.)
    720735AC_DEFUN([AM_PROG_MKDIR_P],
    721 [if mkdir -p -- . 2>/dev/null; then
     736[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
    722737  # Keeping the `.' argument allows $(mkdir_p) to be used without
    723738  # argument.  Indeed, we sometimes output rules like
     
    732747  # directories to create, and then abort because `.' already
    733748  # exists.
    734   for d in ./-p ./--;
     749  for d in ./-p ./--version;
    735750  do
    736751    test -d $d && rmdir $d
  • orxonox/branches/dave/configure

    r2706 r2860  
    14971497fi
    14981498
    1499 if mkdir -p -- . 2>/dev/null; then
     1499if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
    15001500  # Keeping the `.' argument allows $(mkdir_p) to be used without
    15011501  # argument.  Indeed, we sometimes output rules like
     
    15101510  # directories to create, and then abort because `.' already
    15111511  # exists.
    1512   for d in ./-p ./--;
     1512  for d in ./-p ./--version;
    15131513  do
    15141514    test -d $d && rmdir $d
     
    24152415    for i in 1 2 3 4 5 6; do
    24162416      echo '#include "conftst'$i'.h"' >> sub/conftest.c
    2417       : > sub/conftst$i.h
     2417      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
     2418      # Solaris 8's {/usr,}/bin/sh.
     2419      touch sub/conftst$i.h
    24182420    done
    24192421    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    24432445       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    24442446      # icc doesn't choke on unknown options, it will just issue warnings
    2445       # (even with -Werror).  So we grep stderr for any message
    2446       # that says an option was ignored.
    2447       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
     2447      # or remarks (even with -Werror).  So we grep stderr for any message
     2448      # that says an option was ignored or not supported.
     2449      # When given -MP, icc 7.0 and 7.1 complain thusly:
     2450      #   icc: Command line warning: ignoring option '-M'; no argument required
     2451      # The diagnosis changed in icc 8.0:
     2452      #   icc: Command line remark: option '-MP' not supported
     2453      if (grep 'ignoring option' conftest.err ||
     2454          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
    24482455        am_cv_CXX_dependencies_compiler_type=$depmode
    24492456        break
     
    32463253    for i in 1 2 3 4 5 6; do
    32473254      echo '#include "conftst'$i'.h"' >> sub/conftest.c
    3248       : > sub/conftst$i.h
     3255      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
     3256      # Solaris 8's {/usr,}/bin/sh.
     3257      touch sub/conftst$i.h
    32493258    done
    32503259    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    32743283       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    32753284      # icc doesn't choke on unknown options, it will just issue warnings
    3276       # (even with -Werror).  So we grep stderr for any message
    3277       # that says an option was ignored.
    3278       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
     3285      # or remarks (even with -Werror).  So we grep stderr for any message
     3286      # that says an option was ignored or not supported.
     3287      # When given -MP, icc 7.0 and 7.1 complain thusly:
     3288      #   icc: Command line warning: ignoring option '-M'; no argument required
     3289      # The diagnosis changed in icc 8.0:
     3290      #   icc: Command line remark: option '-MP' not supported
     3291      if (grep 'ignoring option' conftest.err ||
     3292          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
    32793293        am_cv_CC_dependencies_compiler_type=$depmode
    32803294        break
     
    63676381
    63686382
    6369                                         ac_config_files="$ac_config_files Makefile console/Makefile gui/Makefile src/Makefile"
     6383                                                  ac_config_files="$ac_config_files Makefile console/Makefile gui/Makefile src/Makefile importer/Makefile"
    63706384
    63716385cat >confcache <<\_ACEOF
     
    69296943  "gui/Makefile" ) CONFIG_FILES="$CONFIG_FILES gui/Makefile" ;;
    69306944  "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     6945  "importer/Makefile" ) CONFIG_FILES="$CONFIG_FILES importer/Makefile" ;;
    69316946  "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
    69326947  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
     
    76887703  # Extract the definition of DEP_FILES from the Makefile without
    76897704  # running `make'.
    7690   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
     7705  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
    76917706  test -z "$DEPDIR" && continue
    76927707  # When using ansi2knr, U may be empty or an underscore; expand it
    7693   U=`sed -n -e '/^U = / s///p' < "$mf"`
     7708  U=`sed -n 's/^U = //p' < "$mf"`
    76947709  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
    76957710  # We invoke sed twice because it is the simplest approach to
    76967711  # changing $(DEPDIR) to its actual value in the expansion.
    7697   for file in `sed -n -e '
     7712  for file in `sed -n '
    76987713    /^DEP_FILES = .*\\\\$/ {
    76997714      s/^DEP_FILES = //
  • orxonox/branches/dave/configure.ac

    r2701 r2860  
    196196                 console/Makefile
    197197                 gui/Makefile
    198                  src/Makefile])
     198                 src/Makefile
     199                 importer/Makefile])
    199200AC_OUTPUT
  • orxonox/branches/dave/src/Makefile.am

    r2636 r2860  
    66
    77bin_PROGRAMS=orxonox
    8 orxonox_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
    98
    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
     9orxonox_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
     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
     11
    1112
    1213
  • orxonox/branches/dave/src/Makefile.in

    r2711 r2860  
    5757        command_node.$(OBJEXT) ini_parser.$(OBJEXT) keynames.$(OBJEXT) \
    5858        track.$(OBJEXT) base_entity.$(OBJEXT) game_loader.$(OBJEXT) \
    59         campaign.$(OBJEXT) story_entity.$(OBJEXT)
     59        campaign.$(OBJEXT) story_entity.$(OBJEXT) object.$(OBJEXT) \
     60        environment.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \
     61        list.$(OBJEXT)
    6062orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    6163orxonox_LDADD = $(LDADD)
     
    6365depcomp = $(SHELL) $(top_srcdir)/depcomp
    6466am__depfiles_maybe = depfiles
    65 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/base_entity.Po \
    66 @AMDEP_TRUE@    ./$(DEPDIR)/camera.Po ./$(DEPDIR)/campaign.Po \
    67 @AMDEP_TRUE@    ./$(DEPDIR)/collision.Po \
     67@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/array.Po \
     68@AMDEP_TRUE@    ./$(DEPDIR)/base_entity.Po ./$(DEPDIR)/camera.Po \
     69@AMDEP_TRUE@    ./$(DEPDIR)/campaign.Po ./$(DEPDIR)/collision.Po \
    6870@AMDEP_TRUE@    ./$(DEPDIR)/command_node.Po \
    6971@AMDEP_TRUE@    ./$(DEPDIR)/data_tank.Po \
     72@AMDEP_TRUE@    ./$(DEPDIR)/environment.Po \
    7073@AMDEP_TRUE@    ./$(DEPDIR)/game_loader.Po \
    7174@AMDEP_TRUE@    ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \
    72 @AMDEP_TRUE@    ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/player.Po \
    73 @AMDEP_TRUE@    ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/track.Po \
    74 @AMDEP_TRUE@    ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \
    75 @AMDEP_TRUE@    ./$(DEPDIR)/world_entity.Po
     75@AMDEP_TRUE@    ./$(DEPDIR)/list.Po ./$(DEPDIR)/material.Po \
     76@AMDEP_TRUE@    ./$(DEPDIR)/object.Po ./$(DEPDIR)/orxonox.Po \
     77@AMDEP_TRUE@    ./$(DEPDIR)/player.Po ./$(DEPDIR)/story_entity.Po \
     78@AMDEP_TRUE@    ./$(DEPDIR)/track.Po ./$(DEPDIR)/vector.Po \
     79@AMDEP_TRUE@    ./$(DEPDIR)/world.Po ./$(DEPDIR)/world_entity.Po
    7680CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    7781        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     
    163167AM_CXXFLAGS = "-I/usr/X11R6/include"
    164168AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib  -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS)
    165 orxonox_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
    166 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
     169orxonox_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
     170noinst_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
    167171all: all-am
    168172
     
    231235        -rm -f *.tab.c
    232236
     237@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    233238@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_entity.Po@am__quote@
    234239@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/camera.Po@am__quote@
     
    237242@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command_node.Po@am__quote@
    238243@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_tank.Po@am__quote@
     244@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/environment.Po@am__quote@
    239245@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game_loader.Po@am__quote@
    240246@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini_parser.Po@am__quote@
    241247@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keynames.Po@am__quote@
     248@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
     249@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@
     250@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@
    242251@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@
    243252@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player.Po@am__quote@
  • orxonox/branches/dave/src/campaign.cc

    r2636 r2860  
    2727Campaign::Campaign ()
    2828{
    29   this->entities = new List<StoryEntity>();
     29  this->entities = new ListTemplate<StoryEntity>();
    3030  this->isInit = false;
    3131}
     
    144144StoryEntity* Campaign::getStoryEntity(Uint32 storyID)
    145145{
    146   List<StoryEntity>* l;
     146  ListTemplate<StoryEntity>* l;
    147147  StoryEntity* entity;
    148148  l = this->entities->get_next(); 
  • orxonox/branches/dave/src/campaign.h

    r2636 r2860  
    3333
    3434 private:
    35   List<StoryEntity>* entities;
     35  ListTemplate<StoryEntity>* entities;
    3636  bool running;
    3737
  • orxonox/branches/dave/src/command_node.cc

    r2636 r2860  
    1111   ### File Specific:
    1212   main-programmer: Christian Meyer
    13    co-programmer: ...
     13   co-programmer: Patrick Boenzli
    1414*/
    1515
     
    3333CommandNode::CommandNode (int ID)
    3434{
    35   bound = new List<WorldEntity>();
     35  bound = new List();
    3636  aliases = NULL;
    3737  netID = ID;
     
    4848  bLocalInput = true;
    4949  netID = 0;
    50   bound = new List<WorldEntity>();
     50  bound = new List();
    5151  load_bindings (filename);
    5252}
     
    5959  if( aliases != NULL) free (aliases);
    6060  if( bound != NULL) delete bound;
     61}
     62
     63
     64void CommandNode::reset()
     65{
     66  this->bound->clear();
    6167}
    6268
     
    123129void CommandNode::bind (WorldEntity* entity)
    124130{
    125   bound->add (entity, LIST_ADD_NEXT, true);
     131  bound->add (entity);
    126132}
    127133
     
    132138void CommandNode::unbind (WorldEntity* entity)
    133139{
    134   bound->remove (entity, LIST_FIND_FW);
     140  bound->remove (entity);
    135141}
    136142
     
    214220}
    215221
     222
    216223void CommandNode::process_network ()
    217224{
     
    219226}
    220227
     228
    221229void CommandNode::relay (Command* cmd)
    222230{
    223   //printf("CommandNode|relay()\n");
    224   List<WorldEntity>* plist = bound;
    225231 
    226232  Orxonox *orx = Orxonox::getInstance();
     
    231237  if( bLocalInput) send_over_network (cmd);
    232238 
    233   while( (plist = plist->get_next()) != NULL)
    234     {
    235       plist->get_object()->command (cmd);
    236     }
    237 }
     239  WorldEntity* entity = bound->enumerate();
     240  while(  entity != NULL)
     241    {
     242      entity->command (cmd);
     243      entity = bound->nextElement();
     244    }
     245}
     246
    238247
    239248/**
  • orxonox/branches/dave/src/command_node.h

    r2190 r2860  
    1919//! Key aliasing structure
    2020/**
    21         This structure contains the key aliasing information, e.g. the command strings that
    22         have been bound to the keys.
     21   This structure contains the key aliasing information, e.g. the command strings that
     22   have been bound to the keys.
    2323*/
    2424typedef struct
    2525{
    26         char keys[N_STD_KEYS][CMD_LENGHT];
    27         char buttons[N_BUTTONS][CMD_LENGHT];
     26  char keys[N_STD_KEYS][CMD_LENGHT];
     27  char buttons[N_BUTTONS][CMD_LENGHT];
    2828} KeyBindings;
    2929
    3030//! Command Node
    3131/**
    32         This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is
    33         captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()).
    34         Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created
    35         with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass
    36         them on to it's WorldEntities.
     32   This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is
     33   captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()).
     34   Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created
     35   with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass
     36   them on to it's WorldEntities.
    3737*/
    3838class CommandNode {
    3939 private:
    40         bool bLocalInput;       //!< Identifies the CommandNode that processes local input
    41         int netID;      //!< Unique identifier that is used to determine between remote CommandNodes
    42         KeyBindings* aliases;
    43         List<WorldEntity>* bound;       //!< List of WorldEntites that recieve commands from this CommandNode
    44         Sint32 coord[2];
    45        
    46         void relay (Command* cmd);
    47         int* name_to_index (char* name);
    48         void process_local ();
    49         void process_network ();
    50         void send_over_network (Command* cmd);
    51        
     40  bool bLocalInput;     //!< Identifies the CommandNode that processes local input
     41  int netID;    //!< Unique identifier that is used to determine between remote CommandNodes
     42  KeyBindings* aliases;
     43  List* bound;  //!< List of WorldEntites that recieve commands from this CommandNode
     44  Sint32 coord[2];
     45 
     46
     47  void relay (Command* cmd);
     48  int* name_to_index (char* name);
     49  void process_local ();
     50  void process_network ();
     51  void send_over_network (Command* cmd);
     52 
    5253 public:
    5354  CommandNode (int ID);
    5455  CommandNode (char* filename);
    5556  ~CommandNode ();
    56  
     57
     58  void reset(); 
    5759  void load_bindings (char* filename);
    5860  void bind (WorldEntity* entity);
  • orxonox/branches/dave/src/environment.cc

    r2036 r2860  
    1616*/
    1717
    18 #include <iostream>
    19 #include <GL/glut.h>
    20 #include <stdlib.h>
    21 
    22 #include "data_tank.h"
    2318
    2419#include "environment.h"
     20#include "stdincl.h"
     21#include "world_entity.h"
     22#include "vector.h"
    2523
    2624using namespace std;
     
    3028#define LEVEL_LENGTH 500
    3129
    32 Environment::Environment ()
    33   : WorldEntity()
     30Environment::Environment () : WorldEntity()
    3431{
    3532
     
    6057Environment::~Environment () {}
    6158
     59void Environment::tick (float time) {}
    6260
     61void Environment::hit (WorldEntity* weapon, Vector loc) {}
     62
     63void Environment::destroy () {}
     64
     65void Environment::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {}
     66
     67void Environment::draw ()
     68{
     69  printf("Environment::draw()");
     70
     71  glMatrixMode(GL_MODELVIEW);
     72  glLoadIdentity();
     73  float matrix[4][4];
     74 
     75  glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
     76  get_placement()->w.matrix (matrix);
     77  glMultMatrixf ((float*)matrix);
     78
     79  glBegin(GL_TRIANGLES);
     80  glColor3f(1,1,1);
     81  glVertex3f(0,0,0.5);
     82  glVertex3f(-0.5,0,-1);
     83  glVertex3f(0.5,0,-1);
     84 
     85  glVertex3f(0,0,0.5);
     86  glVertex3f(0,0.5,-1);
     87  glVertex3f(0,-0.5,-1);
     88  glEnd();
     89   
     90  glBegin(GL_QUADS);
     91  glColor3f(0,0,1);
     92  glVertex3f(0.5,0.5,-1);
     93  glVertex3f(0.5,-0.5,-1);
     94  glVertex3f(-0.5,-0.5,-1);
     95  glVertex3f(-0.5,0.5,-1);
     96  glEnd();
     97}
     98
     99/*
    63100void Environment::paint()
    64101{
    65   /*
     102 
    66103  glPushMatrix();
    67104  //glScalef(0.5, 0.5, 1.0);
     
    95132 
    96133  glPopMatrix();
    97   */
     134 
    98135}
    99136
     
    103140}
    104141
     142*/
  • orxonox/branches/dave/src/environment.h

    r2036 r2860  
    1 
    2 
    3 
    41#ifndef ENVIRONEMENT_H
    52#define ENVIRONEMENT_H
    63
    7 
    84#include "world_entity.h"
    95
    10 class Environment : public WorldEntity {
     6
     7class Environment : public WorldEntity
     8{
     9  friend class World;
    1110
    1211 private:
     
    2120  ~Environment ();
    2221
    23   void paint(void);
    24   void drawEnvironment(void);
    25   void setEnvPosition(void);
    26   void getEnvPosition(void);
     22 
     23  virtual void tick (float time);
     24  virtual void hit (WorldEntity* weapon, Vector loc);
     25  virtual void destroy ();
     26  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
     27  virtual void draw ();
    2728
    2829};
  • orxonox/branches/dave/src/list.h

    r2636 r2860  
    1 /*
    2    orxonox - the future of 3D-vertical-scrollers
    3 
    4    Copyright (C) 2004 orx
    5 
    6    This program is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 2, or (at your option)
    9    any later version.
    10 
    11    ### File Specific:
    12    main-programmer: Christian Meyer
    13 
    14    ADDONS/FIXES:
    15  
    16    Patrick Boenzli     :          Implemented getSize() function
    17 */
    18 
    19 
    20 /*!
    21   \file list.h
    22   \brief Contains a template for a doubly linked list
    23 */
    241
    252#ifndef LIST_H
    263#define LIST_H
    274
    28 #include "stdlib.h"
     5#include "stdincl.h"
    296
    307//! An enum to list all the modes available when adding an object to a List
    31 enum ADDMODE {LIST_ADD_NEXT, LIST_ADD_PREV, LIST_ADD_FIRST, LIST_ADD_LAST};
     8//enum ADDMODE {LIST_ADD_FIRST, LIST_ADD_LAST};
    329//! An enum to list the two searching directions available when removing an object from a List
    33 enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
    34 
    35 //! A generic doubly linked list
    36 template<class T> class List
    37 {
    38   T* object;
    39   List<T>* next;
    40   List<T>* prev;
    41   bool bReference;
    42   int size;
     10//enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
     11
     12
     13
     14class WorldEntity;
     15
     16class List {
     17
     18 public:
     19  List ();
     20  ~List ();
     21
     22  void add(WorldEntity* entity);
     23  void remove(WorldEntity* entity);
     24  void clear();
     25  WorldEntity* firstElement();
     26  bool isEmpty();
     27  int getSize();
     28  WorldEntity* enumerate();
     29  WorldEntity* nextElement();
     30  WorldEntity* toArray();
     31  void debug();
     32
     33 private:
     34  struct listElement
     35  {
     36    listElement* prev;
     37    WorldEntity* curr;
     38    listElement* next;
     39  };
     40  Uint32 size;
     41  listElement* first;
     42  listElement* last;
     43  listElement* currentEl;
     44
     45
     46};
     47
     48class Iterator
     49{
     50
     51 public:
     52  bool hasNext();
     53  WorldEntity* next();
     54
     55 private:
     56
     57};
     58
     59
     60template<class T> class tList
     61{
     62 private:
     63  struct listElement
     64  {
     65    listElement* prev;
     66    T* curr;
     67    listElement* next;
     68  };
     69
     70  Uint32 size;
     71  listElement* first;
     72  listElement* last;
     73  listElement* currentEl;
    4374 
    4475 public:
    45   List (T* obj, List<T>* n, List<T>* p, bool bRef);
    46   ~List ();
     76  tList ();
     77  ~tList ();
    4778 
    48   int add (T* obj, ADDMODE mode, bool bRef);
    49   T* get_object();
    50   List<T>* get_next ();
    51   List<T>* get_previous ();
    52   List<T>* get_last ();
    53   List<T>* get_first ();
    54   void set_next (List<T>* ptr);
    55   void set_prev (List<T>* ptr);
    56   int remove (T* obj, FINDMODE mode);
     79
     80  void add(WorldEntity* entity);
     81  void remove(WorldEntity* entity);
     82  void clear();
     83  T* firstElement();
     84  bool isEmpty();
    5785  int getSize();
     86  T* enumerate();
     87  T* nextElement();
     88  T* toArray();
     89  void debug();
    5890};
    5991
    6092
    61 /**
    62   \brief Standard constructor
    63  
    64   Call this without any parameters to generate a new List which can be filled with content.
    65   DO NOT create a List element that contains an object on your own, you'll lose the data
    66   contained in that object and will have trouble removing the list from your memory.
    67 */
    68 template<class T>
    69 List<T>::List (T* obj = NULL, List<T>* n = NULL, List<T>* p = NULL, bool bRef = false)
    70 {
    71   object = obj;
    72   next = n;
    73   prev = p;
    74   bReference = bRef;
    75   if(obj != NULL)
    76     ++size;
    77 }
    78 
    79 /**
    80   \brief Standard destructor
    81  
    82   Call this on the initially generated base List element to remove the whole List from the memory.
    83   You can safely do this to any List element you want without messing up the rest of the List, but keep in mind
    84   that the contained object will be deleted as well when bRef had been set to false.
    85 */
    86 template<class T>
    87 List<T>::~List ()
    88 {
    89   if (object == NULL) // deleted foot node => disband the list
    90   {
    91     while( next != NULL)
     93template<class T>
     94tList<T>::tList ()
     95{
     96  this->first = NULL;
     97  this->last = NULL;
     98  this->size = 0;
     99}
     100
     101template<class T>
     102tList<T>::~tList ()
     103{}
     104
     105template<class T>
     106void tList<T>::add(WorldEntity* entity)
     107{
     108  printf("tList<T>::add() \n");
     109  listElement* el = new listElement;
     110  el->prev = this->last;
     111  el->curr = entity;
     112  el->next = NULL;
     113
     114  this->last = el;
     115
     116  if(this->size == 0) this->first = el;
     117  else el->prev->next = el;
     118  this->size++;
     119}
     120
     121
     122template<class T>
     123void tList<T>::remove(WorldEntity* entity)
     124{
     125  this->currentEl = this->first;
     126  listElement* te;
     127  while( this->currentEl != NULL)
    92128    {
    93       delete next;
     129      if( this->currentEl->curr == entity)
     130        {
     131          printf("tList<T>::remove() - object found\n");
     132         
     133          if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
     134          else this->currentEl->prev->next = this->currentEl->next;
     135
     136          if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
     137          else this->currentEl->next->prev = this->currentEl->prev;
     138
     139          te = this->currentEl->next;
     140          delete this->currentEl;
     141          this->currentEl = te;
     142          return;
     143        }
     144      this->currentEl = this->currentEl->next;
    94145    }
    95     while( prev != NULL)
     146}
     147
     148
     149template<class T>
     150void tList<T>::clear()
     151{
     152  printf("tList<T>::clear() - clearing all world objects, releasing mem\n");
     153  this->currentEl = this->first;
     154  while(this->currentEl != NULL)
    96155    {
    97       delete prev;
     156      listElement* le = this->currentEl->next;
     157      delete this->currentEl->curr;
     158      delete this->currentEl;
     159      this->currentEl = le;
    98160    }
    99   }
    100   else
    101   {
    102     if (prev != NULL) prev->set_next (next);
    103     if (next != NULL) next->set_prev (prev);
    104     if (!bReference) delete object;
    105   }
    106 }
    107  
    108 /**
    109   \brief Add an object to the List
    110   \param obj: A pointer to an allocated object
    111   \param mode: A Value of ADDMODE (default: LIST_ADD_NEXT)
    112   \param bRef: Sets whether the element is serving as a storage point or a simple listing (default: false)
    113   \return 0 if the operation succeded, -1 if the element could not be added
    114  
    115   This adds a new List element to the chain. The mode parameter can be used to specify
    116   the location where the element should be added. LIST_ADD_NEXT will add the new element directly
    117   after the base element. LIST_ADD_PREV will add the new element directly before the base element.
    118   LIST_ADD_FIRST will add the element at the beginning of the List whereas LIST_ADD_LAST will add
    119   it to the end of the chain. If the bRef parameter is set to true, the object pointer will not be deleted
    120   when the element containing that object is deleted, thus the List can be used for temporary listings as
    121   well as permanent data storage.
    122 */
    123 template<class T>
    124 int List<T>::add (T* obj, ADDMODE mode = LIST_ADD_NEXT, bool bRef = false)
    125 {
    126   List<T>* p;
    127   if( obj == NULL) return -1;
    128   switch (mode)
    129   {
    130     case LIST_ADD_NEXT:
    131       p = new List<T>( obj, next, this, bRef);
    132       if( next != NULL) next->set_prev (p);
    133       next = p;
    134       break;
    135     case LIST_ADD_PREV:
    136       p = new List<T>( obj, this, prev, bRef);
    137       if( prev != NULL) prev->set_next (p);
    138       prev = p;
    139       break;
    140     case LIST_ADD_FIRST:
    141       if (prev == NULL) prev = new List<T> (obj, this, NULL, bRef);
    142       else return prev->add (obj, mode, bRef);
    143       break;
    144     case LIST_ADD_LAST:
    145       if (next == NULL) next = new List<T> (obj, NULL, this, bRef);
    146       else return next->add (obj, mode, bRef);
    147       break;
    148     default:
    149         return -1;
    150       break;
    151   }
    152   ++size;
    153   return 0;
    154 }
    155 
    156 /**
    157   \brief Get the next element of the List
    158   \return The List element after the current List element
    159 */
    160 template<class T>
    161 List<T>* List<T>::get_next ()
    162 {
    163   return next;
    164 }
    165  
    166 /**
    167   \brief Get the previous element of the List
    168   \return The List element before the current List element
    169 */
    170 template<class T>
    171 List<T>* List<T>::get_previous ()
    172 {
    173   return prev;
    174 }
    175 
    176 /**
    177   \brief Get the last element of the List
    178   \return The last List element
    179 */
    180 template<class T>
    181 List<T>* List<T>::get_last ()
    182 {
    183   if (next == NULL) return this;
    184   else return next->get_last();
    185 }
    186 
    187 /**
    188   \brief Get the first element of the List
    189   \return The first List element
    190 */
    191 template<class T>
    192 List<T>* List<T>::get_first ()
    193 {
    194   if (prev == NULL) return this;
    195   else return prev->get_first();
    196 }
    197 
    198 /**
    199   \brief Removes a certain element from the List
    200   \param obj: A pointer to the object that should be removed
    201   \param mode: A value of FINDMODE
    202   \return 0 if the element was found and removed, -1 if the element was not found
    203  
    204   This searches the part of the List specified with mode for the object in question.
    205   When the object is found it is deleted and the List element is removed from the chain.
    206   If mode is LIST_FIND_FW all elements AFTER the base element are searched, if mode is
    207   LIST_FIND_BW all elements BEFORE the base element are searched. Note that the object
    208   contained within the List element is NOT deleted when bRef was set to true.
    209 */
    210 template<class T>
    211 int List<T>::remove (T* obj, FINDMODE mode = LIST_FIND_FW)
    212 {
    213   if (obj == NULL) return -1;
    214   else
    215   {
    216     switch (mode)
    217     {
    218       case LIST_FIND_BW:
    219         if (prev == NULL) return -1;
    220         else
    221         {
    222           if( prev->get_object() == obj)
    223           {
    224             delete prev;
    225           }
    226           else
    227           {
    228             return prev->remove( obj, mode);
    229           }
    230         }
    231         break;
    232       case LIST_FIND_FW:
    233         if (next == NULL) return -1;
    234         else
    235         {
    236           if( next->get_object() == obj)
    237           {
    238             delete next;
    239           }
    240           else
    241           {
    242             return next->remove( obj, mode);
    243           }
    244         }
    245         break;
    246       default:
    247         return -1;
    248     }
    249   }
    250   --size;
    251   return 0;
    252 }
    253 
    254 /**
    255   \brief Set the next element of a List element
    256   \param ptr: A pointer to the new next element
    257    
    258   Sets the next element of a List element... Better not touch this, it can really mess up a List.
    259 */
    260 template<class T>
    261 void List<T>::set_next (List<T>* ptr)
    262 {
    263   next = ptr;
    264 }
    265 
    266 /**
    267   \brief Set the prev element of a List element
    268   \param ptr: A pointer to the new previous element
    269    
    270   Sets the previous element of a List element... Better not touch this, it can really mess up a List.
    271 */
    272 template<class T>
    273 void List<T>::set_prev (List<T>* ptr)
    274 {
    275   prev = ptr;
    276 }
    277 
    278 /**
    279   \brief Get the pointer to the object the element is containing
    280   \return The contained object (will be NULL if called on the base element).
    281 */
    282 template<class T>
    283 T* List<T>::get_object()
    284 {
    285   return object;
    286 }
    287 
    288 
    289 /**
    290   \brief Returns the current size of the List
    291   \return Size of List
    292 */
    293 template<class T>
    294 int List<T>::getSize()
     161  this->first = NULL;
     162  this->last = NULL;
     163  this->size = 0;
     164}
     165
     166
     167template<class T>
     168T* tList<T>::firstElement()
     169{
     170  return this->first->curr;
     171}
     172
     173
     174template<class T>
     175bool tList<T>::isEmpty()
     176{
     177  return (this->size==0)?true:false;
     178}
     179
     180
     181template<class T>
     182int tList<T>::getSize()
    295183{
    296184  return this->size;
    297185}
    298186
     187
     188template<class T>
     189T* tList<T>::enumerate()
     190{
     191  if(this->size == 0) return NULL;
     192  this->currentEl = this->first;
     193  return this->currentEl->curr;
     194}
     195
     196
     197template<class T>
     198T* tList<T>::nextElement()
     199{
     200  if(this->size == 0) return NULL;
     201  this->currentEl = this->currentEl->next;
     202  if(this->currentEl == NULL) return NULL;
     203  return this->currentEl->curr;
     204}
     205
     206
     207template<class T>
     208T* tList<T>::toArray()
     209{}
     210
    299211#endif
    300 
  • orxonox/branches/dave/src/orxonox.cc

    r2636 r2860  
    158158  glClearColor(0.0, 0.0, 0.0, 0.0);
    159159  glEnable(GL_DEPTH_TEST);
    160   glEnable(GL_COLOR);
    161   glShadeModel(GL_FLAT);
     160 
     161  // LIGHTING
     162  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
     163  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
     164  GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
     165
     166  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
     167  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
     168  glEnable(GL_LIGHTING);
     169  glEnable(GL_LIGHT0);
     170  glEnable(GL_DEPTH_TEST);
     171  glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
     172  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
     173   
     174  //  glEnable(GL_COLOR);
     175  //  glShadeModel(GL_SMOOTH);
    162176 
    163177  // create camera
  • orxonox/branches/dave/src/player.cc

    r2730 r2860  
    2525Player::Player(bool isFree) : WorldEntity(isFree)
    2626{
     27
     28  obj = new Object ("reaphigh.obj");
     29  /*
    2730  objectList = glGenLists(1);
    2831  glNewList (objectList, GL_COMPILE);
     
    4851 
    4952  glEndList ();
    50 
     53  */
    5154}
    5255
     
    5861void Player::post_spawn ()
    5962{
    60         travel_speed = 15.0;
    61         velocity = Vector();
    62         bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    63         bFire = false;
    64         acceleration = 10.0;
    65         set_collision (new CollisionCluster (1.0, Vector(0,0,0)));
     63  travel_speed = 15.0;
     64  velocity = Vector();
     65  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     66  bFire = false;
     67  acceleration = 10.0;
     68  set_collision (new CollisionCluster (1.0, Vector(0,0,0)));
    6669}
    6770
     
    104107  glMultMatrixf ((float*)matrix);
    105108 
    106   glCallList (objectList);
     109  glMatrixMode (GL_MODELVIEW);
     110  glRotatef (-90, 0,1,0);
     111  obj->draw();
     112  //  glCallList (objectList);
    107113
     114 
    108115 
    109116  //printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z);
  • orxonox/branches/dave/src/player.h

    r2730 r2860  
    88
    99#include "world_entity.h"
     10#include "object.h"
    1011
    1112//! Basic controllable WorldEntity
     
    3738  float acceleration;
    3839  GLuint objectList;
     40  Object* obj;
    3941 
    4042  void move (float time);
  • orxonox/branches/dave/src/stdincl.h

    r2636 r2860  
    1515#include "coordinates.h"
    1616#include "list.h"
     17#include "list_template.h"
    1718#include "error.h"
    1819#include "message_structures.h"
  • orxonox/branches/dave/src/vector.cc

    r2551 r2860  
    3333{
    3434  Vector r;
    35  
     35
    3636  r.x = x + v.x;
    3737  r.y = y + v.y;
  • orxonox/branches/dave/src/world.cc

    r2731 r2860  
    2222#include "command_node.h"
    2323#include "camera.h"
     24#include "environment.h"
    2425
    2526using namespace std;
     
    3536  this->worldName = name;
    3637  this->debugWorldNr = -1;
    37   this->entities = new List<WorldEntity>();
     38  this->entities = new tList<WorldEntity>();
    3839}
    3940
     
    4243  this->debugWorldNr = worldID;
    4344  this->worldName = NULL;
    44   this->entities = new List<WorldEntity>();
     45  this->entities = new tList<WorldEntity>();
    4546}
    4647
     
    7475  this->bQuitCurrentGame = true;
    7576  this->localCamera->setWorld(NULL);
     77  this->entities->clear();
     78  Orxonox::getInstance()->get_localinput()->reset();
    7679  this->~World();
    7780}
     
    98101            this->pathnodes = new Vector[6];
    99102            this->pathnodes[0] = Vector(0, 0, 0);
    100             this->pathnodes[1] = Vector(-100, 40, 0);
    101             this->pathnodes[2] = Vector(-100, 140, 0);
    102             this->pathnodes[3] = Vector(0, 180, 0);
    103             this->pathnodes[4] = Vector(100, 140, 0);
    104             this->pathnodes[5] = Vector(100, 40, 0);
     103            this->pathnodes[1] = Vector(1000, 0, 0);
     104            //      this->pathnodes[2] = Vector(-100, 140, 0);
     105            //      this->pathnodes[3] = Vector(0, 180, 0);
     106            //      this->pathnodes[4] = Vector(100, 140, 0);
     107            //      this->pathnodes[5] = Vector(100, 40, 0);
    105108           
    106109            // create the tracks
    107             this->tracklen = 6;
    108             this->track = new Track[6];
     110            this->tracklen = 2;
     111            this->track = new Track[2];
    109112            for( int i = 0; i < this->tracklen; i++)
    110113              {
     
    113116           
    114117            // create a player
    115             //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>();
    116118            WorldEntity* myPlayer = new Player();
    117119            this->spawn(myPlayer);
     
    125127            this->localCamera = new Camera(this);
    126128            this->getCamera()->bind (myPlayer);
     129
     130            Placement* plc = new Placement;
     131            plc->r = Vector(100, 10, 10);
     132            plc->w = Quaternion();
     133            WorldEntity* env = new Environment();
     134            this->spawn(env, plc);
     135
    127136            break;
    128137          }
     
    174183  glNewList (objectList, GL_COMPILE);
    175184  glLoadIdentity();
     185  glColor3f(1.0,0,0);
     186  glBegin(GL_QUADS);
     187  float height [500][50];
     188  Vector normal_vectors[500][50];
     189  float size = 2;
     190    for(int i=0;i<400;i+=1){
     191                for(int j=0;j<50;j+=1){
     192        normal_vectors[i][j].x=0;
     193    normal_vectors[i][j].y=1;
     194        normal_vectors[i][j].z=0;
     195       
     196       
     197       
     198        }
     199        }
     200       
     201       
     202        for ( int i = 0; i<400; i+=1)
     203      {
     204        for (int j = 0; j<50;j+=1)
     205          {
     206            //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
     207            height[i][j]=(sin((float)j/3)*rand()*i/182400)*.2;
     208          }
     209      }
     210         for(int a=0;a<2;a+=1){
     211         for (int i=1;i<399 ;i+=1 ){
     212                 for(int j=1;j<49;j+=1){
     213                         height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
     214
     215                 }
     216         }
     217         }
     218    //Berechnung von normalen Vektoren
     219
     220        for(int i=1;i<399;i+=1){
     221    for(int j=1;j<49 ;j+=1)
     222
     223    {
     224                Vector* v1 = new Vector (size*i,        size*(j-25),      height[i][j]-20 );
     225            Vector* v2 = new Vector (size*(i+1),    size*(j-25),      height[i+1][j]-20);
     226            Vector* v3 = new Vector (size*(i),    size*(j-24),  height[i][j+1]-20);
     227            Vector* v4 = new Vector (size*(i-1),        size*(j-25),  height[i-1][j]-20);
     228                Vector* v5 = new Vector (size*(i), size*(j-26), height[i][j-1]-20);
     229               
     230                Vector c1 = *v1 - *v2;
     231            Vector c2 = *v1 - *v3;
     232            Vector c3= *v1 - *v4;
     233            Vector c4 = *v1 - *v5;
     234            normal_vectors[i][j]=c1.cross(*v1-*v3)+c2.cross(*v1-*v4)+c3.cross(*v1-*v5)+c4.cross(*v1-*v2);
     235                normal_vectors[i][j].normalize();
     236           
     237   
     238       
     239       
     240        }
     241        }
     242        int snowheight=3;
     243        for ( int i = 0; i<400; i+=1)
     244      {
     245        for (int j = 0; j<50;j+=1)
     246          {       
     247            Vector* v1 = new Vector (size*i,        size*(j-25),      height[i][j]-20 );
     248            Vector* v2 = new Vector (size*(i+1),    size*(j-25),      height[i+1][j]-20);
     249            Vector* v3 = new Vector (size*(i+1),    size*(j-24),  height[i+1][j+1]-20);
     250            Vector* v4 = new Vector (size*(i),        size*(j-24),  height[i][j+1]-20);
     251            float a[3];
     252                if(height[i][j]<snowheight){
     253                a[0]=0;
     254                a[1]=1.0-height[i][j]/10-.3;
     255                a[2]=0;
     256                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     257                }
     258                else{
     259                a[0]=1.0;
     260                a[1]=1.0;
     261                a[2]=1.0;
     262                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     263
     264                }
     265                glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
     266            glVertex3f(v1->x, v1->y, v1->z);
     267                if(height[i+1][j]<snowheight){
     268                a[0]=0;
     269                a[1] =1.0-height[i+1][j]/10-.3;
     270                a[2]=0;
     271                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     272            }
     273                else{
     274                a[0]=1.0;
     275                a[1]=1.0;
     276                a[2]=1.0;
     277                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     278               
     279                }
     280                glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
     281            glVertex3f(v2->x, v2->y, v2->z);
     282                if(height[i+1][j+1]<snowheight){
     283                a[0]=0;
     284                a[1] =1.0-height[i+1][j+1]/10-.3;
     285                a[2]=0;
     286                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     287            }
     288                else{
     289                a[0]=1.0;
     290                a[1]=1.0;
     291                a[2]=1.0;
     292                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     293               
     294               
     295                }
     296                glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
     297            glVertex3f(v3->x, v3->y, v3->z);
     298                if(height[i][j+1]<snowheight){
     299                a[0]=0;
     300                a[1] =1.0-height[i+1][j+1]/10-.3;
     301                a[2]=0;
     302                glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     303            }
     304                else{
     305                        a[0]=1.0;
     306                a[1]=1.0;
     307                a[2]=1.0;
     308                        glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     309                }
     310                glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
     311            glVertex3f(v4->x, v4->y, v4->z);
     312
     313          }
     314      }
     315glEnd();
     316/* 
    176317  glBegin(GL_LINES);
    177  
    178318  for( float x = -128.0; x < 128.0; x += 25.0)
    179319    {
     
    213353     
    214354    }
    215  
     355  */ 
    216356  //draw track
     357  glBegin(GL_LINES);
    217358  glColor3f(0,1,1);
    218359  for( int i = 0; i < tracklen; i++)
     
    235376void World::collide ()
    236377{
    237   List<WorldEntity> *a, *b;
     378  /*
     379  List *a, *b;
    238380  WorldEntity *aobj, *bobj;
    239  
    240   a = entities->get_next();
     381   
     382  a = entities;
    241383 
    242384  while( a != NULL)
    243385    {
    244       aobj = a->get_object();
     386      aobj = a->nextElement();
    245387      if( aobj->bCollide && aobj->collisioncluster != NULL)
    246388        {
    247           b = a->get_next();
     389          b = a->nextElement();
    248390          while( b != NULL )
    249391            {
    250               bobj = b->get_object();
     392              bobj = b->nextElement();
    251393              if( bobj->bCollide && bobj->collisioncluster != NULL )
    252394                {
     
    260402                  }
    261403                }
    262               b = b->get_next();
     404              b = b->nextElement();
    263405            }
    264406        }
    265       a = a->get_next();
    266     }
     407      a = a->enumerate();
     408    }
     409  */
    267410}
    268411
     
    275418 
    276419  // draw entities
    277   List<WorldEntity> *l;
    278420  WorldEntity* entity;
    279421 
    280   l = entities->get_next(); 
    281   while( l != NULL )
     422  entity = this->entities->enumerate();
     423  while( entity != NULL )
    282424    {
    283       entity = l->get_object();
    284425      if( entity->bDraw ) entity->draw();
    285       l = l->get_next();
     426      entity = this->entities->nextElement();
    286427    }
    287428 
     
    303444void World::update ()
    304445{
    305   List<WorldEntity> *l;
     446  //List<WorldEntity> *l;
    306447  WorldEntity* entity;
    307448  Location* loc;
     
    309450  Uint32 t;
    310451 
    311   l = entities->get_next(); 
    312   while( l != NULL )
     452  //  l = entities->enumerate();
     453  entity = this->entities->enumerate();
     454  while( entity != NULL )
    313455    {
    314       entity = l->get_object();
     456
    315457     
    316458      if( !entity->isFree() )
     
    350492        }
    351493     
    352       l = l->get_next();
     494      entity = entities->nextElement();
    353495    }
    354496 
     
    361503void World::time_slice (Uint32 deltaT)
    362504{
    363   List<WorldEntity> *l;
     505  //List<WorldEntity> *l;
    364506  WorldEntity* entity;
    365507  float seconds = deltaT;
     
    367509  seconds /= 1000;
    368510 
    369   l = entities->get_next();
    370   while( l != NULL)
     511  entity = entities->enumerate();
     512  while( entity != NULL)
    371513    {
    372       entity = l->get_object();
    373514      entity->tick (seconds);
    374       l = l->get_next();
    375     }
    376  
     515      entity = entities->nextElement();
     516    }
     517
    377518  for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    378519}
     
    411552void World::debug()
    412553{
    413   List<WorldEntity> *l;
     554  //List<WorldEntity> *l;
    414555  WorldEntity* entity;
    415556 
    416557  printf("counting all entities\n");
    417   l = entities->get_next(); 
    418   while( l != NULL )
     558  printf("World::debug() - enumerate()\n");
     559  entity = entities->enumerate(); 
     560  while( entity != NULL )
    419561    {
    420       entity = l->get_object();
    421562      if( entity->bDraw ) printf("got an entity\n");
    422       l = l->get_next();
     563      entity = entities->nextElement();
    423564    }
    424565}
     
    445586      // Draw
    446587      display();
     588 
     589      //for(int i = 0; i < 1000000; i++){}
     590
    447591    }
    448592  printf("World|Exiting the main loop\n");
     
    477621    {
    478622      Uint32 dt = currentFrame - this->lastFrame;
    479       /*
     623     
    480624      if(dt > 0)
    481625        {
     
    485629      else
    486630        {
    487           printf("fps = 1000\n");
    488         }
    489       */
     631          printf("fps = 1000 but 0ms!\n");
     632        }
     633     
    490634      this->time_slice (dt);
    491635      this->update ();
     
    545689  Location* loc = NULL;
    546690  WorldEntity* owner;
    547   //T* entity = new T();
    548   entities->add (entity, LIST_ADD_NEXT);
    549   //if( loc == NULL)
    550   //{
    551       zeroloc.dist = 0;
    552       zeroloc.part = 0;
    553       zeroloc.pos = Vector();
    554       zeroloc.rot = Quaternion();
    555       loc = &zeroloc;
    556       //}
     691
     692  entities->add (entity);
     693  zeroloc.dist = 0;
     694  zeroloc.part = 0;
     695  zeroloc.pos = Vector();
     696  zeroloc.rot = Quaternion();
     697  loc = &zeroloc;
    557698  entity->init (loc, owner);
    558699  if (entity->bFree)
     
    561702    }
    562703  entity->post_spawn ();
     704}
     705
     706
     707void World::spawn(WorldEntity* entity, Location* loc)
     708{
     709  Location zeroLoc;
     710  WorldEntity* owner;
     711  this->entities->add (entity);
     712  if( loc == NULL)
     713    {
     714      zeroLoc.dist = 0;
     715      zeroLoc.part = 0;
     716      zeroLoc.pos = Vector();
     717      zeroLoc.rot = Quaternion();
     718      loc = &zeroLoc;
     719    }
     720  entity->init (loc, owner);
     721  if (entity->bFree)
     722    {
     723      this->track[loc->part].map_coords( loc, entity->get_placement());
     724    }
     725  entity->post_spawn ();
    563726  //return entity;
    564727}
     728
     729
     730void World::spawn(WorldEntity* entity, Placement* plc)
     731{
     732  Placement zeroPlc;
     733  WorldEntity* owner;
     734  if( plc == NULL)
     735    {
     736      zeroPlc.r = Vector();
     737      zeroPlc.w = Quaternion();
     738      plc = &zeroPlc;
     739    }
     740  this->entities->add (entity);
     741  entity->init (plc, owner);
     742  entity->post_spawn ();
     743  //return entity;
     744}
  • orxonox/branches/dave/src/world.h

    r2731 r2860  
    4949  bool system_command (Command* cmd);
    5050  Camera* getCamera();
    51   //private:
    5251
    5352  void spawn(WorldEntity* entity);
     53  void spawn(WorldEntity* entity, Location* loc);
     54  void spawn(WorldEntity* entity, Placement* plc);
    5455
    55   List<WorldEntity>* entities;
     56  tList<WorldEntity>* entities;
    5657 
    5758  // base level data
  • orxonox/branches/dave/src/world_entity.cc

    r2190 r2860  
    3636WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
    3737{
    38         collisioncluster = NULL;
    39         owner = NULL;
     38  this->bDraw = true;
     39  collisioncluster = NULL;
     40  owner = NULL;
    4041}
    4142
     
    4546WorldEntity::~WorldEntity ()
    4647{
    47         if( collisioncluster != NULL) delete collisioncluster;
     48  if( collisioncluster != NULL) delete collisioncluster;
    4849}
    4950
    5051/**
    51         \brief get the Location of the WorldEntity
    52         \return a pointer to location
     52   \brief get the Location of the WorldEntity
     53   \return a pointer to location
    5354*/
    5455Location* WorldEntity::get_location ()
    5556{
    56         return &loc;
     57  return &loc;
    5758}
    5859
    5960/**
    60         \brief get the Placement of the WorldEntity
    61         \return a pointer to placement
     61   \brief get the Placement of the WorldEntity
     62   \return a pointer to placement
    6263*/
    6364Placement* WorldEntity::get_placement ()
    6465{
    65         return &place;
     66  return &place;
    6667}
    6768
    6869/**
    69         \brief query whether the WorldEntity in question is free
    70         \return true if the WorldEntity is free or false if it isn't
     70   \brief query whether the WorldEntity in question is free
     71   \return true if the WorldEntity is free or false if it isn't
    7172*/
    7273bool WorldEntity::isFree ()
     
    7677
    7778/**
    78         \brief set the WorldEntity's collision hull
    79         \param newhull: a pointer to a completely assembled CollisionCluster
    80        
    81         Any previously assigned collision hull will be deleted on reassignment
     79   \brief set the WorldEntity's collision hull
     80   \param newhull: a pointer to a completely assembled CollisionCluster
     81   
     82   Any previously assigned collision hull will be deleted on reassignment
    8283*/
    8384void WorldEntity::set_collision (CollisionCluster* newhull)
    8485{
    85         if( newhull == NULL) return;
    86         if( collisioncluster != NULL) delete collisioncluster;
    87         collisioncluster = newhull;
     86  if( newhull == NULL) return;
     87  if( collisioncluster != NULL) delete collisioncluster;
     88  collisioncluster = newhull;
    8889}
    8990
    9091/**
    91         \brief this method is called every frame
    92         \param time: the time in seconds that has passed since the last tick
    93        
    94         Handle all stuff that should update with time inside this method (movement, animation, etc.)
     92   \brief this method is called every frame
     93   \param time: the time in seconds that has passed since the last tick
     94   
     95   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    9596*/
    9697void WorldEntity::tick(float time)
     
    100101/**
    101102   \brief the entity is drawn onto the screen with this function
    102 
     103   
    103104   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.
    104105*/
     
    108109
    109110/**
    110         \brief this function is called, when two entities collide
    111         \param other: the world entity with whom it collides
    112         \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
    113         \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
     111   \brief this function is called, when two entities collide
     112   \param other: the world entity with whom it collides
     113   \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
     114   \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
    114115
    115         Implement behaviour like damage application or other miscellaneous collision stuff in this function
     116   Implement behaviour like damage application or other miscellaneous collision stuff in this function
    116117*/
    117118void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
     
    135136
    136137/**
    137         \brief basic initialisation for bound Entities
     138   \brief basic initialisation for bound Entities
    138139*/
    139140void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner)
    140141{
    141         loc = *spawnloc;
    142         owner = spawnowner;
     142  loc = *spawnloc;
     143  owner = spawnowner;
    143144}
    144145
    145146/**
    146         \brief basic initialisation for free Entities
     147   \brief basic initialisation for free Entities
    147148*/
    148149void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner)
    149150{
    150         place = *spawnplc;
    151         owner = spawnowner;
     151  place = *spawnplc;
     152  owner = spawnowner;
    152153}
    153154
    154155/**
    155         \brief this is called immediately after the Entity has been constructed and initialized
    156        
    157         Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
    158         DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
     156   \brief this is called immediately after the Entity has been constructed and initialized
     157   
     158   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
     159   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
    159160*/
    160161void WorldEntity::post_spawn ()
     
    163164
    164165/**
    165         \brief this handles incoming command messages
    166         \param cmd: a pointer to the incoming Command structure
    167        
    168         Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
    169         to send commands from one WorldEntity to another.
     166   \brief this handles incoming command messages
     167   \param cmd: a pointer to the incoming Command structure
     168   
     169   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
     170   to send commands from one WorldEntity to another.
    170171*/
    171172void WorldEntity::command (Command* cmd)
     
    174175
    175176/**
    176         \brief this is called by the local Camera to determine the point it should look at on the WorldEntity
    177         \param locbuf: a pointer to the buffer to fill with a location to look at
     177   \brief this is called by the local Camera to determine the point it should look at on the WorldEntity
     178   \param locbuf: a pointer to the buffer to fill with a location to look at
    178179       
    179         You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how
    180         to look at the location you return with this.
     180   You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how
     181   to look at the location you return with this.
    181182*/
    182183void WorldEntity::get_lookat (Location* locbuf)
     
    185186
    186187/**
    187         \brief this method is called by the world if the WorldEntity leaves valid gamespace
    188        
    189         For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    190         place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
     188   \brief this method is called by the world if the WorldEntity leaves valid gamespace
     189   
     190   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
     191   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    191192*/
    192193void WorldEntity::left_world ()
Note: See TracChangeset for help on using the changeset viewer.