'Demo Mode' release
This commit is contained in:
@@ -87,7 +87,7 @@ struct device_info {
|
||||
|
||||
struct PackedData;
|
||||
|
||||
class CLCaster : private Gui {
|
||||
class CLCaster : private Gui, public VrEventSubscriber {
|
||||
|
||||
public:
|
||||
|
||||
@@ -156,6 +156,9 @@ public:
|
||||
// ============= GUI ==============
|
||||
virtual void render_gui() override;
|
||||
virtual void update_gui() override;
|
||||
|
||||
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
// ================================
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
|
||||
// Functions modifying the pointed to data
|
||||
void set_position(sf::Vector3f position);
|
||||
sf::Vector3f get_position();
|
||||
void set_direction(sf::Vector3f direction);
|
||||
void set_rgbi(sf::Vector4f rgbi);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ float4 view_light(float4 in_color, float3 light, float4 light_color, float3 view
|
||||
if (all(light == zeroed_float3))
|
||||
return zeroed_float4;
|
||||
|
||||
float d = Distance(light) / 100.0f;
|
||||
float d = Distance(light) / 140.0f;
|
||||
d *= d;
|
||||
|
||||
float diffuse = max(dot(normalize(convert_float3(mask)), normalize(light)), 0.0f);
|
||||
@@ -146,7 +146,6 @@ bool get_oct_vox(
|
||||
// Adding 1 for X, 2 for Y, and 4 for Z
|
||||
int mask_index = 0;
|
||||
|
||||
|
||||
// Do the logic steps to find which sub oct we step down into
|
||||
if (position.x >= (dimension / 2) + quad_position.x) {
|
||||
|
||||
@@ -163,23 +162,15 @@ bool get_oct_vox(
|
||||
if (position.y >= (dimension / 2) + quad_position.y) {
|
||||
|
||||
quad_position.y |= (dimension / 2);
|
||||
|
||||
mask_index += 2;
|
||||
|
||||
// TODO What is up with the binary operator on this one?
|
||||
// Alright, I switched it over and seems not to have done anything?
|
||||
// idx_stack[scale] ^= idx_set_y_mask;
|
||||
idx_stack[scale] |= idx_set_y_mask;
|
||||
|
||||
}
|
||||
if (position.z >= (dimension / 2) + quad_position.z) {
|
||||
|
||||
quad_position.z += (dimension / 2);
|
||||
|
||||
mask_index += 4;
|
||||
|
||||
idx_stack[scale] |= idx_set_z_mask;
|
||||
|
||||
}
|
||||
|
||||
// Check to see if we are on a valid oct
|
||||
@@ -320,6 +311,7 @@ __kernel void raycaster(
|
||||
if (any(voxel >= *map_dim) || any(voxel < 0)){
|
||||
voxel.xyz -= voxel_step.xyz * face_mask.xyz;
|
||||
color_accumulator = mix(fog_color, voxel_color, 1.0f - max(distance_traveled / 700.0f, 0.0f));
|
||||
color_accumulator.w *= 4;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -440,10 +432,7 @@ __kernel void raycaster(
|
||||
return;
|
||||
|
||||
voxel -= voxel_step * face_mask;
|
||||
voxel_step = ( 1, 1, 1 );
|
||||
voxel_step *= (ray_dir > 0) - (ray_dir < 0);
|
||||
|
||||
//voxel = convert_int3(hit_pos);
|
||||
voxel_step = ( 1, 1, 1 ) * ((ray_dir > 0) - (ray_dir < 0));
|
||||
|
||||
delta_t = fabs(1.0f / ray_dir);
|
||||
intersection_t = delta_t * ((hit_pos)-floor(hit_pos)) * convert_float3(voxel_step);
|
||||
@@ -456,9 +445,9 @@ __kernel void raycaster(
|
||||
texture_atlas,
|
||||
convert_int2(tile_face_position * convert_float2(*atlas_dim / *tile_dim)) +
|
||||
convert_int2((float2)(3, 4) * convert_float2(*atlas_dim / *tile_dim))
|
||||
).xyz/2;
|
||||
).xyz/4;
|
||||
|
||||
voxel_color.w -= 0.3f;
|
||||
voxel_color.w -= 0.0f;
|
||||
max_distance = 700;
|
||||
distance_traveled = 0;
|
||||
|
||||
@@ -481,7 +470,7 @@ __kernel void raycaster(
|
||||
|
||||
// SHADOW RAY HIT
|
||||
} else {
|
||||
color_accumulator /= 5;
|
||||
color_accumulator = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ bool Application::init_clcaster() {
|
||||
|
||||
// Create a light prototype, send it to the controller, and get the handle back
|
||||
LightPrototype prototype(
|
||||
sf::Vector3f(100.0f, 100.0f, 75.0f),
|
||||
sf::Vector3f(100.0f, 156.0f, 58.0f),
|
||||
sf::Vector3f(-1.0f, -1.0f, -1.5f),
|
||||
sf::Vector4f(0.4f, 0.4f, 0.4f, 1.0f)
|
||||
sf::Vector4f(0.1f, 0.1f, 0.1f, 0.8f)
|
||||
);
|
||||
light_handle = light_controller->create_light(prototype);
|
||||
|
||||
@@ -93,6 +93,7 @@ bool Application::init_events() {
|
||||
window_handler->subscribe_to_publisher(&input_handler, vr::Event::EventType::Closed);
|
||||
window_handler->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
|
||||
|
||||
raycaster->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
|
||||
//camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::JoystickMoved);
|
||||
|
||||
return true;
|
||||
@@ -116,6 +117,14 @@ bool Application::game_loop() {
|
||||
accumulator_time += delta_time;
|
||||
while ((accumulator_time - step_size) >= step_size) {
|
||||
accumulator_time -= step_size;
|
||||
|
||||
sf::Vector3f light_pos = light_handle->get_position();
|
||||
light_pos.x = sin(elapsed_time / 2) * 100 + 100;
|
||||
light_handle->set_position(light_pos);
|
||||
|
||||
sf::Vector3f cam_pos = camera->get_position();
|
||||
cam_pos.x = sin(elapsed_time / 2 + 3.141f) * 50 + 125;
|
||||
camera->set_position(cam_pos);
|
||||
|
||||
// ==== DELTA TIME LOCKED ====
|
||||
}
|
||||
|
||||
@@ -354,6 +354,19 @@ void CLCaster::update_gui() {
|
||||
rendering = true;
|
||||
}
|
||||
|
||||
|
||||
void CLCaster::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) {
|
||||
|
||||
if (event->type == vr::Event::KeyPressed) {
|
||||
|
||||
vr::KeyPressed *key_event = static_cast<vr::KeyPressed*>(event.get());
|
||||
|
||||
if (key_event->code == sf::Keyboard::T) {
|
||||
debug_quick_recompile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CLCaster::aquire_hardware() {
|
||||
|
||||
Logger::log("Acquiring OpenCL Hardware", Logger::LogLevel::INFO);
|
||||
|
||||
@@ -117,9 +117,6 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
|
||||
else if (held_event->code == sf::Keyboard::D) {
|
||||
add_relative_impulse(Camera::DIRECTION::RIGHT, default_impulse);
|
||||
}
|
||||
else if (held_event->code == sf::Keyboard::T) {
|
||||
set_position(sf::Vector3f(50, 50, 50));
|
||||
}
|
||||
}
|
||||
|
||||
else if (event->type == vr::Event::KeyPressed) {
|
||||
@@ -232,7 +229,7 @@ void Camera::update_gui() {
|
||||
|
||||
void Camera::look_at_center() {
|
||||
|
||||
direction = CartToNormalizedSphere(sf::Vector3f(60, 60, 35) - position);
|
||||
direction = CartToNormalizedSphere(sf::Vector3f(143, 158, 33) - position);
|
||||
}
|
||||
|
||||
sf::Vector2f* Camera::get_direction_pointer() {
|
||||
|
||||
@@ -53,6 +53,11 @@ void LightHandle::set_position(sf::Vector3f position)
|
||||
data_reference->position = position;
|
||||
}
|
||||
|
||||
|
||||
sf::Vector3f LightHandle::get_position() {
|
||||
return data_reference->position;
|
||||
}
|
||||
|
||||
void LightHandle::set_direction(sf::Vector3f direction)
|
||||
{
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ std::vector<std::vector<int>> generate_maze(sf::Vector2i dimensions, sf::Vector2
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Old_Map::generate_terrain() {
|
||||
std::mt19937 gen;
|
||||
std::uniform_real_distribution<double> dis(-1.0, 1.0);
|
||||
@@ -101,7 +99,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() % 10 + 30;
|
||||
double SEED = rand() % 10 + 55;
|
||||
|
||||
//seed the data
|
||||
set_sample(0, 0, SEED);
|
||||
@@ -215,15 +213,25 @@ void Old_Map::generate_terrain() {
|
||||
|
||||
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 z = 0; z < 5; z++) {
|
||||
for (int z = 2; z < 7; z++) {
|
||||
|
||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 60; x < 65; x++) {
|
||||
for (int y = 60; y < 65; y++) {
|
||||
for (int x = dimensions.x / 2 - 3; x < dimensions.x / 2 + dimensions.x / 64 + 3; x++) {
|
||||
for (int y = dimensions.x / 2 - 3; y < dimensions.y / 2 + dimensions.x / 64 + 3; y++) {
|
||||
for (int z = 0; z < 1; z++) {
|
||||
|
||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int x = 140; x < 145; x++) {
|
||||
for (int y = 155; y < 160; y++) {
|
||||
for (int z = 30; z < 35; z++) {
|
||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user