Files
academy2/modules/world/road_map.cpp
2021-10-13 16:33:36 +03:00

65 lines
1.2 KiB
C++

#include "road_map.h"
#define MIN_X (-10000)
#define MAX_X (10000)
#define MIN_Z (-10000)
#define MAX_Z (10000)
#define MIN_Y (-100)
#define MAX_Y (300)
#define HIGHWAY_LENGTH_MIN 100
#define HIGHWAY_LENGTH_MAX 300
static RoadMap *g_road_map_data = NULL;
RoadMap *RoadMap::get_singleton()
{
return g_road_map_data;
}
void RoadMap::create_singleton()
{
g_road_map_data = memnew(RoadMap);
}
void RoadMap::destroy_singleton()
{
memdelete(g_road_map_data);
g_road_map_data = NULL;
}
RoadMap::RoadMap()
{
noise.instance();
rnd.instance();
}
RoadMap::~RoadMap()
{
}
class PrimaryNetwork {
Vector<Vector3> points;
friend class RoadMap;
void start();
};
void PrimaryNetwork::start()
{
#if 0
Vector3 start_pos, start_dir;
float l, a;
Transform xform;
start_pos.x = MIN_X + ((float)(MAX_X - MIN_X)) * rnd.randf();
start_pos.y = MIN_Y + ((float)(MAX_X - MIN_Y)) * rnd.randf();
start_pos.z = MIN_Z + ((float)(MAX_X - MIN_Z)) * rnd.randf();
l = HIGHWAY_LENGTH_MIN + ((float)(HIGHWAY_LENGTH_MAX - HIGHWAY_LENGTH_MIN)) * rnd.randf();
start_dir = Vector3(l, 0.0f, 0.0f);
start_pos.y = CLAMP(start_pos.y, 1.0f, MAX_Y);
xform = Transform();
#endif
}
void RoadMap::gen_primary_network()
{
PrimaryNetwork p;
p.start();
}