1 //-----------------------------------------------------------------------------
2 // World
3 //-----------------------------------------------------------------------------
4 
5 #ifndef __WORLD_H__
6 #define __WORLD_H__
7 
8 #include "cake.h"
9 #include "shader.h"
10 #include "client.h"
11 #include "q3bsp.h"
12 #include "vars.h"
13 
14 extern Var sv_gravity;
15 
16 /**
17  * World class
18  * @todo Use a stack of frustums and cameras.
19  */
20 class World
21 {
22   public:
23     World(void);
24     ~World(void);
25 
26     /**
27      * Adds a map to the world.
28      * The function creates a new Q3BSP object and load the map in it.
29      * @param name the name of the map
30      * @return an integer value that is 1 if map was loaded correctly, 0 if not
31      * @todo Check memory leak in the case of unexistent maps
32      */
33     int AddMap(const char *name);
34 
35     /**
36      * Get a pointer on Q3 BSP structure.
37      * @return A pointer on q3 bsp or null pointer if bsp does not exist.
38      */
39     Q3BSP* GetBSP(void);
40 
41     /**
42      * Initialize the world.
43      * Initialize the bsp and the shaders. This must be called
44      * before trying to render the world.
45      */
46     void Init(void);
47 
48     /**
49      * Shuts the world.
50      * Destroys the BSP and reset shaders.
51      */
52     void Shut(void);
53 
54     /**
55      * Renders the world.
56      * @param clients A pointer to the clients array
57      * @param numclients The number of clients
58      */
59     void Render(Client *clients, int numclients);
60 
61     /**
62      * Set a client to a specific start position.
63      * @param c the destination client
64      * @param n the indice of start pos
65      */
66     void SetStartPos(Client *c, int n = 0);
67 
68     /**
69      * Get the number of start positions in the map.
70      * The function returns the number of start position that were found
71      * in the map entity.
72      * @return the number of start pos.
73      */
74     int GetNumStartPos(void);
75 
76   public:
77 
78     char mapname[32];       /**< current map name */
79 
80     ShaderManager shaders;
81 
82     float gravity;          /**< world gravity */
83     float maxvspeed;        /**< world maximum falling speed */
84 
85   private:
86     Q3BSP *   bsp;
87 };
88 
89 #endif  /* __WORLD_H__ */
90