Did this work?

master
mitchellhansen 7 years ago
parent 2d2a854f0f
commit 58ef1da02a

@ -1,3 +1,3 @@
[LOGGING] [LOGGING]
log_level = 0 # INFO, WARN, ERROR log_level = 0 # INFO, WARN, ERROR
log_dest = 0 # STDOUT, FILE log_dest = 0 # STDOUT, FILE

@ -1,3 +1,3 @@
[GRAPHICS] [GRAPHICS]
x_resolution = 800 x_resolution = 800
y_resolution = 800 y_resolution = 800

@ -34,9 +34,8 @@
// Srsly people who macro error codes are the devil // Srsly people who macro error codes are the devil
#undef ERROR #undef ERROR
#include "Logger.h" #include "Logger.h"
#include "FrameWatcher.h"
class Application: private Gui { class Application {
public: public:
const int WINDOW_X = 1536; const int WINDOW_X = 1536;
@ -72,8 +71,6 @@ private:
Input input_handler; Input input_handler;
std::shared_ptr<WindowHandler> window_handler; std::shared_ptr<WindowHandler> window_handler;
FrameWatcher frame_watcher;
// The sfml imgui wrapper I'm using requires Update be called with sf::Time // The sfml imgui wrapper I'm using requires Update be called with sf::Time
// Might modify it to also accept seconds // Might modify it to also accept seconds
sf::Clock sf_delta_clock; sf::Clock sf_delta_clock;
@ -93,9 +90,4 @@ private:
delta_time = 0.0, delta_time = 0.0,
accumulator_time = 0.0, accumulator_time = 0.0,
current_time = 0.0; current_time = 0.0;
public: };
virtual void render_gui() override;
virtual void update_gui() override;
};

@ -26,7 +26,7 @@ public:
int update(double delta_time); int update(double delta_time);
void look_at(sf::Vector3f position); void look_at_center();
sf::Vector2f* get_direction_pointer(); sf::Vector2f* get_direction_pointer();
sf::Vector3f* get_position_pointer(); sf::Vector3f* get_position_pointer();

@ -57,12 +57,6 @@ namespace vr {
NetworkJoystickMoved, NetworkJoystickMoved,
NetworkJoystickConnected, NetworkJoystickConnected,
NetworkJoystickDisconnected, NetworkJoystickDisconnected,
Tick120Seconds,
Tick60Seconds,
Tick30Seconds,
Tick20Seconds,
Tick10Seconds,
Tick5Seconds,
Count Count
}; };
@ -78,6 +72,8 @@ namespace vr {
}; };
class Closed : public Event { class Closed : public Event {
public: public:
Closed() : Event(vr::Event::EventType::Closed) {}; Closed() : Event(vr::Event::EventType::Closed) {};

@ -1,27 +0,0 @@
#pragma once
#include "Pub_Sub.h"
class FrameWatcher : public VrEventPublisher{
public:
FrameWatcher();
~FrameWatcher();
void do_tick();
private:
float get_elapsed_time();
float step_size = 0.0166f;
double frame_time = 0.0;
double elapsed_time = 0.0;
double delta_time = 0.0;
double accumulator_time = 0.0;
double current_time = 0.0;
};

@ -1,66 +1,66 @@
#pragma once #pragma once
#include <mutex> #include <mutex>
#include <Logger.h> #include <Logger.h>
#include <list> #include <list>
class Gui { class Gui {
public: public:
Gui() { Gui() {
container_lock.lock(); container_lock.lock();
renderable_container.push_back(this); renderable_container.push_back(this);
container_lock.unlock(); container_lock.unlock();
}; };
virtual ~Gui() { virtual ~Gui() {
container_lock.lock(); container_lock.lock();
renderable_container.remove(this); renderable_container.remove(this);
container_lock.unlock(); container_lock.unlock();
}; };
virtual void render_gui() = 0; virtual void render_gui() = 0;
virtual void update_gui() = 0; virtual void update_gui() = 0;
// Instead of rendering nil, we can pass our render call if we would like // Instead of rendering nil, we can pass our render call if we would like
bool renderable() { return rendering; }; bool renderable() { return rendering; };
private: private:
// Whatever class that wants to call this must be a friend!!! // Whatever class that wants to call this must be a friend!!!
friend class Application; friend class Application;
static void do_render() { static void do_render() {
for (auto i : renderable_container) { for (auto i : renderable_container) {
i->update_gui(); i->update_gui();
if (i->renderable()) if (i->renderable())
i->render_gui(); i->render_gui();
} }
}; };
static std::mutex container_lock; static std::mutex container_lock;
static std::list<Gui*> renderable_container; static std::list<Gui*> renderable_container;
protected: protected:
bool rendering = true; bool rendering = false;
// Derived class will handle imgui calls // Derived class will handle imgui calls
}; };

@ -21,7 +21,9 @@ public:
void consume_vr_events(); void consume_vr_events();
void handle_held_keys(); void handle_held_keys();
void dispatch_events();
virtual void render_gui() override; virtual void render_gui() override;
virtual void update_gui() override; virtual void update_gui() override;
@ -40,10 +42,6 @@ private:
static const std::vector<std::string> key_strings; static const std::vector<std::string> key_strings;
std::list<std::unique_ptr<vr::Event>> event_queue; std::list<std::unique_ptr<vr::Event>> event_queue;
protected:
virtual void generate_events() override;
}; };
class WindowHandler : public VrEventSubscriber { class WindowHandler : public VrEventSubscriber {
@ -55,13 +53,13 @@ public:
if (event.get()->type == vr::Event::Closed) { if (event.get()->type == vr::Event::Closed) {
window_ref->close(); window_ref->close();
} else if (event.get()->type == vr::Event::KeyPressed) { } else if (event.get()->type == vr::Event::KeyPressed) {
vr::KeyPressed *key_event = static_cast<vr::KeyPressed*>(event.get()); vr::KeyPressed *key_event = static_cast<vr::KeyPressed*>(event.get());
if (key_event->code == sf::Keyboard::Escape) { if (key_event->code == sf::Keyboard::Escape) {
window_ref->close(); window_ref->close();
} }
} }
}; };

@ -23,9 +23,13 @@ public:
void stop_recieving_from_clients(); void stop_recieving_from_clients();
void generate_events(); void generate_events();
void dispatch_events();
private: private:
std::list<std::unique_ptr<vr::Event>> event_queue;
std::vector<sf::TcpSocket*> client_sockets; std::vector<sf::TcpSocket*> client_sockets;
sf::SocketSelector socket_selector; sf::SocketSelector socket_selector;

@ -3,7 +3,6 @@
#include <iostream> #include <iostream>
#include "Event.hpp" #include "Event.hpp"
#include <memory> #include <memory>
#include <list>
class VrEventPublisher; class VrEventPublisher;
@ -23,19 +22,12 @@ class VrEventPublisher {
public: public:
virtual ~VrEventPublisher() {}; virtual ~VrEventPublisher() {};
virtual void subscribe(VrEventSubscriber *subscriber, vr::Event::EventType type) final; virtual void subscribe(VrEventSubscriber *subscriber, vr::Event::EventType type);
virtual void subscribe(VrEventSubscriber *subscriber, std::vector<vr::Event::EventType> type) final; virtual void subscribe(VrEventSubscriber *subscriber, std::vector<vr::Event::EventType> type);
virtual void unsubscribe(VrEventSubscriber *s, vr::Event::EventType c) final; virtual void unsubscribe(VrEventSubscriber *s, vr::Event::EventType c);
virtual void notify_subscribers(std::unique_ptr<vr::Event> event);
private: private:
std::map<vr::Event::EventType, std::vector<VrEventSubscriber*>> subscribers; std::map<vr::Event::EventType, std::vector<VrEventSubscriber*>> subscribers;
protected:
virtual void notify_subscribers(std::unique_ptr<vr::Event> event) final;
virtual void dispatch_events() final;
virtual void generate_events() = 0;
std::list<std::unique_ptr<vr::Event>> event_queue;
}; };

@ -375,7 +375,7 @@ __kernel void raycaster(
bool shadow_ray = false; bool shadow_ray = false;
// Andrew Woo's raycasting algo // Andrew Woo's raycasting algo
while (distance_traveled < max_distance && bounce_count < 4) { while (distance_traveled < max_distance && bounce_count < 2) {
// Fancy no branch version of the logic step // Fancy no branch version of the logic step
face_mask = intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy); face_mask = intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy);
@ -387,7 +387,6 @@ __kernel void raycaster(
voxel_data = 5; voxel_data = 5;
voxel.xyz -= voxel_step.xyz * face_mask.xyz; voxel.xyz -= voxel_step.xyz * face_mask.xyz;
first_strike = mix(fog_color, voxel_color, 1.0 - max(distance_traveled / 700.0f, (float)0)); first_strike = mix(fog_color, voxel_color, 1.0 - max(distance_traveled / 700.0f, (float)0));
break;
} }
@ -538,10 +537,10 @@ __kernel void raycaster(
texture_atlas, texture_atlas,
convert_int2(tile_face_position * convert_float2(*atlas_dim / *tile_dim)) + convert_int2(tile_face_position * convert_float2(*atlas_dim / *tile_dim)) +
convert_int2((float2)(3, 4) * convert_float2(*atlas_dim / *tile_dim)) convert_int2((float2)(3, 4) * convert_float2(*atlas_dim / *tile_dim))
).xyz/4; ).xyz/2;
voxel_color -= 0.3f; voxel_color.w += 0.3f;
max_distance = 700; max_distance = 500;
distance_traveled = 0; distance_traveled = 0;
float3 hit_pos = convert_float3(voxel) + face_position; float3 hit_pos = convert_float3(voxel) + face_position;

@ -110,43 +110,17 @@ bool Application::game_loop() {
// Time keeping // Time keeping
elapsed_time = elap_time(); elapsed_time = elap_time();
// time between this and the last frame
delta_time = elapsed_time - current_time; delta_time = elapsed_time - current_time;
// Setup the time for the next tick
current_time = elapsed_time; current_time = elapsed_time;
// If the delta exceeded 0.2f, then limit the max lag we'll allow
// 1 / float is how you get the fps. 0.2f == 5fps
if (delta_time > 0.2f) if (delta_time > 0.2f)
delta_time = 0.2f; delta_time = 0.2f;
// Add the the physics accumulator our delta
accumulator_time += delta_time; accumulator_time += delta_time;
// We want to keep our physics at a constant step size but we have a variable frame rate.
// 0.016 == physics preferred timestep
// 0.030 == average 30 fps frame rate
// we must run the physics step ~twice every render frame to keep consistency
int count = 0;
while ((accumulator_time - step_size) >= step_size) { while ((accumulator_time - step_size) >= step_size) {
count++;
accumulator_time -= step_size; accumulator_time -= step_size;
// do physics at step size rate
for (int i = 0; i < 1000; i++) {
int x = 9;
int r = i + x * 4;
current_time = elapsed_time;
}
// ==== DELTA TIME LOCKED ==== // ==== DELTA TIME LOCKED ====
} }
std::cout << count << "\n";
// ==== FPS LOCKED ==== // ==== FPS LOCKED ====
window->clear(sf::Color::Black); window->clear(sf::Color::Black);
@ -172,6 +146,94 @@ bool Application::game_loop() {
fps.draw(); fps.draw();
Gui::do_render(); Gui::do_render();
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar;
bool window_show = true;
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Menu"))
{
ImGui::Button("asdoifjasodif");
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
ImGui::Begin("Window");
ImGui::InputText("filename", screenshot_buf, 128);
if (ImGui::Button("Take Screen shot")) {
std::string path = "../assets/";
std::string filename(screenshot_buf);
filename += ".png";
sf::Texture window_texture;
window_texture.create(window->getSize().x, window->getSize().y);
window_texture.update(*window);
sf::Image image = window_texture.copyToImage();
image.saveToFile(path + filename);
}
ImGui::NextColumn();
if (ImGui::Button("Pause")) {
paused = !paused;
if (paused)
Logger::log("Pausing", Logger::LogLevel::INFO);
else
Logger::log("Unpausing", Logger::LogLevel::INFO);
}
ImGui::End();
ImGui::Begin("Controller debugger");
ImDrawList* draw_list = ImGui::GetWindowDrawList();
static ImVec4 col = ImVec4(1.0f, 0.0f, 1.0f, 1.0f);
const ImVec2 p = ImGui::GetCursorScreenPos();
const ImU32 col32 = ImColor(col);
std::vector<float> axis_values = {
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::X) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Y) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::U) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::R) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Z) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::V) / 2
};
ImGui::Columns(3, "Axis's"); // 4-ways, with border
ImGui::Separator();
ImGui::Text("X Y"); ImGui::NextColumn();
ImGui::Text("U R"); ImGui::NextColumn();
ImGui::Text("Z V"); ImGui::NextColumn();
ImGui::Separator();
for (int i = 0; i < 3; i++) {
float offset = ImGui::GetColumnWidth(i);
draw_list->AddLine(ImVec2(p.x + 0 + offset * i, p.y + 50), ImVec2(p.x + 100 + offset * i, p.y + 50), col32, 1.0);
draw_list->AddLine(ImVec2(p.x + 50 + offset * i, p.y + 0), ImVec2(p.x + 50 + offset * i, p.y + 100), col32, 1.0);
draw_list->AddCircleFilled(ImVec2(p.x + axis_values[2 * i] + 50 + offset * i, p.y + axis_values[2 * i + 1] + 50), 6, col32, 32);
ImGui::Dummy(ImVec2(100, 100));
ImGui::NextColumn();
}
ImGui::End();
//ImGui::ShowTestWindow();
ImGui::Render(); ImGui::Render();
// ImGUI messes up somthing in the SFML GL state, so we need a single draw call to right things // ImGUI messes up somthing in the SFML GL state, so we need a single draw call to right things
@ -195,40 +257,3 @@ float Application::elap_time() {
return static_cast<float>(elapsed_time.count()); return static_cast<float>(elapsed_time.count());
} }
void Application::render_gui() {
ImGui::Begin("Window");
ImGui::InputText("filename", screenshot_buf, 128);
if (ImGui::Button("Take Screen shot")) {
std::string path = "../assets/";
std::string filename(screenshot_buf);
filename += ".png";
sf::Texture window_texture;
window_texture.create(window->getSize().x, window->getSize().y);
window_texture.update(*window);
sf::Image image = window_texture.copyToImage();
image.saveToFile(path + filename);
}
ImGui::NextColumn();
if (ImGui::Button("Pause")) {
paused = !paused;
if (paused)
Logger::log("Pausing", Logger::LogLevel::INFO);
else
Logger::log("Unpausing", Logger::LogLevel::INFO);
}
ImGui::End();
}
void Application::update_gui() {
}

@ -97,7 +97,7 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
default_impulse = 1.0f; default_impulse = 1.0f;
} }
else if (held_event->code == sf::Keyboard::C) { else if (held_event->code == sf::Keyboard::C) {
look_at(sf::Vector3f(128, 128, 10)); look_at_center();
} }
else if (held_event->code == sf::Keyboard::Q) { else if (held_event->code == sf::Keyboard::Q) {
add_relative_impulse(Camera::DIRECTION::DOWN, default_impulse); add_relative_impulse(Camera::DIRECTION::DOWN, default_impulse);
@ -230,10 +230,9 @@ void Camera::update_gui() {
rendering = true; rendering = true;
} }
void Camera::look_at(sf::Vector3f position) void Camera::look_at_center() {
{
direction = CartToNormalizedSphere(position - this->position); direction = CartToNormalizedSphere(sf::Vector3f(60, 60, 35) - position);
} }
sf::Vector2f* Camera::get_direction_pointer() { sf::Vector2f* Camera::get_direction_pointer() {

@ -1,48 +0,0 @@
#include "FrameWatcher.h"
#include <chrono>
FrameWatcher::FrameWatcher() {
}
FrameWatcher::~FrameWatcher()
{
}
void FrameWatcher::do_tick() {
elapsed_time = get_elapsed_time();
delta_time = elapsed_time - current_time;
current_time = elapsed_time;
if (delta_time > 0.2f)
delta_time = 0.2f;
accumulator_time += delta_time;
while ((accumulator_time - step_size) >= step_size) {
accumulator_time -= step_size;
// ==== DELTA TIME LOCKED ====
}
}
float FrameWatcher::get_elapsed_time() {
static std::chrono::time_point<std::chrono::system_clock> start;
static bool started = false;
if (!started) {
start = std::chrono::system_clock::now();
started = true;
}
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_time = now - start;
return static_cast<float>(elapsed_time.count());
}

@ -1,4 +1,4 @@
#include "Gui.h" #include "Gui.h"
std::mutex Gui::container_lock; std::mutex Gui::container_lock;
std::list<Gui*> Gui::renderable_container; std::list<Gui*> Gui::renderable_container;

@ -112,6 +112,16 @@ void Input::handle_held_keys() {
} }
void Input::dispatch_events() {
while (event_queue.size() != 0) {
notify_subscribers(std::move(event_queue.front()));
event_queue.pop_front();
}
}
void Input::render_gui() { void Input::render_gui() {
ImGui::Begin("Input Debugger"); ImGui::Begin("Input Debugger");
@ -282,111 +292,108 @@ void Input::transpose_sf_events(std::list<sf::Event> sf_event_queue) {
} }
} }
const std::vector<std::string> Input::key_strings = { const std::vector<std::string> Input::key_strings = {
"A", "A",
"B", "B",
"C", "C",
"D", "D",
"E", "E",
"F", "F",
"G", "G",
"H", "H",
"I", "I",
"J", "J",
"K", "K",
"L", "L",
"M", "M",
"N", "N",
"O", "O",
"P", "P",
"Q", "Q",
"R", "R",
"S", "S",
"T", "T",
"U", "U",
"V", "V",
"W", "W",
"X", "X",
"Y", "Y",
"Z", "Z",
"Num0", "Num0",
"Num1", "Num1",
"Num2", "Num2",
"Num3", "Num3",
"Num4", "Num4",
"Num5", "Num5",
"Num6", "Num6",
"Num7", "Num7",
"Num8", "Num8",
"Num9", "Num9",
"Escape", "Escape",
"LControl", "LControl",
"LShift", "LShift",
"LAlt", "LAlt",
"LSystem", "LSystem",
"RControl", "RControl",
"RShift", "RShift",
"RAlt", "RAlt",
"RSystem", "RSystem",
"Menu", "Menu",
"LBracket", "LBracket",
"RBracket", "RBracket",
"SemiColon", "SemiColon",
"Comma", "Comma",
"Period", "Period",
"Quote", "Quote",
"Slash", "Slash",
"BackSlash", "BackSlash",
"Tilde", "Tilde",
"Equal", "Equal",
"Dash", "Dash",
"Space", "Space",
"Return", "Return",
"BackSpace", "BackSpace",
"Tab", "Tab",
"PageUp", "PageUp",
"PageDown", "PageDown",
"End", "End",
"Home", "Home",
"Insert", "Insert",
"Delete", "Delete",
"Add", "Add",
"Subtract", "Subtract",
"Multiply", "Multiply",
"Divide", "Divide",
"Left", "Left",
"Right", "Right",
"Up", "Up",
"Down", "Down",
"Numpad0", "Numpad0",
"Numpad1", "Numpad1",
"Numpad2", "Numpad2",
"Numpad3", "Numpad3",
"Numpad4", "Numpad4",
"Numpad5", "Numpad5",
"Numpad6", "Numpad6",
"Numpad7", "Numpad7",
"Numpad8", "Numpad8",
"Numpad9", "Numpad9",
"F1" , "F1" ,
"F2" , "F2" ,
"F3" , "F3" ,
"F4" , "F4" ,
"F5" , "F5" ,
"F6" , "F6" ,
"F7" , "F7" ,
"F8" , "F8" ,
"F9" , "F9" ,
"F10", "F10",
"F11", "F11",
"F12", "F12",
"F13", "F13",
"F14", "F14",
"F15", "F15",
"Pause" "Pause"
}; };
void Input::generate_events() {
}

@ -26,6 +26,14 @@ void NetworkInput::recieve_from_clients()
} }
void NetworkInput::dispatch_events()
{
while (event_queue.size() != 0) {
notify_subscribers(std::move(event_queue.front()));
event_queue.pop_front();
}
}
void NetworkInput::threaded_client_listener(int port) { void NetworkInput::threaded_client_listener(int port) {
listener.listen(port); listener.listen(port);

@ -42,10 +42,3 @@ void VrEventPublisher::notify_subscribers(std::unique_ptr<vr::Event> event) {
} }
} }
void VrEventPublisher::dispatch_events() {
while (event_queue.size() != 0) {
notify_subscribers(std::move(event_queue.front()));
event_queue.pop_front();
}
}

@ -215,7 +215,7 @@ void Old_Map::generate_terrain() {
for (int x = dimensions.x / 2; x < dimensions.x / 2 + dimensions.x / 64; x++) { for (int x = dimensions.x / 2; x < dimensions.x / 2 + dimensions.x / 64; x++) {
for (int y = dimensions.x / 2; y < dimensions.y / 2 + dimensions.x / 64; y++) { for (int y = dimensions.x / 2; y < dimensions.y / 2 + dimensions.x / 64; y++) {
for (int z = 5; z < 15; z++) { for (int z = 0; z < 5; z++) {
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6; voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
} }
@ -249,63 +249,63 @@ void Old_Map::generate_terrain() {
// Hand code in some constructions // Hand code in some constructions
//std::vector<std::vector<int>> maze = std::vector<std::vector<int>> maze =
// generate_maze(sf::Vector2i(8, 8), sf::Vector2i(0, 0)); generate_maze(sf::Vector2i(8, 8), sf::Vector2i(0, 0));
for (int x = 0; x < maze.size(); x++) {
for (int y = 0; y < maze.at(0).size(); y++) {
switch(maze.at(x).at(y)) {
case 1: { // North
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 5;
//voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
break;
}
case 2: { // South
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 5;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
break;
}
case 3: { // East
voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
break;
}
case 4: { // West
voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
//voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
break;
}
}
}
}
//for (int x = 0; x < maze.size(); x++) {
// for (int y = 0; y < maze.at(0).size(); y++) { //for (int x = 0; x < dimensions.x; x++) {
// // for (int y = 0; y < dimensions.y; y++) {
// switch(maze.at(x).at(y)) { // voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
//
// case 1: { // North
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 5;
// //voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
// break;
// }
// case 2: { // South
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 5;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
// break;
// }
// case 3: { // East
// voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
// break;
// }
// case 4: { // West
// voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
// //voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
// break;
// }
//
// }
//
//
// } // }
//} //}
set_voxel(sf::Vector3i(45, 70, 6), 6);
////for (int x = 0; x < dimensions.x; x++) { set_voxel(sf::Vector3i(47, 70, 6), 6);
//// for (int y = 0; y < dimensions.y; y++) { set_voxel(sf::Vector3i(100, 100, 50), 1);
//// voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
//// }
////}
//set_voxel(sf::Vector3i(45, 70, 6), 6);
//set_voxel(sf::Vector3i(47, 70, 6), 6);
//set_voxel(sf::Vector3i(100, 100, 50), 1);
} }

Loading…
Cancel
Save