Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc @ 4640

Last change on this file since 4640 was 4640, checked in by bensch, 19 years ago

orxonox/trunk: now the collision-detection-module does not need GUI anymore

File size: 5.2 KB
Line 
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: Benjamin Grauer
13   co-programmer: ...
14
15   this file extends the framework file, so it renders what i want.
16*/
17
18#include "framework.h"
19
20#include "fields.h"
21#include "stdlibincl.h"
22#include "light.h"
23
24#include "cd_engine.h"
25#include "bv_tree.h"
26
27#include "md2Model.h"
28
29
30
31
32MD2Model* model;
33int drawMode;
34int depth;
35
36void Framework::moduleInit(int argc, char** argv)
37{
38  CDEngine::getInstance();
39  CDEngine::getInstance()->debug();
40
41  //model = new MD2Model("models/tris.md2", "models/tris.pcx");
42  //model->tick(0.1f);
43
44//   int const length = 6;
45//   sVec3D* vertList = new sVec3D[length];
46//   sVec3D data[length]  = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}};
47//
48//   for(int i = 0; i < length; ++i)
49//   {
50//     vertList[i][0] = data[i][0];
51//     vertList[i][1] = data[i][1];
52//     vertList[i][2] = data[i][2];
53//   }
54
55  //CDEngine::getInstance()->debugSpawnTree(3, model->data->pVertices, model->data->numVertices);
56
57
58  LightManager* lightMan = LightManager::getInstance();
59  lightMan->setAmbientColor(.1,.1,.1);
60  lightMan->addLight();
61  lightMan->setPosition(30, 30, 30);
62  lightMan->addLight();
63  lightMan->setPosition(-30, -30, -30);
64
65  drawMode = DRAW_MODEL;
66  depth = 2;
67
68  printf("\n\n===========================");
69  printf("Collision Detection Modler:\n");
70  printf("Key Bindings:\n");
71  printf(" -| Displaying Polygons\t\t p\n");
72  printf(" -| Displaying Separation Plane\t s\n");
73  printf("\n");
74  printf(" -| Tree Depth 0\t\t 0\n");
75  printf(" -| Tree Depth 1\t\t 1\n");
76  printf(" -| Tree Depth 2\t\t 2\n");
77  printf(" -| Tree Depth 3\t\t 3\n");
78  printf(" -| Tree Depth 4\t\t 4\n");
79  printf(" -| Tree Depth 5\t\t 5\n");
80  printf("===========================\n\n");
81}
82
83
84void Framework::moduleEventHandler(SDL_Event* event)
85{
86  switch (event->type)
87  {
88    case SDL_KEYDOWN:
89      switch (event->key.keysym.sym)
90      {
91        case SDLK_a:
92          drawMode |= DRAW_ALL;
93          break;
94        case SDLK_0:
95        {
96          printf("Setting tree depth = 0\n");
97          depth = 0;
98          int temp = drawMode & DRAW_ALL;
99          drawMode ^= temp;
100          drawMode |= DRAW_SINGLE;
101          break;
102        }
103        case SDLK_1:
104        {
105          printf("Setting tree depth = 1\n");
106          depth = 1;
107          int temp = drawMode & DRAW_ALL;
108          drawMode ^= temp;
109          drawMode |= DRAW_SINGLE;
110          break;
111        }
112        case SDLK_2:
113        {
114          printf("Setting tree depth = 2\n");
115          depth = 2;
116          int temp = drawMode & DRAW_ALL;
117          drawMode ^= temp;
118          drawMode |= DRAW_SINGLE;
119          break;
120        }
121        case SDLK_3:
122        {
123          printf("Setting tree depth = 3\n");
124          depth = 3;
125          int temp = drawMode & DRAW_ALL;
126          drawMode ^= temp;
127          drawMode |= DRAW_SINGLE;
128          break;
129        }
130        case SDLK_4:
131        {
132          printf("Setting tree depth = 4\n");
133          depth = 4;
134          int temp = drawMode & DRAW_ALL;
135          drawMode ^= temp;
136          drawMode |= DRAW_SINGLE;
137          break;
138        }
139        case SDLK_5:
140        {
141          printf("Setting tree depth = 5\n");
142          depth = 5;
143          int temp = drawMode & DRAW_ALL;
144          drawMode ^= temp;
145          drawMode |= DRAW_SINGLE;
146          break;
147        }
148        case SDLK_6:
149        {
150          printf("Setting tree depth = 6\n");
151          depth = 6;
152          int temp = drawMode & DRAW_ALL;
153          drawMode ^= temp;
154          drawMode |= DRAW_SINGLE;
155          break;
156        }
157        case SDLK_s:
158          if(drawMode & DRAW_SEPARATING_PLANE)
159          {
160            int temp = drawMode & DRAW_SEPARATING_PLANE;
161            drawMode ^= temp;
162            printf("Removing Separation Plane\n");
163          }
164          else
165          {
166            drawMode |= DRAW_SEPARATING_PLANE;
167            printf("Drawing Separation Plane\n");
168          }
169
170          break;
171        case SDLK_p:
172          if(drawMode & DRAW_BV_POLYGON)
173          {
174            int temp = drawMode & DRAW_BV_POLYGON;
175            drawMode ^= temp;
176            printf("Removing OBB Polygons\n");
177          }
178          else
179          {
180            drawMode |= DRAW_BV_POLYGON;
181            printf("Drawing OBB Polygons\n");
182          }
183          break;
184
185      }
186  }
187}
188
189
190void Framework::moduleTick(float dt)
191{
192}
193
194
195void Framework::moduleDraw() const
196{
197  CDEngine::getInstance()->drawBV(depth, drawMode);
198
199  LightManager::getInstance()->draw();
200
201  //model->draw();
202}
203
204
205void Framework::moduleHelp(void) const
206{
207  PRINT(0)("\n");
208  PRINT(0)("i - print debug information of Collision-detection\n");
209  PRINT(0)("\n");
210}
211
212/*
213void Framework::moduleInitGui(int argc, char** argv)
214{
215  Window* guiMainWindow = NULL;
216
217  initGUI(0, NULL);
218
219  guiMainWindow = new Window("Collision_detection");
220  {
221    //all the Widgets you need
222  }
223  Window::mainWindow->showall();
224  Window::mainWindow->setSize(300, 500);
225}
226*/
Note: See TracBrowser for help on using the repository browser.