Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ODE/src/lib/graphics/importer/bsp_manager.h @ 10158

Last change on this file since 10158 was 9919, checked in by bottac, 18 years ago

CrPhysicsFullWalk on Static Models and BSP Patches almost working. libODE≥0.7 required.
Screenshot: http://people.ee.ethz.ch/~bottac/Collision_ODE/

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