You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#pragma once
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include "map/Map.h"
|
|
|
|
|
|
|
|
class Ray {
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// The Tail of the vector
|
|
|
|
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> 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 3d voxel position the ray is currently at
|
|
|
|
sf::Vector3<int> voxel;
|
|
|
|
|
|
|
|
// The 2d pixel coordinate
|
|
|
|
sf::Vector2<int> pixel;
|
|
|
|
|
|
|
|
// Reference to the voxel map
|
|
|
|
Map *map;
|
|
|
|
|
|
|
|
// The dimensions of the voxel map
|
|
|
|
sf::Vector3<int> dimensions;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Ray(
|
|
|
|
Map *m,
|
|
|
|
sf::Vector2<int> resolution,
|
|
|
|
sf::Vector2<int> pixel,
|
|
|
|
sf::Vector3<float> camera_position,
|
|
|
|
sf::Vector3<float> ray_direction
|
|
|
|
);
|
|
|
|
|
|
|
|
sf::Color Cast();
|
|
|
|
};
|