Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8734 was 8724, checked in by bensch, 18 years ago

merged the bsp-model-stuff back here

File size: 3.7 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
31// FORWARD DECLARATIONS
32class  BspFile;
33class BspTreeLeaf;
34class BspTreeNode;
35class Vector;
36class set;
37struct face;
38struct brush;
39struct plane;
40
41class WorldEntity;
42
43struct BspCollisionEvent
44{
45  Vector normal; //!< normal Vector, length 1
46  Vector place;  //!< Absoloute coordinates of collision
47};
48
49class BspManager
50{
51public:
52  // Constructors
53  BspManager(WorldEntity* parent);
54
55  BspManager(const char* fileName, float scale = 0.4f);
56  void load(const char* fileName, float scale);
57
58  // Functions
59  const void draw();
60  const void tick(float time);
61  void draw_debug_face(int Face);
62  void draw_face(int Face);
63  void draw_patch(face* Face);
64
65
66  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
67                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
68
69private:
70  // Functions
71  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
72  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
73  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
74  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
75  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
76  void  checkCollisionBox(void);
77  void  checkBrushRay(brush* curBrush);
78  void  checkBrushRayN(brush* curBrush);
79  void  checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
80  float  checkPatchAltitude(BspTreeNode* node); //! To be implemented...
81
82  void drawDebugCube(Vector* cam);
83  bool isAlreadyVisible(int Face);
84  void addFace(int Face);
85
86  // Data
87  BspFile*  bspFile;
88  BspTreeNode* root;
89  Vector cam;
90  Vector ship;
91  Vector  viewDir;
92  plane* collPlane;
93  int lastTex;
94
95  //obsolete: global variables for collision detection
96  bool  outputStartsOut;
97  bool  outputAllSolid;
98  float outputFraction;
99  Vector inputStart;
100  Vector inputEnd;
101 
102  Vector traceMins; //!< Mins of current bbox
103  Vector traceMaxs; //!< Maxs of current bbox
104  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
105                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
106
107  WorldEntity* parent;          //!< the parent entity of the bspManager: interface to this
108
109  bool * alreadyVisible;
110  // Deques to store the visible faces
111  ::std::deque<int> trasparent; //!< the ones with transparancy go here
112  ::std::deque<int> opal; //!< the others here.
113
114  Vector out;  //!< For debugging only
115  Vector out1; //!< For debugging only
116  Vector out2; //!< For debugging only
117                       
118  int tgl;
119};
120
121#endif /* _BSP_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.