More work done on the ray

This commit is contained in:
MitchellHansen
2016-07-31 00:01:50 -07:00
parent 4432c0338b
commit 37ef472f61
5 changed files with 179 additions and 25 deletions

View File

@@ -5,39 +5,39 @@
class Ray {
private:
private:
// The Tail of the vector
sf::Vector3<float> origin;
// The Tail of the vector
sf::Vector3<float> origin;
// Direction / Length of the vector
sf::Vector3<float> direction;
// Direction / Length of the vector
sf::Vector3<float> direction;
// The incrementing points at which T intersects int(X, Y, Z) points
sf::Vector3<float> intersection_t;
// The incrementing points at which T intersects int(X, Y, Z) points
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
sf::Vector3<float> delta_t;
// The speed at which the ray climbs.
// Take the slope of the line (1 / cartesian.x/y/z) = delta_t.x/y/z
sf::Vector3<float> delta_t;
// The 3d voxel position the ray is currently at
sf::Vector3<int> voxel;
// The 3d voxel position the ray is currently at
sf::Vector3<int> voxel;
// Reference to the voxel map
Map *map;
// Reference to the voxel map
Map *map;
// The dimensions of the voxel map
sf::Vector3<int> dimensions;
// 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
);
sf::Color Cast();
sf::Color Cast();
};

View File

@@ -1,5 +1,9 @@
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
const double PI = 3.141592653589793238463;
const float PI_F = 3.14159265358979f;
struct fps_counter {
public:
@@ -49,3 +53,24 @@ inline sf::Vector3f CartToSphere(sf::Vector3f in) {
);
return r;
};
inline sf::Vector3f Normalize(sf::Vector3f in) {
float multiplier = sqrt(in.x * in.x + in.y * in.y + in.z * in.z);
auto r = sf::Vector3f(
in.x / multiplier,
in.y / multiplier,
in.z / multiplier
);
return r;
}
inline float DegreesToRadians(float in) {
return in * PI / 180.0f;
}
inline float RadiansToDegrees(float in) {
return in * 180.0f / PI;
}