added relative camera controls, now handles like an actual fly cam.
This commit is contained in:
@@ -19,10 +19,11 @@ public:
|
||||
|
||||
int slew_camera(sf::Vector2f input);
|
||||
|
||||
int update();
|
||||
int update(double delta_time);
|
||||
|
||||
void* get_direction_pointer();
|
||||
void* get_position_pointer();
|
||||
sf::Vector2f* get_direction_pointer();
|
||||
sf::Vector3f* get_position_pointer();
|
||||
sf::Vector3f* get_movement_pointer();
|
||||
|
||||
sf::Vector3f get_movement();
|
||||
sf::Vector3f get_position();
|
||||
|
||||
@@ -6,10 +6,68 @@
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <cmath>
|
||||
#include <deque>
|
||||
|
||||
class Map {
|
||||
public:
|
||||
|
||||
// In addition to traversing the voxel hierarchy, we must also be able to
|
||||
// tell which block a given voxel resides in.This is accomplished us -
|
||||
// ing 32 - bit page headers spread amongst the child descriptors.Page
|
||||
// headers are placed at every 8 kilobyte boundary, and each contains
|
||||
// a relative pointer to the block info section.By placing the begin -
|
||||
// ning of the child descriptor array at such a boundary, we can always
|
||||
// find a page header by simply clearing the lowest bits of any child
|
||||
// descriptor pointer.
|
||||
struct page_header {
|
||||
int bitmask;
|
||||
};
|
||||
|
||||
struct leaf_node {
|
||||
long bitmask;
|
||||
};
|
||||
|
||||
|
||||
short scale;
|
||||
|
||||
void generate_octree() {
|
||||
|
||||
uint64_t *octree = new uint64_t[200];
|
||||
|
||||
|
||||
long tree_node = 0;
|
||||
|
||||
std::vector<long> page_array;
|
||||
|
||||
// Page placed every 8 kilobytes
|
||||
// contains a relative pointer to the block info section
|
||||
uint32_t page = 255;
|
||||
|
||||
// Child pointer points to the first non-leaf child of this node
|
||||
uint16_t child_pointer = 20;
|
||||
|
||||
|
||||
uint32_t pointer = page | child_pointer;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Map(sf::Vector3i dim) {
|
||||
|
||||
//generate_octree();
|
||||
//return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dimensions = dim;
|
||||
std::mt19937 gen;
|
||||
std::uniform_real_distribution<double> dis(-1.0, 1.0);
|
||||
@@ -147,14 +205,14 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// for (int x = 0; x < dim.x / 10; x++) {
|
||||
// for (int y = 0; y < dim.y / 10; y++) {
|
||||
// for (int z = 0; z < dim.z; z++) {
|
||||
// if (rand() % 1000 < 1)
|
||||
// list[x + dim.x * (y + dim.z * z)] = rand() % 6;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (int x = 0; x < dim.x / 10; x++) {
|
||||
for (int y = 0; y < dim.y / 10; y++) {
|
||||
for (int z = 0; z < dim.z; z++) {
|
||||
if (rand() % 1000 < 1)
|
||||
list[x + dim.x * (y + dim.z * z)] = rand() % 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -162,6 +220,11 @@ public:
|
||||
~Map() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sf::Vector3i getDimensions();
|
||||
char *list;
|
||||
sf::Vector3i dimensions;
|
||||
|
||||
@@ -39,6 +39,32 @@ private:
|
||||
double fps_average = 0;
|
||||
};
|
||||
|
||||
struct debug_text {
|
||||
public:
|
||||
debug_text(int slot, int pixel_spacing, void* data_, std::string prefix_) : data(data_), prefix(prefix_) {
|
||||
if (!f.loadFromFile("../assets/fonts/Arial.ttf")) {
|
||||
std::cout << "couldn't find the fall back Arial font in ../assets/fonts/" << std::endl;
|
||||
}
|
||||
else {
|
||||
t.setFont(f);
|
||||
t.setCharacterSize(20);
|
||||
t.setPosition(20, slot * pixel_spacing);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void draw(sf::RenderWindow *r) {
|
||||
t.setString(prefix + std::to_string(*(float*)data));
|
||||
r->draw(t);
|
||||
}
|
||||
|
||||
private:
|
||||
void* data;
|
||||
std::string prefix;
|
||||
sf::Font f;
|
||||
sf::Text t;
|
||||
|
||||
};
|
||||
|
||||
inline sf::Vector3f SphereToCart(sf::Vector2f i) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user