Changeset 3151 in orxonox.OLD for orxonox/branches/dave/src
- Timestamp:
- Dec 11, 2004, 5:26:18 PM (20 years ago)
- Location:
- orxonox/branches/dave/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/dave/src/Makefile.am
r2860 r3151 8 8 9 9 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 object.cc environment.cc array.cc material.cc list.cc 10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h 10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h 11 11 12 12 13 13 14 # uncomment the following if bencoderrequires the math library14 # uncomment the following if orxonox requires the math library 15 15 #orxonox_LDADD=-lm 16 16 -
orxonox/branches/dave/src/Makefile.in
r2860 r3151 38 38 PRE_UNINSTALL = : 39 39 POST_UNINSTALL = : 40 host_triplet = @host@ 40 41 bin_PROGRAMS = orxonox$(EXEEXT) 41 42 subdir = src … … 113 114 EGREP = @EGREP@ 114 115 EXEEXT = @EXEEXT@ 116 GTK2_CFLAGS = @GTK2_CFLAGS@ 117 GTK2_LIBS = @GTK2_LIBS@ 118 HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@ 119 HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@ 115 120 INSTALL_DATA = @INSTALL_DATA@ 116 121 INSTALL_PROGRAM = @INSTALL_PROGRAM@ … … 146 151 am__quote = @am__quote@ 147 152 bindir = @bindir@ 153 build = @build@ 148 154 build_alias = @build_alias@ 155 build_cpu = @build_cpu@ 156 build_os = @build_os@ 157 build_vendor = @build_vendor@ 149 158 datadir = @datadir@ 150 159 exec_prefix = @exec_prefix@ 160 host = @host@ 151 161 host_alias = @host_alias@ 162 host_cpu = @host_cpu@ 163 host_os = @host_os@ 164 host_vendor = @host_vendor@ 152 165 includedir = @includedir@ 153 166 infodir = @infodir@ … … 164 177 sharedstatedir = @sharedstatedir@ 165 178 sysconfdir = @sysconfdir@ 179 target = @target@ 166 180 target_alias = @target_alias@ 181 target_cpu = @target_cpu@ 182 target_os = @target_os@ 183 target_vendor = @target_vendor@ 167 184 AM_CXXFLAGS = "-I/usr/X11R6/include" 168 185 AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS) 169 186 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 object.cc environment.cc array.cc material.cc list.cc 170 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h 187 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h 171 188 all: all-am 172 189 … … 441 458 442 459 443 # uncomment the following if bencoderrequires the math library460 # uncomment the following if orxonox requires the math library 444 461 #orxonox_LDADD=-lm 445 462 -
orxonox/branches/dave/src/array.cc
r2860 r3151 69 69 printf ("Finalizing array.\n"); 70 70 if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) 71 // if ((array = new GLfloat [entryCount]) == NULL) 71 72 printf ("could not allocate %i data Blocks\n", entryCount); 72 73 Entry* walker = firstEntry; … … 77 78 } 78 79 finalized = true; 80 79 81 return; 80 82 } … … 91 93 printf ("adding new Entry to Array: %f\n", entry); 92 94 93 entryCount++;94 95 currentEntry->value = entry; 95 96 currentEntry->next = new Entry; 96 97 currentEntry = currentEntry->next; 97 98 currentEntry->next = NULL; 99 ++entryCount; 98 100 } 99 101 else -
orxonox/branches/dave/src/keynames.cc
r2551 r3151 13 13 co-programmer: ... 14 14 */ 15 #include <SDL/SDL.h>16 15 17 16 #include "keynames.h" -
orxonox/branches/dave/src/keynames.h
r2551 r3151 10 10 #endif 11 11 12 #ifndef __APPLE__ 12 13 #include <SDL/SDL.h> 14 #else 15 #include <SDL.h> 16 #endif 13 17 14 18 /** -
orxonox/branches/dave/src/object.cc
r2860 r3151 119 119 120 120 /** 121 121 \brief finalizes an Object. 122 122 This funcion is needed, to close the glList and all the other lists. 123 123 */ … … 226 226 if (verbose >= 2) 227 227 printf("Adding new Group\n"); 228 group->name = ""; 228 229 group->faceMode = -1; 229 group-> name = "";230 group->faceCount =0; 230 231 if ((group->listNumber = glGenLists(1)) == 0 ) 231 232 { … … 246 247 group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2; 247 248 } 248 249 if (verbose >=2) 250 printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal); 249 251 group->vertices = new Array(); 250 252 group->normals = new Array(); … … 256 258 /** 257 259 \brief finalizes a Group. 260 \param group the group to finalize. 258 261 */ 259 262 bool Object::finalizeGroup(Group* group) 260 263 { 264 if (verbose >=2) 265 printf ("Finalize group %s.\n", group->name); 261 266 glEnd(); 262 267 glEndList(); 268 } 269 /** 270 \brief deletes the Arrays of the Group to save space. 271 \param group the group to delete the arrays from. 272 */ 273 bool Object::cleanupGroup(Group* group) 274 { 275 if (verbose >=2) 276 printf ("cleaning up group %s.\n", group->name); 263 277 264 278 delete group->vertices; … … 266 280 delete group->vTexture; 267 281 } 282 268 283 /** 269 284 \brief Reads in the .obj File and sets all the Values. … … 282 297 } 283 298 objFileName = fileName; 284 char Buffer[ 500];299 char Buffer[10000]; 285 300 while(!OBJ_FILE->eof()) 286 301 { 287 OBJ_FILE->getline(Buffer, 500);302 OBJ_FILE->getline(Buffer, 10000); 288 303 if (verbose >=4) 289 304 printf ("Read input line: %s\n",Buffer); … … 330 345 } 331 346 OBJ_FILE->close(); 347 return true; 332 348 333 349 } … … 363 379 { 364 380 currentGroup->vertices->finalizeArray(); 365 glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());381 // glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray()); 366 382 currentGroup->normals->finalizeArray(); 367 glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());383 // glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray()); 368 384 currentGroup->vTexture->finalizeArray(); 369 385 } 370 386 371 387 readingVertices = false; 372 char subbuffer1[20]; 373 char subbuffer2[20]; 374 char subbuffer3[20]; 375 char subbuffer4[20] =""; 376 sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 377 if (!strcmp(subbuffer4, "")) 388 currentGroup->faceCount++; 389 390 int elemCount = 0; 391 392 FaceElement* firstElem = new FaceElement; 393 FaceElement* tmpElem = firstElem; 394 395 396 while(strcmp (faceString, "\0")) 397 { 398 if (elemCount>0) 399 tmpElem = tmpElem->next = new FaceElement; 400 tmpElem->next = NULL; 401 402 403 sscanf (faceString, "%s", tmpElem->value); 404 faceString += strlen(tmpElem->value); 405 if (strcmp (faceString, "\0")) 406 faceString++; 407 elemCount++; 408 409 410 } 411 412 413 if (elemCount == 3) 378 414 { 379 415 if (currentGroup->faceMode != 3) … … 386 422 currentGroup->faceMode = 3; 387 423 if (verbose >=3) 388 printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3); 389 addGLElement(subbuffer1); 390 addGLElement(subbuffer2); 391 addGLElement(subbuffer3); 392 return true; 393 } 394 else 424 printf ("found triag.\n"); 425 } 426 427 else if (elemCount == 4) 395 428 { 396 429 if (currentGroup->faceMode != 4) … … 402 435 currentGroup->faceMode = 4; 403 436 if (verbose >=3 ) 404 printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 405 addGLElement(subbuffer1); 406 addGLElement(subbuffer2); 407 addGLElement(subbuffer3); 408 addGLElement(subbuffer4); 409 return true; 410 } 437 printf ("found quad.\n"); 438 } 439 440 else if (elemCount > 4) 441 { 442 if (currentGroup->faceMode != -1) 443 glEnd(); 444 glBegin(GL_POLYGON); 445 if (verbose >=3) 446 printf ("Polygon with %i faces found.", elemCount); 447 currentGroup->faceMode = elemCount; 448 } 449 450 tmpElem = firstElem; 451 while (tmpElem != NULL) 452 { 453 // printf ("%s\n", tmpElem->value); 454 addGLElement(tmpElem->value); 455 tmpElem = tmpElem->next; 456 } 457 411 458 } 412 459 … … 423 470 { 424 471 if (verbose >=3) 425 printf ("importing grafical Element .... includingto openGL\n");472 printf ("importing grafical Element to openGL\n"); 426 473 char* vertex = elementString; 427 474 428 475 char* texture; 429 texture = strstr (vertex, "/"); 430 texture[0] = '\0'; 431 texture ++; 432 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 433 434 char* normal; 435 if ((normal = strstr (texture, "/")) !=NULL) 436 { 437 normal[0] = '\0'; 438 normal ++; 439 //glArrayElement(atoi(vertex)-1); 440 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 441 } 476 if ((texture = strstr (vertex, "/")) != NULL) 477 { 478 texture[0] = '\0'; 479 texture ++; 480 if (verbose>=3) 481 printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount()); 482 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 483 484 char* normal; 485 if ((normal = strstr (texture, "/")) !=NULL) 486 { 487 normal[0] = '\0'; 488 normal ++; 489 //glArrayElement(atoi(vertex)-1); 490 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 491 } 492 } 493 if (verbose>=3) 494 printf ("includeing vertex #%i, and mapping it to group vertex #%i, vertexArray has %i entries.\n", atoi(vertex), (atoi(vertex)-1 - currentGroup->firstVertex)*3, currentGroup->vertices->getCount()); 442 495 glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3); 443 496 … … 488 541 bool Object::readGroup (char* groupString) 489 542 { 490 // printf ("test\n"); 491 if (!strcmp(groupString, "default")) 492 { 493 if (groupCount != 0) 494 { 495 Group* newGroup = new Group; 496 finalizeGroup(currentGroup); 497 currentGroup->nextGroup = newGroup; 498 initGroup(newGroup); 499 currentGroup = newGroup; // must be after init see initGroup for more info 500 } 501 ++groupCount; 502 } 503 else 504 { 505 506 currentGroup->name = new char [strlen(groupString)]; 543 // setting the group name if not default. 544 if (strcmp(currentGroup->name, "default")) 545 { 546 currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char)); 507 547 strcpy(currentGroup->name, groupString); 508 548 } 549 if (groupCount != 0 && currentGroup->faceCount>0) 550 { 551 Group* newGroup = new Group; 552 finalizeGroup(currentGroup); 553 currentGroup->nextGroup = newGroup; 554 initGroup(newGroup); 555 cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup. 556 currentGroup = newGroup; // must be after init see initGroup for more info 557 } 558 559 ++groupCount; 560 509 561 } 510 562 -
orxonox/branches/dave/src/object.h
r2860 r3151 18 18 extern int verbose; //!< fill be removed and added again as a verbose-class 19 19 20 21 struct FaceElement 22 { 23 char value[20]; 24 FaceElement* next; 25 }; 20 26 21 27 //! Class that handles 3D-Objects. it can also read them in and display them. … … 49 55 Array* vTexture; 50 56 int faceMode; 57 int faceCount; 51 58 52 59 int firstVertex; … … 74 81 bool initGroup(Group* group); 75 82 bool finalizeGroup (Group* group); 83 bool cleanupGroup(Group* group); 76 84 77 85 -
orxonox/branches/dave/src/orxonox.cc
r2860 r3151 148 148 149 149 // Set window labeling 150 // TO DO: Add version information to caption 151 SDL_WM_SetCaption( "Orxonox", "Orxonox"); 150 SDL_WM_SetCaption( "Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION); 152 151 153 152 // TO DO: Create a cool icon and use it here -
orxonox/branches/dave/src/orxonox.h
r2636 r3151 7 7 #define ORXONOX_H 8 8 9 #include <SDL/SDL.h> 9 // this includes the information from configure/makefiles 10 #if HAVE_CONFIG_H 11 #include <config.h> 12 #endif 10 13 11 14 #include "stdincl.h" -
orxonox/branches/dave/src/player.cc
r2860 r3151 26 26 { 27 27 28 obj = new Object ("reap high.obj");28 obj = new Object ("reaplow.obj"); 29 29 /* 30 30 objectList = glGenLists(1); -
orxonox/branches/dave/src/stdincl.h
r2860 r3151 8 8 #include <windows.h> 9 9 #endif 10 11 #ifndef __APPLE__ 10 12 #include <SDL/SDL.h> 13 #else 14 #include <SDL.h> 15 #endif 16 11 17 #include <GL/gl.h> 12 18 #include <GL/glu.h> -
orxonox/branches/dave/src/vector.cc
r2860 r3151 843 843 return (n.dot(p) + k); 844 844 } 845 846 847 /** 848 \brief Creates a new BezierCurve 849 */ 850 BezierCurve::BezierCurve (void) 851 { 852 nodeCount = 0; 853 firstNode = new PathNode; 854 currentNode = firstNode; 855 856 firstNode->position = Vector (.0, .0, .0); 857 firstNode->number = 0; 858 firstNode->next = 0; // not sure if this really points to NULL!! 859 860 return; 861 } 862 863 /** 864 \brief Deletes a BezierCurve. 865 It does this by freeing all the space taken over from the nodes 866 */ 867 BezierCurve::~BezierCurve (void) 868 { 869 PathNode* tmpNode; 870 currentNode = firstNode; 871 while (tmpNode != 0) 872 { 873 tmpNode = currentNode; 874 currentNode = currentNode->next; 875 delete tmpNode; 876 } 877 } 878 879 /** 880 \brief adds a new Node to the bezier Curve 881 \param newNode a Vector to the position of the new node 882 */ 883 void BezierCurve::addNode(const Vector& newNode) 884 { 885 PathNode* tmpNode; 886 if (nodeCount == 0 ) 887 tmpNode = firstNode; 888 else 889 { 890 tmpNode = new PathNode; 891 currentNode = currentNode->next = tmpNode; 892 } 893 tmpNode->position = newNode; 894 tmpNode->next = 0; // not sure if this really points to NULL!! 895 tmpNode->number = (++nodeCount); 896 return; 897 } 898 899 /** 900 \brief calculates the Position on the curve 901 \param t The position on the Curve (0<=t<=1) 902 \return the Position on the Path 903 */ 904 Vector BezierCurve::calcPos(float t) 905 { 906 if (nodeCount <=4) 907 { 908 // if (verbose >= 1) 909 // printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount); 910 curvePoint = Vector(0,0,0); 911 } 912 PathNode* tmpNode = firstNode; 913 914 int k,kn,nn,nkn; 915 double blend,muk,munk; 916 Vector b = Vector(0.0,0.0,0.0); 917 918 muk = 1; 919 munk = pow(1-t,(double)nodeCount); 920 921 for (k=0; k<=nodeCount; k++) { 922 nn = nodeCount; 923 kn = k; 924 nkn = nodeCount - k; 925 blend = muk * munk; 926 muk *= t; 927 munk /= (1-t); 928 while (nn >= 1) { 929 blend *= nn; 930 nn--; 931 if (kn > 1) { 932 blend /= (double)kn; 933 kn--; 934 } 935 if (nkn > 1) { 936 blend /= (double)nkn; 937 nkn--; 938 } 939 } 940 b.x += tmpNode->position.x * blend; 941 b.y += tmpNode->position.y * blend; 942 b.z += tmpNode->position.z * blend; 943 944 tmpNode = tmpNode->next; 945 } 946 return b; 947 } 948 949 Vector BezierCurve::calcDirection (float t) 950 { 951 double diff = .00000000001; 952 953 Vector diffV = ((calcPos(t+diff) - calcPos(t))/diff); 954 diffV.normalize(); 955 return diffV; 956 } 957 958 /** 959 \brief returns the Position of the point calculated on the Curve 960 \return a Vector to the calculated position 961 */ 962 Vector BezierCurve::getPos() const 963 { 964 return curvePoint; 965 } -
orxonox/branches/dave/src/vector.h
r2551 r3151 149 149 }; 150 150 151 152 153 //! Bezier Curve 154 /** 155 Class to handle bezier curves in 3-dimesnsional space 156 157 needed for the Tracking system in OrxOnoX. 158 */ 159 class BezierCurve 160 { 161 private: 162 int nodeCount; 163 Vector curvePoint; 164 165 struct PathNode 166 { 167 int number; 168 Vector position; 169 PathNode* next; 170 }; 171 172 PathNode* firstNode; 173 PathNode* currentNode; 174 175 public: 176 BezierCurve (void); 177 ~BezierCurve (void); 178 void addNode (const Vector& newNode); 179 Vector calcPos (float t); 180 Vector calcDirection (float t); 181 182 Vector getPos () const; 183 }; 184 185 186 151 187 #endif
Note: See TracChangeset
for help on using the changeset viewer.