added the map, switched branches
This commit is contained in:
24
include/Map.h
Normal file
24
include/Map.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
|
||||
class Map {
|
||||
public:
|
||||
Map(sf::Vector3i dim) {
|
||||
list = new char[dim.x * dim.y * dim.z];
|
||||
}
|
||||
|
||||
~Map() {
|
||||
}
|
||||
|
||||
sf::Vector3<int> getDimensions();
|
||||
char *list;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ class Ray {
|
||||
private:
|
||||
|
||||
// The Tail of the vector
|
||||
sf::Vector3<float> origin
|
||||
sf::Vector3<float> origin;
|
||||
|
||||
// Direction / Length of the vector
|
||||
sf::Vector3<float> direction;
|
||||
|
||||
// The incrementing points at which T intersects int(X, Y, Z) points
|
||||
sf::Vector3<float> intersction_t;
|
||||
sf::Vector3<float> intersection_t;
|
||||
|
||||
// The speed at which the ray climbs.
|
||||
// Take the slope of the line (1 / cartesian.x/y/z) = delta_t.x/y/z
|
||||
@@ -24,20 +24,20 @@ class Ray {
|
||||
sf::Vector3<int> voxel;
|
||||
|
||||
// Reference to the voxel map
|
||||
Map *m;
|
||||
Map *map;
|
||||
|
||||
// The dimensions of the voxel map
|
||||
sf::Vector3<int> dimensions;
|
||||
|
||||
public:
|
||||
|
||||
public Ray(
|
||||
Map *m,
|
||||
sf::Vector2<int> resolution,
|
||||
sf::Vector2<int> pixel,
|
||||
sf::Vector3<float> camera_position,
|
||||
sf::Vector3<float> ray_direction
|
||||
);
|
||||
Ray(
|
||||
Map *m,
|
||||
sf::Vector2<int> resolution,
|
||||
sf::Vector2<int> pixel,
|
||||
sf::Vector3<float> camera_position,
|
||||
sf::Vector3<float> ray_direction
|
||||
);
|
||||
|
||||
public sf::Color Cast();
|
||||
}
|
||||
sf::Color Cast();
|
||||
};
|
||||
|
||||
@@ -5,8 +5,7 @@ struct fps_counter {
|
||||
public:
|
||||
fps_counter(){
|
||||
if(!f.loadFromFile("../assets/fonts/Arial.ttf")){
|
||||
std::cout << "couldn't find the fallback Arial font "
|
||||
"in ../assets/fonts/" << std::endl;
|
||||
std::cout << "couldn't find the fall back Arial font in ../assets/fonts/" << std::endl;
|
||||
} else {
|
||||
t.setFont(f);
|
||||
}
|
||||
@@ -29,3 +28,24 @@ private:
|
||||
double fps_average = 0;
|
||||
};
|
||||
|
||||
|
||||
inline sf::Vector3f SphereToCart(sf::Vector3f i) {
|
||||
|
||||
auto r = sf::Vector3f(
|
||||
(i.x * sin(i.z) * cos(i.y)),
|
||||
(i.x * sin(i.z) * sin(i.y)),
|
||||
(i.x * cos(i.z))
|
||||
);
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
inline sf::Vector3f CartToSphere(sf::Vector3f in) {
|
||||
|
||||
auto r = sf::Vector3f(
|
||||
sqrt(in.x * in.x + in.y * in.y + in.z * in.z),
|
||||
atan(in.y / in.x),
|
||||
atan(sqrt(in.x * in.x + in.y * in.y) / in.z)
|
||||
);
|
||||
return r;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user