Various tweaks and modifications
Some preliminary testing of map
This commit is contained in:
@@ -22,6 +22,10 @@ message(STATUS "OpenCL found: ${OPENCL_FOUND}")
|
|||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
message(STATUS "GLEW found: ${GLEW_FOUND}")
|
message(STATUS "GLEW found: ${GLEW_FOUND}")
|
||||||
|
|
||||||
|
# Find Vulkan
|
||||||
|
#find_package(VULKAN REQUIRED)
|
||||||
|
#message(STATUS "VULKAN found: ${VULKAN_FOUND}")
|
||||||
|
|
||||||
# Find OpenGL
|
# Find OpenGL
|
||||||
find_package( OpenGL REQUIRED)
|
find_package( OpenGL REQUIRED)
|
||||||
message(STATUS "OpenGL found: ${OPENGL_FOUND}")
|
message(STATUS "OpenGL found: ${OPENGL_FOUND}")
|
||||||
@@ -30,6 +34,7 @@ message(STATUS "OpenGL found: ${OPENGL_FOUND}")
|
|||||||
include_directories(${SFML_INCLUDE_DIR})
|
include_directories(${SFML_INCLUDE_DIR})
|
||||||
include_directories(${OpenCL_INCLUDE_DIRS})
|
include_directories(${OpenCL_INCLUDE_DIRS})
|
||||||
include_directories(${OpenGL_INCLUDE_DIRS})
|
include_directories(${OpenGL_INCLUDE_DIRS})
|
||||||
|
#include_directories(${Vulkan_INCLUDE_DIRS})
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
# Glob all thr sources into their values
|
# Glob all thr sources into their values
|
||||||
@@ -53,6 +58,7 @@ target_link_libraries (${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
|
|||||||
target_link_libraries (${PNAME} ${OpenCL_LIBRARY})
|
target_link_libraries (${PNAME} ${OpenCL_LIBRARY})
|
||||||
target_link_libraries (${PNAME} ${OPENGL_LIBRARIES})
|
target_link_libraries (${PNAME} ${OPENGL_LIBRARIES})
|
||||||
target_link_libraries (${PNAME} ${GLEW_LIBRARIES})
|
target_link_libraries (${PNAME} ${GLEW_LIBRARIES})
|
||||||
|
#target_link_libraries (${PNAME} ${Vulkan_LIBRARIES})
|
||||||
|
|
||||||
# Setup to use C++11
|
# Setup to use C++11
|
||||||
set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11
|
set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define CHUNK_DIM 32
|
#define CHUNK_DIM 32
|
||||||
|
#define OCT_DIM 64
|
||||||
|
|
||||||
struct KeyHasher {
|
struct KeyHasher {
|
||||||
std::size_t operator()(const sf::Vector3i& k) const {
|
std::size_t operator()(const sf::Vector3i& k) const {
|
||||||
@@ -57,6 +58,15 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
int64_t generate_children(sf::Vector3i pos, int dim);
|
||||||
|
|
||||||
|
|
||||||
|
int64_t block[1024];
|
||||||
|
int stack_position = 0;
|
||||||
|
char getVoxel(sf::Vector3i pos);
|
||||||
|
char* voxel_data = new char[OCT_DIM * OCT_DIM * OCT_DIM];
|
||||||
|
|
||||||
|
|
||||||
std::unordered_map<sf::Vector3i, Chunk, KeyHasher> chunk_map;
|
std::unordered_map<sf::Vector3i, Chunk, KeyHasher> chunk_map;
|
||||||
|
|
||||||
double* height_map;
|
double* height_map;
|
||||||
|
|||||||
@@ -75,6 +75,17 @@ float4 cast_light_rays(
|
|||||||
// if it does
|
// if it does
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rand(int* seed) // 1 <= *seed < m
|
||||||
|
{
|
||||||
|
int const a = 16807; //ie 7**5
|
||||||
|
int const m = 2147483647; //ie 2**31-1
|
||||||
|
|
||||||
|
*seed = ((*seed) * a) % m;
|
||||||
|
return(*seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__kernel void raycaster(
|
__kernel void raycaster(
|
||||||
global char* map,
|
global char* map,
|
||||||
global int3* map_dim,
|
global int3* map_dim,
|
||||||
@@ -85,9 +96,17 @@ __kernel void raycaster(
|
|||||||
global float* lights,
|
global float* lights,
|
||||||
global int* light_count,
|
global int* light_count,
|
||||||
__write_only image2d_t image,
|
__write_only image2d_t image,
|
||||||
global int* seed
|
global int* seed_memory
|
||||||
){
|
){
|
||||||
|
|
||||||
|
|
||||||
|
int global_id = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||||
|
int seed = seed_memory[global_id];
|
||||||
|
int random_number = rand(&seed);
|
||||||
|
seed_memory[global_id] = seed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t id = get_global_id(0);
|
size_t id = get_global_id(0);
|
||||||
int2 pixel = {id % (*resolution).x, id / (*resolution).x};
|
int2 pixel = {id % (*resolution).x, id / (*resolution).x};
|
||||||
float3 ray_dir = projection_matrix[pixel.x + (*resolution).x * pixel.y];
|
float3 ray_dir = projection_matrix[pixel.x + (*resolution).x * pixel.y];
|
||||||
@@ -139,19 +158,18 @@ __kernel void raycaster(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use a ghetto ass rng to give rays a "fog" appearance
|
// use a ghetto ass rng to give rays a "fog" appearance
|
||||||
int2 randoms = { seed, ray_dir.y };
|
int2 randoms = { random_number, 14 };
|
||||||
uint tseed = randoms.x + id;
|
uint tseed = randoms.x + id;
|
||||||
uint t = tseed ^ (tseed << 11);
|
uint t = tseed ^ (tseed << 11);
|
||||||
uint result = randoms.y ^ (randoms.y >> 19) ^ (t ^ (t >> 8));
|
uint result = randoms.y ^ (randoms.y >> 19) ^ (t ^ (t >> 8));
|
||||||
*seed = result % 50;
|
|
||||||
|
|
||||||
int max_dist = 800 + result % 100;
|
int max_dist = 800 + result % 100;
|
||||||
int dist = 0;
|
int dist = 0;
|
||||||
|
|
||||||
int3 mask = { 0, 0, 0 };
|
int3 mask = { 0, 0, 0 };
|
||||||
float4 color = { 0.73, 0.81, 0.89, 0.6 };
|
float4 color = { 0.73, 0.81, 0.89, 0.6 };
|
||||||
float4 c = (float4)(0.40, 0.00, 0.40, 0.2);
|
float4 c = (float4)(0.60, 0.00, 0.40, 0.1);
|
||||||
c.x += ray_dir.y;// (result % 100) / 100;
|
c.x += (result % 100) / 10;
|
||||||
|
|
||||||
// Andrew Woo's raycasting algo
|
// Andrew Woo's raycasting algo
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ OpenCL:
|
|||||||
- Separate out into a part of the rendering module
|
- Separate out into a part of the rendering module
|
||||||
|
|
||||||
Map:
|
Map:
|
||||||
- Reimplement the old map, put it into an old_map structure
|
|
||||||
- Implement the new octree structure
|
- Implement the new octree structure
|
||||||
- storing the pre-octree volumetric data
|
- storing the pre-octree volumetric data
|
||||||
- determining when to load volumetric data into the in-memory structure
|
- determining when to load volumetric data into the in-memory structure
|
||||||
@@ -28,5 +27,15 @@ Renderer:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Build:
|
||||||
|
Z:\Cpp_Libs\SFML-Visual_Studio2015RCx64
|
||||||
|
Z:/Cpp_Libs/glew-2.0.0/lib/Release/x64/glew32s.lib
|
||||||
|
Z:/Cpp_Libs/glew-2.0.0/include
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ int Camera::update(double delta_time) {
|
|||||||
// have to do it component wise
|
// have to do it component wise
|
||||||
double multiplier = 40;
|
double multiplier = 40;
|
||||||
|
|
||||||
position.x += movement.x * delta_time * multiplier;
|
position.x += static_cast<float>(movement.x * delta_time * multiplier);
|
||||||
position.y += movement.y * delta_time * multiplier;
|
position.y += static_cast<float>(movement.y * delta_time * multiplier);
|
||||||
position.z += movement.z * delta_time * multiplier;
|
position.z += static_cast<float>(movement.z * delta_time * multiplier);
|
||||||
|
|
||||||
movement *= (float)(friction_coefficient * delta_time * multiplier);
|
movement *= static_cast<float>(friction_coefficient * delta_time * multiplier);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ GL_Testing::GL_Testing() {
|
|||||||
|
|
||||||
GLfloat tmp[] = {
|
GLfloat tmp[] = {
|
||||||
|
|
||||||
1, 0, 0, 0,
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
0, cos(1), sin(1), 0,
|
0.0f, static_cast<float>(cos(1.0f)), static_cast<float>(sin(1.0f)), 0.0f,
|
||||||
0, -sin(1), cos(1), 0,
|
0.0f, static_cast<float>(-sin(1.0f)), static_cast<float>(cos(1.0f)), 0.0f,
|
||||||
0, 0, 0, 1
|
0.0f, 0.0f, 0.0f, 1.0f
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -132,10 +132,10 @@ void GL_Testing::rotate(double delta) {
|
|||||||
|
|
||||||
GLfloat tmp[] = {
|
GLfloat tmp[] = {
|
||||||
|
|
||||||
1, 0, 0, 0,
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
0, cos(counter), sin(counter), 0,
|
0.0f, static_cast<float>(cos(counter)), static_cast<float>(sin(counter)), 0.0f,
|
||||||
0, -sin(counter), cos(counter), 0,
|
0.0f, static_cast<float>(-sin(counter)), static_cast<float>(cos(counter)), 0.0f,
|
||||||
0, 0, 0, 1
|
0.0f, 0.0f, 0.0f, 1.0f
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ int Hardware_Caster::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
srand(NULL);
|
srand(NULL);
|
||||||
int seed = rand();
|
|
||||||
|
|
||||||
create_buffer("seed", sizeof(int), &seed);
|
int *seed_memory = new int[1920*1080];
|
||||||
|
|
||||||
|
create_buffer("seed", sizeof(int) * 1920 * 1080, seed_memory);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ void Hardware_Caster::validate()
|
|||||||
set_kernel_arg("raycaster", 8, "image");
|
set_kernel_arg("raycaster", 8, "image");
|
||||||
set_kernel_arg("raycaster", 9, "seed");
|
set_kernel_arg("raycaster", 9, "seed");
|
||||||
|
|
||||||
print_kernel_arguments();
|
//print_kernel_arguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ void Hardware_Caster::assign_lights(std::vector<Light> lights) {
|
|||||||
|
|
||||||
this->lights = std::vector<Light>(lights);
|
this->lights = std::vector<Light>(lights);
|
||||||
|
|
||||||
light_count = lights.size();
|
light_count = static_cast<int>(lights.size());
|
||||||
|
|
||||||
create_buffer("lights", sizeof(float) * 10 * light_count, this->lights.data(), CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR);
|
create_buffer("lights", sizeof(float) * 10 * light_count, this->lights.data(), CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR);
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ int Hardware_Caster::acquire_platform_and_device() {
|
|||||||
if (assert(error, "clGetDeviceIDs"))
|
if (assert(error, "clGetDeviceIDs"))
|
||||||
return OPENCL_ERROR;
|
return OPENCL_ERROR;
|
||||||
|
|
||||||
for (int q = 0; q < deviceIdCount; q++) {
|
for (unsigned int q = 0; q < deviceIdCount; q++) {
|
||||||
|
|
||||||
device d;
|
device d;
|
||||||
|
|
||||||
|
|||||||
214
src/Map.cpp
214
src/Map.cpp
@@ -1,8 +1,63 @@
|
|||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// root
|
||||||
|
//
|
||||||
|
// a1
|
||||||
|
// a2
|
||||||
|
//
|
||||||
|
// b1
|
||||||
|
// b1
|
||||||
|
//
|
||||||
|
// c1
|
||||||
|
// c1
|
||||||
|
//
|
||||||
|
// a2
|
||||||
|
// a2
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Map::Map(sf::Vector3i position) {
|
Map::Map(sf::Vector3i position) {
|
||||||
|
|
||||||
load_unload(position);
|
load_unload(position);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8192; i++) {
|
||||||
|
block[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitCount(unsigned int u) {
|
int BitCount(unsigned int u) {
|
||||||
@@ -12,6 +67,30 @@ int BitCount(unsigned int u) {
|
|||||||
return ((uCount + (uCount >> 3)) & 030707070707) % 63;
|
return ((uCount + (uCount >> 3)) & 030707070707) % 63;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetBit(int position, char* c) {
|
||||||
|
*c |= 1 << position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlipBit(int position, char* c) {
|
||||||
|
*c ^= 1 << position;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetBit(int position, char* c) {
|
||||||
|
return (*c >> position) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBit(int position, int64_t* c) {
|
||||||
|
*c |= 1 << position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlipBit(int position, int64_t* c) {
|
||||||
|
*c ^= 1 << position;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetBit(int position, int64_t* c) {
|
||||||
|
return (*c >> position) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
struct leaf {
|
struct leaf {
|
||||||
leaf *children;
|
leaf *children;
|
||||||
char leaf_mask;
|
char leaf_mask;
|
||||||
@@ -24,6 +103,103 @@ struct block {
|
|||||||
double* data = new double[1000];
|
double* data = new double[1000];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int64_t generate_children_at_raw() {
|
||||||
|
|
||||||
|
int64_t t;
|
||||||
|
|
||||||
|
// count the raw data and insert via bit masks or whatever into the valid field
|
||||||
|
|
||||||
|
// Set the child pointer blank and the leaf mask blank as well
|
||||||
|
|
||||||
|
// Return the single value
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Map::generate_children(sf::Vector3i pos, int dim) {
|
||||||
|
|
||||||
|
sf::Vector3i t1 = sf::Vector3i(pos.x, pos.y, pos.z);
|
||||||
|
sf::Vector3i t2 = sf::Vector3i(pos.x + dim, pos.y, pos.z);
|
||||||
|
sf::Vector3i t3 = sf::Vector3i(pos.x, pos.y + dim, pos.z);
|
||||||
|
sf::Vector3i t4 = sf::Vector3i(pos.x + dim, pos.y + dim, pos.z);
|
||||||
|
|
||||||
|
sf::Vector3i t5 = sf::Vector3i(pos.x, pos.y, pos.z + dim);
|
||||||
|
sf::Vector3i t6 = sf::Vector3i(pos.x + dim, pos.y, pos.z + dim);
|
||||||
|
sf::Vector3i t7 = sf::Vector3i(pos.x, pos.y + dim, pos.z + dim);
|
||||||
|
sf::Vector3i t8 = sf::Vector3i(pos.x + dim, pos.y + dim, pos.z + dim);
|
||||||
|
|
||||||
|
std::vector<int64_t> cps;
|
||||||
|
int64_t tmp = 0;
|
||||||
|
|
||||||
|
if (dim == 1) {
|
||||||
|
|
||||||
|
if (getVoxel(t1))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t2))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t3))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t4))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t5))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t6))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t7))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
if (getVoxel(t8))
|
||||||
|
SetBit(16, &tmp);
|
||||||
|
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Generate all 8 sub trees accounting for each of their unique positions
|
||||||
|
int curr_stack_pos = stack_position;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tmp = generate_children(t1, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t2, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t3, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t4, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t5, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t6, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t7, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
tmp = generate_children(t8, dim / 2);
|
||||||
|
if (tmp != 0)
|
||||||
|
cps.push_back(tmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
memcpy(&block[stack_position], cps.data(), cps.size() * sizeof(int64_t));
|
||||||
|
stack_position += cps.size();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Map::generate_octree() {
|
void Map::generate_octree() {
|
||||||
|
|
||||||
@@ -34,19 +210,40 @@ void Map::generate_octree() {
|
|||||||
|
|
||||||
int* dataset = new int[32 * 32 * 32];
|
int* dataset = new int[32 * 32 * 32];
|
||||||
for (int i = 0; i < 32 * 32 * 32; i++) {
|
for (int i = 0; i < 32 * 32 * 32; i++) {
|
||||||
dataset[0] = i;
|
dataset[0] = rand() % 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int level = static_cast<int>(log2(32));
|
|
||||||
|
|
||||||
|
// levels defines how many levels to traverse before we hit raw data
|
||||||
|
// Will be the map width I presume. Will still need to handle how to swap in and out data.
|
||||||
|
// Possible have some upper static nodes that will stay full regardless of contents?
|
||||||
|
int levels = static_cast<int>(log2(64));
|
||||||
|
|
||||||
|
|
||||||
leaf top_node;
|
leaf top_node;
|
||||||
top_node.level = level;
|
|
||||||
|
|
||||||
for (int i = 0; i < 16 * 16 * 16; i++) {
|
int t_level = -1;
|
||||||
for (int i = 0; i < 8 * 8 * 8; i++) {
|
int b_level = 0;
|
||||||
for (int i = 0; i < 4 * 4 * 4; i++) {
|
|
||||||
|
for (int i1 = 0; i1 < 2 * 2 * 2; i1++) {
|
||||||
|
int b_level = 1;
|
||||||
|
for (int i2 = 0; i2 < 2 * 2 * 2; i2++) {
|
||||||
|
int b_level = 2;
|
||||||
|
for (int i3 = 0; i3 < 2 * 2 * 2; i3++) {
|
||||||
|
int b_level = 3;
|
||||||
|
|
||||||
|
leaf l1;
|
||||||
|
l1.children = nullptr;
|
||||||
|
l1.leaf_mask = 0;
|
||||||
|
l1.valid_mask = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 2 * 2 * 2; i++) {
|
for (int i = 0; i < 2 * 2 * 2; i++) {
|
||||||
|
|
||||||
|
//int x =
|
||||||
|
|
||||||
|
|
||||||
|
//if (dataset[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,6 +324,11 @@ void Map::setVoxel(sf::Vector3i world_position, int val) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char Map::getVoxel(sf::Vector3i pos){
|
||||||
|
|
||||||
|
return voxel_data[pos.x + OCT_DIM * (pos.y + OCT_DIM * pos.z)];
|
||||||
|
}
|
||||||
|
|
||||||
void Chunk::set(int type) {
|
void Chunk::set(int type) {
|
||||||
for (int i = 0; i < CHUNK_DIM * CHUNK_DIM * CHUNK_DIM; i++) {
|
for (int i = 0; i < CHUNK_DIM * CHUNK_DIM * CHUNK_DIM; i++) {
|
||||||
voxel_data[i] = 0;
|
voxel_data[i] = 0;
|
||||||
|
|||||||
@@ -136,14 +136,14 @@ void Old_Map::generate_terrain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int x = 0; x < dimensions.x / 10; x++) {
|
//for (int x = 0; x < dimensions.x / 10; x++) {
|
||||||
for (int y = 0; y < dimensions.y / 10; y++) {
|
// for (int y = 0; y < dimensions.y / 10; y++) {
|
||||||
for (int z = 0; z < dimensions.z; z++) {
|
// for (int z = 0; z < dimensions.z; z++) {
|
||||||
if (rand() % 1000 < 1)
|
// if (rand() % 1000 < 1)
|
||||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = rand() % 6;
|
// voxel_data[x + dimensions.x * (y + dimensions.z * z)] = rand() % 6;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/Ray.cpp
12
src/Ray.cpp
@@ -130,20 +130,12 @@ sf::Color Ray::Cast() {
|
|||||||
alpha *= 162;
|
alpha *= 162;
|
||||||
|
|
||||||
switch (voxel_data) {
|
switch (voxel_data) {
|
||||||
case 1:
|
|
||||||
// AngleBew0 - 1.57 * 162 = 0 - 255
|
|
||||||
|
|
||||||
return sf::Color(255, 0, 0, alpha);
|
|
||||||
case 2:
|
|
||||||
return sf::Color(255, 10, 0, alpha);
|
|
||||||
case 3:
|
|
||||||
return sf::Color(255, 0, 255, alpha);
|
|
||||||
case 4:
|
|
||||||
return sf::Color(80, 0, 150, alpha);
|
|
||||||
case 5:
|
case 5:
|
||||||
return sf::Color(255, 120, 255, alpha);
|
return sf::Color(255, 120, 255, alpha);
|
||||||
case 6:
|
case 6:
|
||||||
return sf::Color(150, 80, 220, alpha);
|
return sf::Color(150, 80, 220, alpha);
|
||||||
|
default:
|
||||||
|
return sf::Color(150, 80, 220, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
dist++;
|
dist++;
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@@ -1,5 +1,6 @@
|
|||||||
#include "GL_Testing.h"
|
#include "GL_Testing.h"
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#include <vulkan/vk_sdk_platform.h>
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#include <CL/opencl.h>
|
#include <CL/opencl.h>
|
||||||
@@ -66,6 +67,15 @@ sf::Texture window_texture;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Map _map(sf::Vector3i(0, 0, 0));
|
||||||
|
_map.generate_octree();
|
||||||
|
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
||||||
|
|
||||||
GL_Testing t;
|
GL_Testing t;
|
||||||
|
|||||||
Reference in New Issue
Block a user