Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/bsp/bsp_manager.h @ 10607

Last change on this file since 10607 was 10519, checked in by patrick, 18 years ago

emitter fix

File size: 4.1 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2006 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: bottac@ee.ethz.ch
13
14   Inspired by:
15   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
16   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
17
18   Collision detection adapted from:
19   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
20*/
21
22#ifndef _BSP_MANAGER_H
23#define _BSP_MANAGER_H
24
25
26#include <vector>
27#include <deque>
28
29
30#define BSP_X_OFFSET 20.0f
31#define BSP_Y_OFFSET 40.0f
32#define BSP_Z_OFFSET 20.0f
33
34
35// FORWARD DECLARATIONS
36class  BspFile;
37class BspTreeLeaf;
38class BspTreeNode;
39class Vector;
40class set;
41struct face;
42struct brush;
43struct plane;
44
45class WorldEntity;
46
47
48// Obsolete
49struct BspCollisionEvent
50{
51  Vector normal; //!< normal Vector, length 1
52  Vector place;  //!< Absoloute coordinates of collision
53};
54
55class BspManager
56{
57public:
58  // Constructors
59  BspManager(WorldEntity* parent);
60
61  BspManager(const char* fileName, float scale = 0.4f);
62
63  // Deconstructor
64  ~BspManager();
65
66
67
68  // Functions
69  int load(const char* fileName, float scale);
70  const void draw();
71  const void tick(float time);
72  void draw_debug_face(int Face);
73  void draw_face(int Face);
74  void draw_patch(face* Face);
75
76
77  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
78                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
79
80  int sortTransparency;              //!< sort transparent textures
81  int sortTransparencyMore;          //!< sort transparent textures better
82
83private:
84  // collision functions
85  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
86  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
87  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
88  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
89
90  void checkCollisionX(WorldEntity* entity);
91  void checkCollisionY(WorldEntity* entity);
92  void checkCollisionZ(WorldEntity* entity);
93
94  void  checkCollisionBox(void);
95  void  checkBrushRay(brush* curBrush);
96  void  checkBrushRayN(brush* curBrush);
97  void  checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
98  float checkPatchAltitude(BspTreeNode* node); //! To be implemented...
99
100  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
101
102
103  // visibility functions
104  void drawDebugCube(Vector* cam);
105  bool isAlreadyVisible(int Face);
106  void addFace(int Face);
107
108  // Data
109  BspFile*  bspFile;
110  BspTreeNode* root;
111  Vector cam;
112  Vector ship;
113  Vector  viewDir;
114  plane* collPlane;
115  int lastTex;
116
117  //obsolete: global variables for collision detection
118  bool  outputStartsOut;
119  bool  outputAllSolid;
120  float outputFraction;
121  Vector inputStart;
122  Vector inputEnd;
123
124  Vector traceMins; //!< Mins of current bbox
125  Vector traceMaxs; //!< Maxs of current bbox
126  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
127                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
128
129  WorldEntity* parent;          //!< the parent entity of the bspManager: interface to this
130
131  bool * alreadyVisible;
132  // Deques to store the visible faces
133  ::std::vector<int> trasparent; //!< the ones with transparancy go here
134  ::std::vector<int> opal; //!< the others here.
135
136  Vector out;  //!< Stores collision coordinates
137  Vector out1; //!< For debugging only
138  Vector out2; //!< For debugging only
139
140  int tgl;
141};
142
143#endif /* _BSP_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.