author | Tero Marttila <terom@fixme.fi> |
Thu, 22 Jan 2009 02:56:50 +0200 | |
branch | new_graphics |
changeset 420 | 278020dcd9b7 |
parent 409 | 1a03ff151abc |
child 423 | 947ab54de4b7 |
permissions | -rw-r--r-- |
197 | 1 |
#ifndef PHYSICS_WORLD_HH |
2 |
#define PHYSICS_WORLD_HH |
|
3 |
||
4 |
#include <ClanLib/display.h> |
|
5 |
#include <ClanLib/core.h> |
|
6 |
||
7 |
#include <algorithm> |
|
8 |
#include <functional> |
|
9 |
#include <cmath> |
|
199 | 10 |
|
205 | 11 |
#include "Terrain.hh" |
199 | 12 |
|
197 | 13 |
class PhysicsWorld; |
14 |
||
15 |
#include "PhysicsObject.hh" |
|
16 |
#include "Vector.hh" |
|
205 | 17 |
#include "Timer.hh" |
197 | 18 |
#include "Config.hh" |
19 |
||
20 |
/** |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
21 |
* PhysicsWorld class. PhysicsWorld contains a number of PhysicsObjects that are simulated forward in time using |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
22 |
* the physics tick rate |
197 | 23 |
*/ |
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
24 |
class PhysicsWorld { |
197 | 25 |
friend class PhysicsObject; |
26 |
||
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
27 |
// XXX: needs some fixing up, move Terrain methods |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
28 |
public: |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
29 |
/** The world's terrain */ |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
30 |
Terrain &terrain; |
409
1a03ff151abc
add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents:
408
diff
changeset
|
31 |
|
1a03ff151abc
add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents:
408
diff
changeset
|
32 |
/** Size of simulation area */ |
1a03ff151abc
add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents:
408
diff
changeset
|
33 |
Vector dimensions; |
197 | 34 |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
35 |
protected: |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
36 |
/** List of simulated objects*/ |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
37 |
std::list<PhysicsObject*> objects; |
208 | 38 |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
39 |
/** Gravity vector */ |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
40 |
Vector gravity; |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
41 |
|
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
42 |
/** Physics simulation ticks */ |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
43 |
Timer tick_timer; |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
44 |
|
197 | 45 |
CL_SlotContainer slots; |
46 |
||
47 |
public: |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
48 |
/** |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
49 |
* Construct a world with the given configuration. |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
50 |
*/ |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
51 |
PhysicsWorld (Vector gravity, Vector dimensions, Terrain &terrain); |
199 | 52 |
|
225 | 53 |
/** |
197 | 54 |
* Add object to the PhysicsWorld. |
55 |
* |
|
56 |
* @param object Pointer to the PhysicsObject to add. |
|
57 |
*/ |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
300
diff
changeset
|
58 |
void addPhysicsObject (PhysicsObject *object); |
197 | 59 |
|
60 |
/** |
|
225 | 61 |
* Remove the object from the PhysicsWorld. |
62 |
*/ |
|
63 |
void removePhysicsObject (PhysicsObject *po); |
|
64 |
||
65 |
/** |
|
197 | 66 |
* Advance one time step in physics simulation. |
67 |
*/ |
|
300 | 68 |
void tick (TimeMS tick_length); |
197 | 69 |
|
70 |
/** |
|
71 |
* Get current tick in physics simulation. |
|
72 |
* |
|
73 |
* @return tick Current simulation tick. |
|
74 |
*/ |
|
300 | 75 |
TickCount getTicks (void); |
197 | 76 |
}; |
77 |
||
78 |
#endif |