added the map, switched branches

This commit is contained in:
MitchellHansen
2016-07-30 23:05:59 -07:00
parent 624d2771ac
commit 4432c0338b
7 changed files with 600 additions and 37 deletions

24
include/Map.h Normal file
View 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:
};

View File

@@ -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();
};

View File

@@ -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;
};