Finally found the root of that off by one error. Changed up the readme.

This commit is contained in:
MitchellHansen
2017-01-16 02:31:51 -08:00
parent cc7a4a2efb
commit abec38e7c7
8 changed files with 91 additions and 32 deletions

View File

@@ -93,11 +93,13 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
vr::KeyHeld *held_event = static_cast<vr::KeyHeld*>(event.get());
default_impulse = 1.0f;
if (held_event->code == sf::Keyboard::LShift) {
default_impulse = 0.2f;
}
if (held_event->code == sf::Keyboard::RShift) {
default_impulse = 1.0f;
}
else if (held_event->code == sf::Keyboard::C) {
look_at_center();
}

View File

@@ -26,7 +26,8 @@ void Old_Map::generate_terrain() {
voxel_data[i] = 0;
}
set_voxel(sf::Vector3i(75, 75, 75), 5);
//set_voxel(sf::Vector3i(63, 63, 63), 1);
for (int i = 0; i < dimensions.x * dimensions.y; i++) {
height_map[i] = 0;
@@ -37,7 +38,7 @@ void Old_Map::generate_terrain() {
int DATA_SIZE = dimensions.x + 1;
//an initial seed value for the corners of the data
//srand(f_rand());
double SEED = rand() % 30 + 55;
double SEED = rand() % 5 + 10;
//seed the data
set_sample(0, 0, SEED);
@@ -45,7 +46,7 @@ void Old_Map::generate_terrain() {
set_sample(dimensions.x, 0, SEED);
set_sample(dimensions.x, dimensions.y, SEED);
double h = 30.0;//the range (-h -> +h) for the average offset
double h = 5.0;//the range (-h -> +h) for the average offset
//for the new value in range of h
//side length is distance of a single square side
//or distance of diagonal in diamond
@@ -138,6 +139,16 @@ void Old_Map::generate_terrain() {
}
for (int x = dimensions.x / 2; x < dimensions.x / 2 + dimensions.x / 16; x++) {
for (int y = dimensions.x / 2; y < dimensions.y / 2 + dimensions.x / 16; y++) {
for (int z = 0; z < 20; z++) {
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
}
}
}
for (int x = 0; x < dimensions.x; x++) {
for (int y = 0; y < dimensions.y; y++) {
// for (int z = 0; z < dimensions.z; z++) {

View File

@@ -40,9 +40,9 @@ const int WINDOW_X = 1000;
const int WINDOW_Y = 1000;
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
const int MAP_X = 512;
const int MAP_Y = 512;
const int MAP_Z = 512;
const int MAP_X = 128;
const int MAP_Y = 128;
const int MAP_Z = 128;
float elap_time(){
static std::chrono::time_point<std::chrono::system_clock> start;
@@ -115,8 +115,8 @@ int main() {
// Light for the currently non functional Bling Phong shader
Light l;
l.direction_cartesian = sf::Vector3f(-0.2f, -0.2f, -1.5f);
l.position = sf::Vector3f(100.0f, 500.0f, 100.0f);
l.direction_cartesian = sf::Vector3f(-1.0f, -1.0f, -1.5f);
l.position = sf::Vector3f(256.0f, 256.0f, 256.0f);
l.rgbi = sf::Vector4f(0.3f, 0.4f, 0.3f, 1.0f);
std::vector<Light> light_vec;
@@ -157,6 +157,8 @@ int main() {
bool reset = false;
double timer_accumulator = 0.0;
Input input_handler;
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyHeld);
@@ -182,6 +184,19 @@ int main() {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::L)) {
light_vec.at(0).position = camera->get_position();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::N)) {
light_vec.at(0).orbit_around_center(timer_accumulator += delta_time);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::N)) {
std::string path = "../assets/";
std::string filename;
std::getline(std::cin, filename);
filename += ".png";
sf::Image image = window.capture();
image.saveToFile(path + filename);
}
// Time keeping
elapsed_time = elap_time();
@@ -196,6 +211,8 @@ int main() {
// ==== DELTA TIME LOCKED ====
}
// ==== FPS LOCKED ====
camera->update(delta_time);