Changeset 2707 in orxonox.OLD for orxonox/branches/buerli/src
- Timestamp:
- Nov 3, 2004, 12:29:03 AM (20 years ago)
- Location:
- orxonox/branches/buerli/src
- Files:
-
- 15 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/buerli/src/Makefile.in
r2685 r2707 1 # Makefile.in generated by automake 1. 7.9from Makefile.am.1 # Makefile.in generated by automake 1.8.5 from Makefile.am. 2 2 # @configure_input@ 3 3 4 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 20035 # Free Software Foundation, Inc.4 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 # 2003, 2004 Free Software Foundation, Inc. 6 6 # This Makefile.in is free software; the Free Software Foundation 7 7 # gives unlimited permission to copy and/or distribute it, … … 14 14 15 15 @SET_MAKE@ 16 17 18 SOURCES = $(orxonox_SOURCES) 16 19 17 20 srcdir = @srcdir@ … … 22 25 pkgincludedir = $(includedir)/@PACKAGE@ 23 26 top_builddir = .. 24 25 27 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 26 28 INSTALL = @INSTALL@ … … 36 38 PRE_UNINSTALL = : 37 39 POST_UNINSTALL = : 40 bin_PROGRAMS = orxonox$(EXEEXT) 41 subdir = src 42 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 43 $(srcdir)/Makefile.in INSTALL 44 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 45 am__aclocal_m4_deps = $(top_srcdir)/configure.ac 46 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 47 $(ACLOCAL_M4) 48 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 49 CONFIG_HEADER = $(top_builddir)/config.h 50 CONFIG_CLEAN_FILES = 51 am__installdirs = "$(DESTDIR)$(bindir)" 52 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 53 PROGRAMS = $(bin_PROGRAMS) 54 am_orxonox_OBJECTS = orxonox.$(OBJEXT) world.$(OBJEXT) \ 55 player.$(OBJEXT) data_tank.$(OBJEXT) world_entity.$(OBJEXT) \ 56 vector.$(OBJEXT) camera.$(OBJEXT) collision.$(OBJEXT) \ 57 command_node.$(OBJEXT) ini_parser.$(OBJEXT) keynames.$(OBJEXT) \ 58 track.$(OBJEXT) base_entity.$(OBJEXT) IPhys.$(OBJEXT) 59 orxonox_OBJECTS = $(am_orxonox_OBJECTS) 60 orxonox_LDADD = $(LDADD) 61 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) 62 depcomp = $(SHELL) $(top_srcdir)/depcomp 63 am__depfiles_maybe = depfiles 64 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/IPhys.Po \ 65 @AMDEP_TRUE@ ./$(DEPDIR)/base_entity.Po ./$(DEPDIR)/camera.Po \ 66 @AMDEP_TRUE@ ./$(DEPDIR)/collision.Po \ 67 @AMDEP_TRUE@ ./$(DEPDIR)/command_node.Po \ 68 @AMDEP_TRUE@ ./$(DEPDIR)/data_tank.Po ./$(DEPDIR)/ini_parser.Po \ 69 @AMDEP_TRUE@ ./$(DEPDIR)/keynames.Po ./$(DEPDIR)/orxonox.Po \ 70 @AMDEP_TRUE@ ./$(DEPDIR)/player.Po ./$(DEPDIR)/track.Po \ 71 @AMDEP_TRUE@ ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \ 72 @AMDEP_TRUE@ ./$(DEPDIR)/world_entity.Po 73 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 74 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) 75 CXXLD = $(CXX) 76 CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ 77 -o $@ 78 SOURCES = $(orxonox_SOURCES) 79 DIST_SOURCES = $(orxonox_SOURCES) 80 HEADERS = $(noinst_HEADERS) 81 ETAGS = etags 82 CTAGS = ctags 83 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 38 84 ACLOCAL = @ACLOCAL@ 39 85 AMDEP_FALSE = @AMDEP_FALSE@ … … 90 136 am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ 91 137 am__include = @am__include@ 138 am__leading_dot = @am__leading_dot@ 92 139 am__quote = @am__quote@ 93 140 bindir = @bindir@ … … 103 150 localstatedir = @localstatedir@ 104 151 mandir = @mandir@ 152 mkdir_p = @mkdir_p@ 105 153 oldincludedir = @oldincludedir@ 106 154 prefix = @prefix@ … … 112 160 AM_CXXFLAGS = "-I/usr/X11R6/include" 113 161 AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS) 114 115 116 #"-O3 -pedantic -fPIC -ffast-math -I/usr/X11R6/include"117 bin_PROGRAMS = orxonox118 162 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 IPhys.cc 119 120 163 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 IPhys.h 121 subdir = src122 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4123 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs124 CONFIG_HEADER = $(top_builddir)/config.h125 CONFIG_CLEAN_FILES =126 bin_PROGRAMS = orxonox$(EXEEXT)127 PROGRAMS = $(bin_PROGRAMS)128 129 am_orxonox_OBJECTS = orxonox.$(OBJEXT) world.$(OBJEXT) player.$(OBJEXT) \130 data_tank.$(OBJEXT) world_entity.$(OBJEXT) vector.$(OBJEXT) \131 camera.$(OBJEXT) collision.$(OBJEXT) command_node.$(OBJEXT) \132 ini_parser.$(OBJEXT) keynames.$(OBJEXT) track.$(OBJEXT) \133 base_entity.$(OBJEXT) IPhys.$(OBJEXT)134 orxonox_OBJECTS = $(am_orxonox_OBJECTS)135 orxonox_LDADD = $(LDADD)136 orxonox_DEPENDENCIES =137 orxonox_LDFLAGS =138 139 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)140 depcomp = $(SHELL) $(top_srcdir)/depcomp141 am__depfiles_maybe = depfiles142 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/IPhys.Po ./$(DEPDIR)/base_entity.Po \143 @AMDEP_TRUE@ ./$(DEPDIR)/camera.Po ./$(DEPDIR)/collision.Po \144 @AMDEP_TRUE@ ./$(DEPDIR)/command_node.Po \145 @AMDEP_TRUE@ ./$(DEPDIR)/data_tank.Po ./$(DEPDIR)/ini_parser.Po \146 @AMDEP_TRUE@ ./$(DEPDIR)/keynames.Po ./$(DEPDIR)/orxonox.Po \147 @AMDEP_TRUE@ ./$(DEPDIR)/player.Po ./$(DEPDIR)/track.Po \148 @AMDEP_TRUE@ ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \149 @AMDEP_TRUE@ ./$(DEPDIR)/world_entity.Po150 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \151 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)152 CXXLD = $(CXX)153 CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \154 -o $@155 DIST_SOURCES = $(orxonox_SOURCES)156 HEADERS = $(noinst_HEADERS)157 158 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in INSTALL \159 Makefile.am160 SOURCES = $(orxonox_SOURCES)161 162 164 all: all-am 163 165 164 166 .SUFFIXES: 165 167 .SUFFIXES: .cc .o .obj 166 $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) 168 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 169 @for dep in $?; do \ 170 case '$(am__configure_deps)' in \ 171 *$$dep*) \ 172 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ 173 && exit 0; \ 174 exit 1;; \ 175 esac; \ 176 done; \ 177 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ 167 178 cd $(top_srcdir) && \ 168 179 $(AUTOMAKE) --gnu src/Makefile 169 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 170 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) 171 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 180 .PRECIOUS: Makefile 181 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 182 @case '$?' in \ 183 *config.status*) \ 184 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 185 *) \ 186 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 187 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 188 esac; 189 190 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 191 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 192 193 $(top_srcdir)/configure: $(am__configure_deps) 194 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 195 $(ACLOCAL_M4): $(am__aclocal_m4_deps) 196 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 172 197 install-binPROGRAMS: $(bin_PROGRAMS) 173 198 @$(NORMAL_INSTALL) 174 $(mkinstalldirs) $(DESTDIR)$(bindir)199 test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" 175 200 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 176 201 p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ … … 178 203 ; then \ 179 204 f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ 180 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \181 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f|| exit 1; \205 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ 206 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ 182 207 else :; fi; \ 183 208 done … … 187 212 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 188 213 f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ 189 echo " rm -f $(DESTDIR)$(bindir)/$$f"; \190 rm -f $(DESTDIR)$(bindir)/$$f; \214 echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ 215 rm -f "$(DESTDIR)$(bindir)/$$f"; \ 191 216 done 192 217 … … 198 223 199 224 mostlyclean-compile: 200 -rm -f *.$(OBJEXT) core *.core225 -rm -f *.$(OBJEXT) 201 226 202 227 distclean-compile: … … 219 244 220 245 .cc.o: 221 @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ 222 @am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ 223 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ 224 @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ 225 @am__fastdepCXX_TRUE@ fi 246 @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ 247 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi 226 248 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 227 249 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ 228 250 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 229 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<251 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< 230 252 231 253 .cc.obj: 232 @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ 233 @am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ 234 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ 235 @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ 236 @am__fastdepCXX_TRUE@ fi 254 @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ 255 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi 237 256 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 238 257 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ 239 258 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 240 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ ` if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`259 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 241 260 uninstall-info-am: 242 243 ETAGS = etags244 ETAGSFLAGS =245 246 CTAGS = ctags247 CTAGSFLAGS =248 249 tags: TAGS250 261 251 262 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) … … 257 268 END { for (i in files) print i; }'`; \ 258 269 mkid -fID $$unique 270 tags: TAGS 259 271 260 272 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ … … 268 280 $(AWK) ' { files[$$0] = 1; } \ 269 281 END { for (i in files) print i; }'`; \ 270 test -z "$(ETAGS_ARGS)$$tags$$unique" \ 271 || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 272 $$tags $$unique 273 282 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 283 test -n "$$unique" || unique=$$empty_fix; \ 284 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 285 $$tags $$unique; \ 286 fi 274 287 ctags: CTAGS 275 288 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ … … 294 307 distclean-tags: 295 308 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 296 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)297 298 top_distdir = ..299 distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)300 309 301 310 distdir: $(DISTFILES) … … 311 320 if test "$$dir" != "$$file" && test "$$dir" != "."; then \ 312 321 dir="/$$dir"; \ 313 $(mk installdirs) "$(distdir)$$dir"; \322 $(mkdir_p) "$(distdir)$$dir"; \ 314 323 else \ 315 324 dir=''; \ … … 329 338 check: check-am 330 339 all-am: Makefile $(PROGRAMS) $(HEADERS) 331 332 340 installdirs: 333 $(mkinstalldirs) $(DESTDIR)$(bindir) 341 for dir in "$(DESTDIR)$(bindir)"; do \ 342 test -z "$$dir" || $(mkdir_p) "$$dir"; \ 343 done 334 344 install: install-am 335 345 install-exec: install-exec-am … … 370 380 dvi-am: 371 381 382 html: html-am 383 372 384 info: info-am 373 385 … … 405 417 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ 406 418 clean-generic ctags distclean distclean-compile \ 407 distclean-generic distclean-tags distdir dvi dvi-am info\408 info-am install install-am install-binPROGRAMS install-data\409 install-data -am install-exec install-exec-am install-info\410 install-info -am install-man install-strip installcheck\411 installcheck -am installdirs maintainer-clean \419 distclean-generic distclean-tags distdir dvi dvi-am html \ 420 html-am info info-am install install-am install-binPROGRAMS \ 421 install-data install-data-am install-exec install-exec-am \ 422 install-info install-info-am install-man install-strip \ 423 installcheck installcheck-am installdirs maintainer-clean \ 412 424 maintainer-clean-generic mostlyclean mostlyclean-compile \ 413 425 mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ -
orxonox/branches/buerli/src/camera.cc
r2551 r2707 27 27 This standard constructor sets all parameters to zero 28 28 */ 29 Camera::Camera () 30 { 29 Camera::Camera (World* world) 30 { 31 this->world = world; 31 32 bound = NULL; 32 33 /* give it some physical live */ … … 36 37 fs = new Vector(0.0, 0.0, 0.0); 37 38 cameraMode = NORMAL; 38 39 39 deltaTime = 3000.0; 40 40 cameraOffset = 1.0; … … 179 179 /* the camera is handled like an entity and rolls on the track */ 180 180 case NORMAL: 181 Orxonox *orx = Orxonox::getInstance();182 181 Location lookat; 183 if( bound != NULL )182 if( bound != NULL && world != NULL ) 184 183 { 185 184 bound->get_lookat (&lookat); 186 orx->get_world()->calc_camera_pos (&lookat, &desired_place);185 world->calc_camera_pos (&lookat, &desired_place); 187 186 } 188 187 else … … 293 292 } 294 293 } 294 295 296 void Camera::setWorld(World* world) 297 { 298 this->world = world; 299 } -
orxonox/branches/buerli/src/camera.h
r2551 r2707 10 10 11 11 class WorldEntity; 12 class World; 12 13 13 14 //! Camera 14 15 /** 15 16 17 18 19 16 This class controls the viewpoint from which the World is rendered. To use the 17 Camera it has to be bound to a WorldEntity which serves as the reference focus 18 point. The Camera itself calls the WorldEntity::get_lookat() and 19 World::calc_camera_pos() functions to calculate the position it currently should 20 be in. 20 21 */ 21 22 … … 27 28 Placement actual_place; //!< the Camera's current position 28 29 Placement desired_place; //!< where the Camera should be according to calculations 30 World* world; 29 31 30 32 /* physical system - not needed yet */ … … 49 51 Quaternion *res; 50 52 53 54 CAMERA_MODE cameraMode; //!< saves the camera mode: how the camera follows the entity 55 56 void update_desired_place (); 57 58 public: 59 Camera (World* world); 60 ~Camera (); 61 62 void time_slice (Uint32 deltaT); 63 void apply (); 64 void bind (WorldEntity* entity); 65 void jump (Placement* plc); 51 66 52 CAMERA_MODE cameraMode; //!< saves the camera mode: how the camera follows the entity 53 54 void update_desired_place (); 55 56 public: 57 Camera (); 58 ~Camera (); 59 60 void time_slice (Uint32 deltaT); 61 void apply (); 62 void bind (WorldEntity* entity); 63 void jump (Placement* plc); 67 void setWorld(World* world); 64 68 65 69 }; -
orxonox/branches/buerli/src/command_node.cc
r2551 r2707 19 19 #include "ini_parser.h" 20 20 #include "world_entity.h" 21 #include "game_loader.h" 21 22 22 23 #include <stdio.h> … … 27 28 28 29 /** 29 30 30 \brief constructs a CommandNode to handle remote input 31 \param ID: unique denumerator to identify the node in the network 31 32 */ 32 33 CommandNode::CommandNode (int ID) 33 34 { 34 35 36 37 38 } 39 40 /** 41 42 35 bound = new List<WorldEntity>(); 36 aliases = NULL; 37 netID = ID; 38 bLocalInput = false; 39 } 40 41 /** 42 \brief constructs a CommandNode to handle local input 43 \param filename: The path and name of the file to load the key bindings from 43 44 */ 44 45 CommandNode::CommandNode (char* filename = DEFAULT_KEYBIND_FILE) 45 46 { 46 47 48 49 50 51 } 52 53 /** 54 47 aliases = NULL; 48 bLocalInput = true; 49 netID = 0; 50 bound = new List<WorldEntity>(); 51 load_bindings (filename); 52 } 53 54 /** 55 \brief removes the CommandNode from memory 55 56 */ 56 57 CommandNode::~CommandNode () 57 58 { 58 59 60 } 61 62 /** 63 64 59 if( aliases != NULL) free (aliases); 60 if( bound != NULL) delete bound; 61 } 62 63 /** 64 \brief loads new key bindings from a file 65 \param filename: The path and name of the file to load the bindings from 65 66 */ 66 67 void CommandNode::load_bindings (char* filename) 67 68 { 68 FILE* stream; 69 70 printf("Loading key bindings from %s\n", filename); 71 72 if( filename == NULL) filename = DEFAULT_KEYBIND_FILE; 73 74 // remove old bindings if present 75 if( aliases != NULL) 69 FILE* stream; 70 71 printf("Loading key bindings from %s\n", filename); 72 73 if( filename == NULL) filename = DEFAULT_KEYBIND_FILE; 74 75 // remove old bindings if present 76 if( aliases != NULL) 77 { 78 free (aliases); 79 aliases = NULL; 80 } 81 82 // create parser 83 IniParser parser (filename); 84 if( parser.get_section ("Bindings") == -1) 85 { 86 printf("Could not find key bindings in %s\n", filename); 87 return; 88 } 89 // allocate empty lookup table 90 aliases = (KeyBindings*) calloc (1, sizeof (KeyBindings)); 91 92 char namebuf[256]; 93 char valuebuf[256]; 94 memset (namebuf, 0, 256); 95 memset (valuebuf, 0, 256); 96 int* index; 97 98 while( parser.next_var (namebuf, valuebuf) != -1) 99 { 100 index = name_to_index (namebuf); 101 switch( index[0]) 76 102 { 77 free (aliases); 78 aliases = NULL; 103 case 0: 104 printf("Key binding %d(%s) set to %s\n", index[1], SDLK_to_keyname( index[1]), valuebuf); 105 strcpy (aliases->keys[index[1]], valuebuf); 106 break; 107 case 1: 108 printf("Button binding %d(%s) set to %s\n", index[1], SDLB_to_buttonname( index[1]), valuebuf); 109 strcpy (aliases->buttons[index[1]], valuebuf); 110 break; 111 default: 112 break; 79 113 } 80 81 // create parser 82 IniParser parser (filename); 83 if( parser.get_section ("Bindings") == -1) 114 memset (namebuf, 0, 256); 115 memset (valuebuf, 0, 256); 116 } 117 } 118 119 /** 120 \brief binds a WorldEntity to the CommandNode 121 \param entity: Pointer to the entity to bind 122 */ 123 void CommandNode::bind (WorldEntity* entity) 124 { 125 bound->add (entity, LIST_ADD_NEXT, true); 126 } 127 128 /** 129 \brief removes an entity from the list of the CommandNode 130 \param entity: Pointer to the entity to relese 131 */ 132 void CommandNode::unbind (WorldEntity* entity) 133 { 134 bound->remove (entity, LIST_FIND_FW); 135 } 136 137 int* CommandNode::name_to_index (char* name) 138 { 139 coord[0] = -1; 140 coord[1] = -1; 141 int c; 142 if( (c = keyname_to_SDLK (name)) != -1) 143 { 144 coord[1] = c; 145 coord[0] = 0; 146 } 147 if( (c = buttonname_to_SDLB (name)) != -1) 148 { 149 coord[1] = c; 150 coord[0] = 1; 151 } 152 return coord; 153 } 154 155 /** 156 \brief tells the CommandNode to run through all pending events and relay them accordingly 157 */ 158 void CommandNode::process () 159 { 160 if( bLocalInput) process_local (); 161 else process_network (); 162 } 163 164 void CommandNode::process_local () 165 { 166 SDL_Event event; 167 Command cmd; 168 169 while( SDL_PollEvent (&event)) 170 { 171 memset (cmd.cmd, 0, CMD_LENGHT); 172 switch( event.type) 84 173 { 85 printf("Could not find key bindings in %s\n", filename); 86 return; 174 case SDL_KEYDOWN: 175 strcpy (cmd.cmd, aliases->keys[event.key.keysym.sym]); 176 cmd.bUp = false; 177 if( strlen (cmd.cmd) > 0) relay (&cmd); 178 break; 179 case SDL_KEYUP: 180 strcpy( cmd.cmd, aliases->keys[event.key.keysym.sym]); 181 cmd.bUp = true; 182 if( strlen (cmd.cmd) > 0) relay (&cmd); 183 break; 184 case SDL_MOUSEMOTION: 185 strcpy( cmd.cmd, "cursor"); 186 cmd.x = event.motion.x; 187 cmd.y = event.motion.y; 188 cmd.xrel = event.motion.xrel; 189 cmd.yrel = event.motion.yrel; 190 break; 191 case SDL_MOUSEBUTTONUP: 192 strcpy( cmd.cmd, aliases->buttons[event.button.button]); 193 cmd.bUp = true; 194 if( strlen (cmd.cmd) > 0) relay (&cmd); 195 break; 196 case SDL_MOUSEBUTTONDOWN: 197 strcpy( cmd.cmd, aliases->buttons[event.button.button]); 198 cmd.bUp = false; 199 if( strlen (cmd.cmd) > 0) relay (&cmd); 200 break; 201 case SDL_JOYAXISMOTION: 202 case SDL_JOYBALLMOTION: 203 case SDL_JOYHATMOTION: 204 case SDL_JOYBUTTONDOWN: 205 case SDL_JOYBUTTONUP: 206 break; 207 default: 208 Orxonox *orx = Orxonox::getInstance(); 209 orx->event_handler (&event); 210 211 break; 87 212 } 88 // allocate empty lookup table 89 aliases = (KeyBindings*) calloc (1, sizeof (KeyBindings)); 90 91 char namebuf[256]; 92 char valuebuf[256]; 93 memset (namebuf, 0, 256); 94 memset (valuebuf, 0, 256); 95 int* index; 96 97 while( parser.next_var (namebuf, valuebuf) != -1) 98 { 99 index = name_to_index (namebuf); 100 switch( index[0]) 101 { 102 case 0: 103 printf("Key binding %d(%s) set to %s\n", index[1], SDLK_to_keyname( index[1]), valuebuf); 104 strcpy (aliases->keys[index[1]], valuebuf); 105 break; 106 case 1: 107 printf("Button binding %d(%s) set to %s\n", index[1], SDLB_to_buttonname( index[1]), valuebuf); 108 strcpy (aliases->buttons[index[1]], valuebuf); 109 break; 110 default: 111 break; 112 } 113 memset (namebuf, 0, 256); 114 memset (valuebuf, 0, 256); 115 } 116 } 117 118 /** 119 \brief binds a WorldEntity to the CommandNode 120 \param entity: Pointer to the entity to bind 121 */ 122 void CommandNode::bind (WorldEntity* entity) 123 { 124 bound->add (entity, LIST_ADD_NEXT, true); 125 } 126 127 /** 128 \brief removes an entity from the list of the CommandNode 129 \param entity: Pointer to the entity to relese 130 */ 131 void CommandNode::unbind (WorldEntity* entity) 132 { 133 bound->remove (entity, LIST_FIND_FW); 134 } 135 136 int* CommandNode::name_to_index (char* name) 137 { 138 coord[0] = -1; 139 coord[1] = -1; 140 int c; 141 if( (c = keyname_to_SDLK (name)) != -1) 142 { 143 coord[1] = c; 144 coord[0] = 0; 145 } 146 if( (c = buttonname_to_SDLB (name)) != -1) 147 { 148 coord[1] = c; 149 coord[0] = 1; 150 } 151 return coord; 152 } 153 154 /** 155 \brief tells the CommandNode to run through all pending events and relay them accordingly 156 */ 157 void CommandNode::process () 158 { 159 if( bLocalInput) process_local (); 160 else process_network (); 161 } 162 163 void CommandNode::process_local () 164 { 165 SDL_Event event; 166 Command cmd; 167 168 while( SDL_PollEvent (&event)) 169 { 170 memset (cmd.cmd, 0, CMD_LENGHT); 171 switch( event.type) 172 { 173 case SDL_KEYDOWN: 174 strcpy (cmd.cmd, aliases->keys[event.key.keysym.sym]); 175 cmd.bUp = false; 176 if( strlen (cmd.cmd) > 0) relay (&cmd); 177 break; 178 case SDL_KEYUP: 179 strcpy( cmd.cmd, aliases->keys[event.key.keysym.sym]); 180 cmd.bUp = true; 181 if( strlen (cmd.cmd) > 0) relay (&cmd); 182 break; 183 case SDL_MOUSEMOTION: 184 strcpy( cmd.cmd, "cursor"); 185 cmd.x = event.motion.x; 186 cmd.y = event.motion.y; 187 cmd.xrel = event.motion.xrel; 188 cmd.yrel = event.motion.yrel; 189 break; 190 case SDL_MOUSEBUTTONUP: 191 strcpy( cmd.cmd, aliases->buttons[event.button.button]); 192 cmd.bUp = true; 193 if( strlen (cmd.cmd) > 0) relay (&cmd); 194 break; 195 case SDL_MOUSEBUTTONDOWN: 196 strcpy( cmd.cmd, aliases->buttons[event.button.button]); 197 cmd.bUp = false; 198 if( strlen (cmd.cmd) > 0) relay (&cmd); 199 break; 200 case SDL_JOYAXISMOTION: 201 case SDL_JOYBALLMOTION: 202 case SDL_JOYHATMOTION: 203 case SDL_JOYBUTTONDOWN: 204 case SDL_JOYBUTTONUP: 205 break; 206 default: 207 Orxonox *orx = Orxonox::getInstance(); 208 orx->event_handler (&event); 209 break; 210 } 211 } 213 } 212 214 } 213 215 … … 219 221 void CommandNode::relay (Command* cmd) 220 222 { 221 printf("CommandNode|relay()\n"); 222 List<WorldEntity>* plist = bound; 223 224 Orxonox *orx = Orxonox::getInstance(); 225 if( orx->system_command (cmd)) return; 226 227 if( bLocalInput) send_over_network (cmd); 228 229 while( (plist = plist->get_next()) != NULL) 230 { 231 plist->get_object()->command (cmd); 232 } 233 } 234 235 /** 236 \brief sets the network identifier of the CommandNode 237 \param ID: the new ID to use 223 //printf("CommandNode|relay()\n"); 224 List<WorldEntity>* plist = bound; 225 226 Orxonox *orx = Orxonox::getInstance(); 227 if( orx->system_command (cmd)) return; 228 GameLoader* gl = GameLoader::getInstance(); 229 if(gl->worldCommand(cmd)) return; 230 231 if( bLocalInput) send_over_network (cmd); 232 233 while( (plist = plist->get_next()) != NULL) 234 { 235 plist->get_object()->command (cmd); 236 } 237 } 238 239 /** 240 \brief sets the network identifier of the CommandNode 241 \param ID: the new ID to use 238 242 */ 239 243 void CommandNode::set_netID (int ID) 240 244 { 241 245 netID = ID; 242 246 } 243 247 -
orxonox/branches/buerli/src/error.h
r2551 r2707 22 22 */ 23 23 24 // this are the two undefined error nr. Don't use them ... 25 #define ERROR -1 26 #define NERROR 0 24 27 25 #define ERROR -1 26 #define NO_ERROR 0 28 /*! 29 \brief Error Definitions: 30 31 Error Classes: 32 0xx application framework codes 33 1xx graphics codes 34 2xx file/FS codes 35 3xx network codes 36 4xx general codes 37 38 Error Specifier 1: 39 x0x action finsished as desired 40 x1x initialisation error 41 x2x execution error 42 x3x uninitialisation error 43 44 Error Specifier 2: 45 xx0 no further informations 46 xx1 only a warning - feel free to ignore, the program will proceed 47 xx2 this could lead unexpected behaviour 48 xx3 this is a fatal error - you are invited to quit the program - panic! 49 */ 50 51 typedef struct 52 { 53 int code; 54 char* message; 55 char* location; 56 } Error; -
orxonox/branches/buerli/src/list.h
r2077 r2707 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 1 20 /*! 2 21 \file list.h … … 21 40 List<T>* prev; 22 41 bool bReference; 42 int size; 23 43 24 44 public: … … 35 55 void set_prev (List<T>* ptr); 36 56 int remove (T* obj, FINDMODE mode); 57 int getSize(); 37 58 }; 38 59 … … 52 73 prev = p; 53 74 bReference = bRef; 75 if(obj != NULL) 76 ++size; 54 77 } 55 78 … … 127 150 break; 128 151 } 152 ++size; 129 153 return 0; 130 154 } … … 224 248 } 225 249 } 250 --size; 226 251 return 0; 227 252 } … … 262 287 263 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() 295 { 296 return this->size; 297 } 264 298 265 299 #endif -
orxonox/branches/buerli/src/orxonox.cc
r2551 r2707 29 29 #include "data_tank.h" 30 30 #include "command_node.h" 31 #include "game_loader.h" 31 32 #include <string.h> 32 33 … … 34 35 35 36 /** 36 37 \brief create a new Orxonox 37 38 */ 38 39 Orxonox::Orxonox () … … 42 43 43 44 /** 44 45 \brief remove Orxonox from memory 45 46 */ 46 47 Orxonox::~Orxonox () 47 48 { 48 49 50 51 52 49 Orxonox::singleton_ref = NULL; 50 if( world != NULL) delete world; 51 if( localinput != NULL) delete world; 52 if( localcamera != NULL) delete localcamera; 53 if( resources != NULL) delete resources; 53 54 } 54 55 … … 65 66 66 67 /** 67 68 69 70 71 68 \brief this finds the config file 69 70 Since the config file varies from user to user and since one may want to specify different config files 71 for certain occasions or platforms this function finds the right config file for every occasion and stores 72 it's path and name into configfilename 72 73 */ 73 74 void Orxonox::get_config_file (int argc, char** argv) 74 75 { 75 /* char* path;76 77 78 79 80 81 82 83 84 85 86 87 } 88 89 /** 90 76 /* char* path; 77 #ifdef __WIN32__ 78 path = getenv(""); 79 #else 80 path = getenv("HOME"); 81 #endif 82 83 if( path != NULL) strcpy (configfilename, path); 84 else strcpy (configfilename, "./"); 85 strcat (configfilename, "/.orxonox.conf");*/ 86 87 strcpy (configfilename, "orxonox.conf"); 88 } 89 90 /** 91 \brief initialize Orxonox with command line 91 92 */ 92 93 int Orxonox::init (int argc, char** argv) 93 94 { 94 95 96 97 98 99 95 // parse command line 96 // config file 97 98 get_config_file (argc, argv); 99 100 // initialize SDL 100 101 printf("> Initializing SDL\n"); 101 102 if( SDL_Init (SDL_INIT_EVERYTHING) == -1) 102 {103 printf ("Could not SDL_Init(): %s\n", SDL_GetError());104 return -1;105 }106 107 103 { 104 printf ("Could not SDL_Init(): %s\n", SDL_GetError()); 105 return -1; 106 } 107 108 // initialize everything 108 109 printf("> Initializing video\n"); 109 110 if( init_video () == -1) return -1; 110 111 printf("> Initializing sound\n"); 111 112 if( init_sound () == -1) return -1; 112 113 printf("> Initializing input\n"); 113 114 if( init_input () == -1) return -1; 114 115 printf("> Initializing networking\n"); 115 116 if( init_networking () == -1) return -1; 116 117 printf("> Initializing resources\n"); 117 118 printf("> Initializing world\n");119 if( init_world () == -1) return -1; 120 121 122 } 123 124 /** 125 118 if( init_resources () == -1) return -1; 119 //printf("> Initializing world\n"); 120 //if( init_world () == -1) return -1; PB: world will be initialized when started 121 122 return 0; 123 } 124 125 /** 126 \brief initializes SDL and OpenGL 126 127 */ 127 128 int Orxonox::init_video () … … 161 162 162 163 // create camera 163 localcamera = new Camera( );164 165 return 0; 166 } 167 168 /** 169 164 localcamera = new Camera(world); 165 166 return 0; 167 } 168 169 /** 170 \brief initializes the sound engine 170 171 */ 171 172 int Orxonox::init_sound () 172 173 { 173 174 175 } 176 177 /** 178 174 printf("Not yet implemented\n"); 175 return 0; 176 } 177 178 /** 179 \brief initializes input functions 179 180 */ 180 181 int Orxonox::init_input () 181 182 { 182 183 184 185 186 } 187 188 /** 189 183 // create localinput 184 localinput = new CommandNode( configfilename); 185 186 return 0; 187 } 188 189 /** 190 \brief initializes network system 190 191 */ 191 192 int Orxonox::init_networking () 192 193 { 193 194 195 } 196 197 /** 198 194 printf("Not yet implemented\n"); 195 return 0; 196 } 197 198 /** 199 \brief initializes and loads resource files 199 200 */ 200 201 int Orxonox::init_resources () 201 202 { 202 203 204 } 205 206 /** 207 203 printf("Not yet implemented\n"); 204 return 0; 205 } 206 207 /** 208 \brief initializes the world 208 209 */ 209 210 int Orxonox::init_world () 210 211 { 211 world = new World(); 212 213 // TO DO: replace this with a menu/intro 214 world->load_debug_level(); 215 216 return 0; 217 } 218 219 /** 220 \brief exits Orxonox 212 //world = new World(); 213 214 // TO DO: replace this with a menu/intro 215 //world->load_debug_level(); 216 217 return 0; 218 } 219 220 221 /** 222 \brief starts the orxonox game or menu 223 224 here is the central orxonox state manager. There are currently two states 225 - menu 226 - game-play 227 both states manage their states themselfs again. 228 */ 229 void Orxonox::start() 230 { 231 232 this->gameLoader = GameLoader::getInstance(); 233 this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 234 this->gameLoader->init(); 235 this->gameLoader->start(); 236 } 237 238 /** 239 \brief exits Orxonox 221 240 */ 222 241 void Orxonox::quitGame() 223 242 { 224 225 } 226 227 /** 228 243 bQuitOrxonox = true; 244 } 245 246 /** 247 \brief this runs all of Orxonox 229 248 */ 230 249 void Orxonox::mainLoop() … … 236 255 while( !bQuitOrxonox) 237 256 { 238 printf("<==");239 240 257 // Network 241 258 synchronize(); … … 248 265 // Draw 249 266 display(); 250 251 printf(">\n");252 267 } 253 268 printf("Orxonox|Exiting the main loop\n"); … … 255 270 256 271 /** 257 258 272 \brief handles sprecial events from localinput 273 \param event: an event not handled by the CommandNode 259 274 */ 260 275 void Orxonox::event_handler (SDL_Event* event) 261 276 { 262 263 } 264 265 /** 266 277 // Handle special events such as reshape, quit, focus changes 278 } 279 280 /** 281 \brief synchronize local data with remote data 267 282 */ 268 283 void Orxonox::synchronize () 269 284 { 270 271 272 } 273 274 /** 275 285 // Get remote input 286 // Update synchronizables 287 } 288 289 /** 290 \brief run all input processing 276 291 */ 277 292 void Orxonox::handle_input () 278 293 { 279 280 281 282 } 283 284 /** 285 294 // localinput 295 localinput->process(); 296 // remoteinput 297 } 298 299 /** 300 \brief advance the timeline 286 301 */ 287 302 void Orxonox::time_slice () … … 295 310 { 296 311 float fps = 1000/dt; 297 printf(" %f", fps);312 printf("fps = %f\n", fps); 298 313 } 299 314 … … 306 321 307 322 /** 308 323 \brief compute collision detection 309 324 */ 310 325 void Orxonox::collision () 311 326 { 312 313 } 314 315 /** 316 317 318 327 world->collide (); 328 } 329 330 /** 331 \brief handle keyboard commands that are not meant for WorldEntities 332 \param cmd: the command to handle 333 \return true if the command was handled by the system or false if it may be passed to the WorldEntities 319 334 */ 320 335 bool Orxonox::system_command (Command* cmd) 321 336 { 322 323 324 if( !cmd->bUp) bQuitOrxonox = true;325 326 327 328 } 329 330 /** 331 337 if( !strcmp( cmd->cmd, "quit")) 338 { 339 if( !cmd->bUp) this->gameLoader->stop(); 340 return true; 341 } 342 return false; 343 } 344 345 /** 346 \brief render the current frame 332 347 */ 333 348 void Orxonox::display () 334 349 { 335 336 337 338 339 340 341 342 343 344 } 345 346 /** 347 348 350 // clear buffer 351 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 352 // set camera 353 localcamera->apply (); 354 // draw world 355 world->draw (); 356 // draw HUD 357 // flip buffers 358 SDL_GL_SwapBuffers(); 359 } 360 361 /** 362 \brief retrieve a pointer to the local Camera 363 \return a pointer to localcamera 349 364 */ 350 365 Camera* Orxonox::get_camera () 351 366 { 352 353 } 354 355 /** 356 357 367 return localcamera; 368 } 369 370 /** 371 \brief retrieve a pointer to the local CommandNode 372 \return a pointer to localinput 358 373 */ 359 374 CommandNode* Orxonox::get_localinput () 360 375 { 361 362 } 363 364 /** 365 366 376 return localinput; 377 } 378 379 /** 380 \brief retrieve a pointer to the local World 381 \return a pointer to world 367 382 */ 368 383 World* Orxonox::get_world () 369 384 { 370 385 return world; 371 386 } 372 387 373 388 int main (int argc, char** argv) 374 389 { 375 390 printf(">>> Starting Orxonox <<<\n"); 376 391 Orxonox *orx = Orxonox::getInstance(); 377 392 378 393 if( (*orx).init(argc, argv) == -1) 379 { 380 printf("! Orxonox initialization failed\n"); 381 return -1; 382 } 383 384 (*orx).mainLoop(); 385 394 { 395 printf("! Orxonox initialization failed\n"); 396 return -1; 397 } 398 399 //(*orx).mainLoop(); 400 401 orx->start(); 402 386 403 //delete orx; 387 404 -
orxonox/branches/buerli/src/orxonox.conf
r2190 r2707 6 6 SPACE=fire 7 7 ESCAPE=quit 8 p=pause 8 9 q=quit 9 10 BUTTON_LEFT=fire 10 11 BUTTON_RIGHT=altfire 11 12 b=benscho 13 x=up_world 14 z=down_world 15 -
orxonox/branches/buerli/src/orxonox.h
r2190 r2707 16 16 class World; 17 17 class Camera; 18 class GameLoader; 18 19 19 20 //! Orxonox core singleton class … … 33 34 Camera* localcamera; 34 35 SDL_Surface* screen; 36 GameLoader* gameLoader; 35 37 36 38 bool bQuitOrxonox; 37 39 bool pause; 38 39 40 41 42 40 Uint32 lastframe; 41 42 void get_config_file (int argc, char** argv); 43 44 // main loop functions 43 45 void synchronize (); 44 46 void handle_input (); … … 57 59 public: 58 60 static Orxonox* getInstance (); 61 void start(); 59 62 void quitGame(); 60 63 … … 63 66 64 67 int init (int argc, char** argv); 65 66 67 68 69 68 69 CommandNode* get_localinput(); 70 Camera* get_camera(); 71 World* get_world(); 72 70 73 void mainLoop(); 71 74 }; -
orxonox/branches/buerli/src/player.cc
r2551 r2707 62 62 void Player::command (Command* cmd) 63 63 { 64 65 66 67 68 69 64 //printf("Player|recieved command [%s]\n", cmd->cmd); 65 if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp; 66 else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp; 67 else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp; 68 else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp; 69 else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp; 70 70 } 71 71 72 72 void Player::draw () 73 { 73 { 74 74 glMatrixMode(GL_MODELVIEW); 75 75 glLoadIdentity(); -
orxonox/branches/buerli/src/stdincl.h
r2551 r2707 15 15 #include "coordinates.h" 16 16 #include "list.h" 17 #include "error.h" 17 18 #include "message_structures.h" 18 19 #include "orxonox.h" -
orxonox/branches/buerli/src/track.cc
r2551 r2707 52 52 { 53 53 } 54 55 void Track::init() 56 { 57 58 } 59 54 60 55 61 /** -
orxonox/branches/buerli/src/track.h
r2551 r2707 27 27 28 28 public: 29 29 Track (); 30 30 Track (Uint32 number, Uint32 next, Vector* start, Vector* finish); 31 31 ~Track (); 32 33 virtual void post_enter (WorldEntity* entity); // handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght) 34 virtual void post_leave (WorldEntity* entity); 35 virtual void tick (float deltaT); 36 virtual void map_camera (Location* lookat, Placement* camplc); 37 virtual bool map_coords (Location* loc, Placement* plc); // this should return true if the entity left track boundaries 32 virtual void init(); 33 34 virtual void post_enter (WorldEntity* entity); // handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght) 35 virtual void post_leave (WorldEntity* entity); 36 virtual void tick (float deltaT); 37 virtual void map_camera (Location* lookat, Placement* camplc); 38 virtual bool map_coords (Location* loc, Placement* plc); // this should return true if the entity left track boundaries 38 39 }; 39 40 -
orxonox/branches/buerli/src/world.cc
r2551 r2707 31 31 This creates a new empty world! 32 32 */ 33 World::World () 34 { 35 entities = new List<WorldEntity>(); 33 World::World (char* name) 34 { 35 this->worldName = name; 36 this->debugWorldNr = -1; 37 this->entities = new List<WorldEntity>(); 38 } 39 40 World::World (int worldID) 41 { 42 this->debugWorldNr = worldID; 43 this->worldName = NULL; 44 this->entities = new List<WorldEntity>(); 36 45 } 37 46 … … 41 50 World::~World () 42 51 { 43 unload (); 44 delete entities; 45 } 52 Orxonox *orx = Orxonox::getInstance(); 53 orx->get_localinput()->unbind (this->localPlayer); 54 delete this->entities; 55 delete this->localCamera; 56 } 57 58 59 /** 60 \brief initialize the world before use. 61 */ 62 Error World::init() 63 { 64 this->bPause = false; 65 } 66 67 Error World::start() 68 { 69 this->mainLoop(); 70 } 71 72 Error World::stop() 73 { 74 this->bQuitCurrentGame = true; 75 this->localCamera->setWorld(NULL); 76 this->~World(); 77 } 78 79 Error World::pause() 80 { 81 this->isPaused = true; 82 } 83 84 Error World::resume() 85 { 86 this->isPaused = false; 87 } 88 89 void World::load() 90 { 91 if(this->debugWorldNr != -1) 92 { 93 switch(this->debugWorldNr) 94 { 95 case DEBUG_WORLD_0: 96 { 97 // create some path nodes 98 this->pathnodes = new Vector[6]; 99 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); 105 106 // create the tracks 107 this->tracklen = 6; 108 this->track = new Track[6]; 109 for( int i = 0; i < this->tracklen; i++) 110 { 111 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]); 112 } 113 114 // create a player 115 //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>(); 116 WorldEntity* myPlayer = new Player(); 117 this->spawn(myPlayer); 118 this->localPlayer = myPlayer; 119 120 // bind input 121 Orxonox *orx = Orxonox::getInstance(); 122 orx->get_localinput()->bind (myPlayer); 123 124 // bind camera 125 this->localCamera = new Camera(this); 126 this->getCamera()->bind (myPlayer); 127 break; 128 } 129 case DEBUG_WORLD_1: 130 { 131 // create some path nodes 132 this->pathnodes = new Vector[6]; 133 this->pathnodes[0] = Vector(0, 0, 0); 134 this->pathnodes[1] = Vector(20, 10, 10); 135 this->pathnodes[2] = Vector(40, 0, 10); 136 this->pathnodes[3] = Vector(60, 10, 0); 137 this->pathnodes[4] = Vector(80, 20, 10); 138 this->pathnodes[5] = Vector(30, 50, 0); 139 140 // create the tracks 141 this->tracklen = 6; 142 this->track = new Track[6]; 143 for( int i = 0; i < this->tracklen; i++) 144 { 145 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]); 146 } 147 148 // create a player 149 //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>(); 150 WorldEntity* myPlayer = new Player(); 151 this->spawn(myPlayer); 152 this->localPlayer = myPlayer; 153 154 // bind input 155 Orxonox *orx = Orxonox::getInstance(); 156 orx->get_localinput()->bind (myPlayer); 157 158 // bind camera 159 this->localCamera = new Camera(this); 160 this->getCamera()->bind (myPlayer); 161 break; 162 } 163 default: 164 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 165 } 166 } 167 else if(this->worldName != NULL) 168 { 169 170 } 171 } 172 46 173 47 174 /** … … 254 381 } 255 382 256 /** 257 \brief loads a simple level for testing purposes 258 */ 259 void World::load_debug_level() 260 { 261 // create some path nodes 262 pathnodes = new Vector[6]; 263 pathnodes[0] = Vector(0, 0, 0); 264 pathnodes[1] = Vector(-100, 40, 0); 265 pathnodes[2] = Vector(-100, 140, 0); 266 pathnodes[3] = Vector(0, 180, 0); 267 pathnodes[4] = Vector(100, 140, 0); 268 pathnodes[5] = Vector(100, 40, 0); 269 270 // create the tracks 271 tracklen = 6; 272 track = new Track[6]; 273 for( int i = 0; i < tracklen; i++) 274 { 275 track[i] = Track( i, (i+1)%tracklen, &pathnodes[i], &pathnodes[(i+1)%tracklen]); 276 } 277 278 // create a player 279 WorldEntity* myPlayer = (WorldEntity*) spawn<Player>(); 280 281 // bind input 282 Orxonox *orx = Orxonox::getInstance(); 283 orx->get_localinput()->bind (myPlayer); 284 285 // bind camera 286 orx->get_camera()->bind (myPlayer); 287 } 383 288 384 289 385 /** … … 295 391 track[loc->part].map_camera (loc, plc); 296 392 } 393 394 395 void World::setTrackLen(Uint32 len) 396 { 397 this->tracklen = len; 398 } 399 400 int World::getTrackLen() 401 { 402 return this->tracklen; 403 } 404 405 void World::debug() 406 { 407 List<WorldEntity> *l; 408 WorldEntity* entity; 409 410 printf("counting all entities\n"); 411 l = entities->get_next(); 412 while( l != NULL ) 413 { 414 entity = l->get_object(); 415 if( entity->bDraw ) printf("got an entity\n"); 416 l = l->get_next(); 417 } 418 } 419 420 421 void World::mainLoop() 422 { 423 this->lastFrame = SDL_GetTicks(); 424 this->bQuitOrxonox = false; 425 this->bQuitCurrentGame = false; 426 printf("World|Entering main loop\n"); 427 while(!this->bQuitOrxonox && !this->bQuitCurrentGame) /* pause pause pause ?!?!?*/ 428 { 429 //debug routine 430 //debug(); 431 // Network 432 synchronize(); 433 // Process input 434 handle_input(); 435 // Process time 436 time_slice(); 437 // Process collision 438 collision(); 439 // Draw 440 display(); 441 } 442 printf("World|Exiting the main loop\n"); 443 } 444 445 /** 446 \brief synchronize local data with remote data 447 */ 448 void World::synchronize () 449 { 450 // Get remote input 451 // Update synchronizables 452 } 453 454 /** 455 \brief run all input processing 456 */ 457 void World::handle_input () 458 { 459 // localinput 460 Orxonox::getInstance()->get_localinput()->process(); 461 // remoteinput 462 } 463 464 /** 465 \brief advance the timeline 466 */ 467 void World::time_slice () 468 { 469 Uint32 currentFrame = SDL_GetTicks(); 470 if(!this->bPause) 471 { 472 Uint32 dt = currentFrame - this->lastFrame; 473 /* 474 if(dt > 0) 475 { 476 float fps = 1000/dt; 477 printf("fps = %f\n", fps); 478 } 479 else 480 { 481 printf("fps = 1000\n"); 482 } 483 */ 484 this->time_slice (dt); 485 this->update (); 486 this->localCamera->time_slice (dt); 487 } 488 this->lastFrame = currentFrame; 489 } 490 491 /** 492 \brief compute collision detection 493 */ 494 void World::collision () 495 { 496 this->collide (); 497 } 498 499 /** 500 \brief handle keyboard commands that are not meant for WorldEntities 501 \param cmd: the command to handle 502 \return true if the command was handled by the system or false if it may be passed to the WorldEntities 503 */ 504 bool World::system_command (Command* cmd) 505 { 506 if( !strcmp( cmd->cmd, "quit")) 507 { 508 if( !cmd->bUp) this->bQuitOrxonox = true; 509 return true; 510 } 511 return false; 512 } 513 514 /** 515 \brief render the current frame 516 */ 517 void World::display () 518 { 519 // clear buffer 520 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 521 // set camera 522 this->localCamera->apply (); 523 // draw world 524 this->draw(); 525 // draw HUD 526 // flip buffers 527 SDL_GL_SwapBuffers(); 528 } 529 530 Camera* World::getCamera() 531 { 532 return this->localCamera; 533 } 534 535 536 void World::spawn(WorldEntity* entity) 537 { 538 Location zeroloc; 539 Location* loc = NULL; 540 WorldEntity* owner; 541 //T* entity = new T(); 542 entities->add (entity, LIST_ADD_NEXT); 543 //if( loc == NULL) 544 //{ 545 zeroloc.dist = 0; 546 zeroloc.part = 0; 547 zeroloc.pos = Vector(); 548 zeroloc.rot = Quaternion(); 549 loc = &zeroloc; 550 //} 551 entity->init (loc, owner); 552 if (entity->bFree) 553 { 554 this->track[loc->part].map_coords( loc, entity->get_placement()); 555 } 556 entity->post_spawn (); 557 //return entity; 558 } -
orxonox/branches/buerli/src/world.h
r2551 r2707 8 8 9 9 #include "stdincl.h" 10 #include "story_entity.h" 11 12 10 13 11 14 class Track; 12 15 class WorldEntity; 16 class Camera; 13 17 14 18 //! The game environment 15 class World {19 class World : public StoryEntity { 16 20 17 21 public: 18 World (); 22 World (char* name); 23 World (int worldID); 19 24 ~World (); 20 25 21 template<typename T> 22 T* spawn(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 23 template<typename T> 24 T* spawn(Placement* plc, WorldEntity* owner); 26 template<typename T> 27 T* spawn(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 28 template<typename T> 29 T* spawn(Placement* plc, WorldEntity* owner); 30 31 virtual Error init(); 32 virtual Error start(); 33 virtual Error stop(); 34 virtual Error pause(); 35 virtual Error resume(); 25 36 26 void time_slice (Uint32 deltaT); 27 void collide (); 28 void draw (); 29 void update (); // maps Locations to Placements 30 void calc_camera_pos (Location* loc, Placement* plc); 37 virtual void load(); 38 39 void time_slice (Uint32 deltaT); 40 void collide (); 41 void draw (); 42 void update (); // maps Locations to Placements 43 void calc_camera_pos (Location* loc, Placement* plc); 31 44 32 void unload (); 33 34 void load_debug_level (); 35 45 void unload (); 46 47 void setTrackLen(Uint32 tracklen); 48 int getTrackLen(); 49 bool system_command (Command* cmd); 50 Camera* getCamera(); 51 //private: 52 53 void spawn(WorldEntity* entity); 54 55 List<WorldEntity>* entities; 56 57 // base level data 58 Track* track; 59 Uint32 tracklen; // number of Tracks the World consist of 60 Vector* pathnodes; 61 Camera* localCamera; 62 36 63 private: 37 38 List<WorldEntity>* entities; 39 40 // base level data 41 Track* track; 42 Uint32 tracklen; // number of Tracks the World consist of 43 Vector* pathnodes; 64 Uint32 lastFrame; //!> last time of frame 65 bool bQuitOrxonox; //!> quit this application 66 bool bQuitCurrentGame; //!> quit only the current game and return to menu 67 bool bPause; 44 68 69 char* worldName; 70 int debugWorldNr; 71 72 WorldEntity* localPlayer; 73 74 void mainLoop(); 75 void synchronize(); 76 void handle_input(); 77 void time_slice(); 78 void collision(); 79 void display(); 80 void debug(); 45 81 }; 46 82 … … 58 94 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) 59 95 { 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 96 Location zeroloc; 97 T* entity = new T(); 98 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 99 if( loc == NULL) 100 { 101 zeroloc.dist = 0; 102 zeroloc.part = 0; 103 zeroloc.pos = Vector(); 104 zeroloc.rot = Quaternion(); 105 loc = &zeroloc; 106 } 107 entity->init (loc, owner); 108 if (entity->bFree) 109 { 110 track[loc->part].map_coords( loc, entity->get_placement()); 111 } 112 entity->post_spawn (); 113 return entity; 78 114 } 79 115 … … 92 128 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) 93 129 { 94 95 96 97 98 99 100 101 102 103 104 130 T* entity = new T(); 131 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 132 entity->init (plc, owner); 133 if (!entity->bFree) 134 { 135 printf("Can't spawn unfree entity with placement\n"); 136 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 137 return NULL; 138 } 139 entity->post_spawn (); 140 return entity; 105 141 } 106 142
Note: See TracChangeset
for help on using the changeset viewer.