Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

collision detection: partial fix.

File size: 3.5 KB
RevLine 
[7353]1/*
2   orxonox - the future of 3D-vertical-scrollers
[8213]3
[7353]4   Copyright (C) 2006 orx
[8213]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.
[8213]10
[7353]11   ### File Specific:
12   main-programmer: bottac@ee.ethz.ch
[8213]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/
[8213]17
[8081]18   Collision detection adapted from:
19   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
[7353]20*/
21
[8217]22#ifndef _BSP_MANAGER_H
23#define _BSP_MANAGER_H
24
25
[7385]26#include <vector>
27#include <deque>
[7353]28
[8213]29
[8217]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
[8217]49class BspManager
[7353]50{
51public:
[7395]52  // Constructors
[8219]53  BspManager(WorldEntity* parent);
[8213]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();
[8195]60  const void tick(float time);
[8213]61  void draw_debug_face(int Face);
[7395]62  void draw_face(int Face);
63  void draw_patch(face* Face);
[7353]64
[8213]65
[8218]66  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
[8195]67                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
[7395]68
[7353]69private:
[7395]70  // Functions
71  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
[8195]72  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
[8213]73  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
[8195]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);
[7563]77  void  checkBrushRay(brush* curBrush);
[8081]78  void  checkBrushRayN(brush* curBrush);
[7395]79  void drawDebugCube(Vector* cam);
[7563]80  bool isAlreadyVisible(int Face);
81  void addFace(int Face);
[8213]82
[7563]83  // Data
84  BspFile*  bspFile;
85  BspTreeNode* root;
[7395]86  Vector cam;
87  Vector ship;
88  Vector  viewDir;
[8030]89  plane* collPlane;
[7563]90  int lastTex;
[8213]91
[8195]92  //obsolete: global variables for collision detection
[7563]93  bool  outputStartsOut;
94  bool  outputAllSolid;
95  float outputFraction;
[8195]96  Vector traceMins; //!< Mins of current bbox
97  Vector traceMaxs; //!< Maxs of current bbox
[8213]98  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
[8195]99                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
[8213]100
[8219]101  WorldEntity* parent;          //!< the parent entity of the bspManager: interface to this
[8213]102
[7395]103  bool * alreadyVisible;
104  // Deques to store the visible faces
105  ::std::deque<int> trasparent; //!< the ones with transparancy go here
106  ::std::deque<int> opal; //!< the others here.
[7385]107
[8195]108  Vector out;  //!< For debugging only
[8213]109  Vector out1; //!< For debugging only
[8195]110  Vector out2; //!< For debugging only
[8317]111                       
112  int tgl;
[7353]113};
114
[8217]115#endif /* _BSP_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.