1 | /*==========================================================================
|
---|
2 | * (C) 2006 Universidad Jaime I de Castellón
|
---|
3 | *==========================================================================
|
---|
4 | * PROYECT: GAME TOOLS
|
---|
5 | *==========================================================================*/
|
---|
6 | /* CONTENT:
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * @file GeoLodManager.h
|
---|
10 | *==========================================================================*/
|
---|
11 |
|
---|
12 | #ifndef _GEOLODMANAGER
|
---|
13 | #define _GEOLODMANAGER
|
---|
14 |
|
---|
15 | #include "GeoVector3.h"
|
---|
16 | #include "GeoLodObject.h"
|
---|
17 | #include <map>
|
---|
18 |
|
---|
19 | namespace Geometry
|
---|
20 | {
|
---|
21 | class lodobj_dist_node_t
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | lodobj_dist_node_t(LodObject *o):dist2cam(0.0f),lodobj(o){}
|
---|
25 | lodobj_dist_node_t(const lodobj_dist_node_t &c):dist2cam(c.dist2cam),lodobj(c.lodobj){}
|
---|
26 | lodobj_dist_node_t(void):dist2cam(0.0f),lodobj(NULL){}
|
---|
27 | float dist2cam;
|
---|
28 | LodObject *lodobj;
|
---|
29 | bool operator < (const lodobj_dist_node_t &o) const { return (dist2cam < o.dist2cam); }
|
---|
30 | };
|
---|
31 |
|
---|
32 | class lodobj_idpos_node_t;
|
---|
33 |
|
---|
34 | class LodManager
|
---|
35 | {
|
---|
36 | public:
|
---|
37 | LodManager(float near, float far, const Geometry::Vector3 &campos);
|
---|
38 | void AddLodObj(LodObject*, const Geometry::Vector3 &);
|
---|
39 | void UpdateLOD(void);
|
---|
40 | void UpdateCamera(const Geometry::Vector3 &);
|
---|
41 | void UpdateLODObjectPos(LodObject*,const Geometry::Vector3 &);
|
---|
42 | private:
|
---|
43 | std::map<float,Geometry::lodobj_dist_node_t> lodobj_dists; // key: dist2cam for efficient distance finding
|
---|
44 | std::map<Geometry::lodobj_idpos_node_t,Geometry::Vector3> lodobj_pos; // map key: LodObject UniqueID for efficient ID-based finding
|
---|
45 | unsigned int targetFPS;
|
---|
46 | Vector3 camera_pos;
|
---|
47 | bool camera_changed;
|
---|
48 | float near_range, far_range;
|
---|
49 | float CalculateDistToCamera(const Geometry::Vector3 &) const;
|
---|
50 | float SelectRandomDistance(void) const;
|
---|
51 | };
|
---|
52 | };
|
---|
53 |
|
---|
54 | #endif |
---|