Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/lib/graphics/importer/bsp_manager.h @ 8714

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

Ground walk

File size: 3.7 KB
RevLine 
[7353]1/*
2   orxonox - the future of 3D-vertical-scrollers
[8490]3
[7353]4   Copyright (C) 2006 orx
[8490]5
[7353]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.
[8490]10
[7353]11   ### File Specific:
12   main-programmer: bottac@ee.ethz.ch
[8490]13
[8081]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/
[8490]17
[8081]18   Collision detection adapted from:
19   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
[7353]20*/
21
[8490]22#ifndef _BSP_MANAGER_H
23#define _BSP_MANAGER_H
24
25
[7385]26#include <vector>
27#include <deque>
[7353]28
[8490]29
30
[7563]31// FORWARD DECLARATIONS
[7353]32class  BspFile;
33class BspTreeLeaf;
34class BspTreeNode;
35class Vector;
36class set;
37struct face;
[7563]38struct brush;
[8030]39struct plane;
40
[7833]41class WorldEntity;
[7353]42
[8081]43struct BspCollisionEvent
44{
45  Vector normal; //!< normal Vector, length 1
46  Vector place;  //!< Absoloute coordinates of collision
47};
48
[7353]49class BspManager
50{
51public:
[7395]52  // Constructors
[8490]53  BspManager(WorldEntity* parent);
54
[8081]55  BspManager(const char* fileName, float scale = 0.4f);
56  void load(const char* fileName, float scale);
[7353]57
[7395]58  // Functions
[8081]59  const void draw();
[8490]60  const void tick(float time);
61  void draw_debug_face(int Face);
[7395]62  void draw_face(int Face);
63  void draw_patch(face* Face);
[7353]64
[7395]65
[8490]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
[7353]69private:
[7395]70  // Functions
71  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
[8490]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);
[8714]75  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
[8490]76  void  checkCollisionBox(void);
[7563]77  void  checkBrushRay(brush* curBrush);
[8081]78  void  checkBrushRayN(brush* curBrush);
[8714]79  void  checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
80  float  checkPatchAltitude(BspTreeNode* node); //! To be implemented...
[8490]81
[7395]82  void drawDebugCube(Vector* cam);
[7563]83  bool isAlreadyVisible(int Face);
84  void addFace(int Face);
[8490]85
[7563]86  // Data
87  BspFile*  bspFile;
88  BspTreeNode* root;
[7395]89  Vector cam;
90  Vector ship;
91  Vector  viewDir;
[8030]92  plane* collPlane;
[7563]93  int lastTex;
[8490]94
95  //obsolete: global variables for collision detection
[7563]96  bool  outputStartsOut;
97  bool  outputAllSolid;
98  float outputFraction;
[8490]99  Vector inputStart;
100  Vector inputEnd;
[7563]101 
[8490]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
[7395]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.
[7385]113
[8490]114  Vector out;  //!< For debugging only
115  Vector out1; //!< For debugging only
116  Vector out2; //!< For debugging only
117                       
118  int tgl;
[7353]119};
120
[8490]121#endif /* _BSP_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.