Basic render loop is taking shape. Digging back into the

raycasting will be slightly annoying
This commit is contained in:
MitchellHansen
2016-07-31 01:01:01 -07:00
parent 37ef472f61
commit 2b46bef923
5 changed files with 57 additions and 28 deletions

View File

@@ -3,11 +3,10 @@
#include <Ray.h>
RayCaster::RayCaster(Map *map,
sf::Vector3<int> map_dimensions,
sf::Vector2<int> viewport_resolution,
sf::Vector3<float> camera_direction,
sf::Vector3<float> camera_position) {
RayCaster::RayCaster(
Map *map,
sf::Vector3<int> map_dimensions,
sf::Vector2<int> viewport_resolution ) {
// Override values
//this.map_dimensions = new Vector3<int> (50, 50, 50);
@@ -17,16 +16,12 @@ RayCaster::RayCaster(Map *map,
this->map_dimensions = map_dimensions;
map = map;
this->map = map;
resolution = viewport_resolution;
image = new sf::Uint8[resolution.x, resolution.y];
image = new sf::Color[resolution.x, resolution.y];
this->camera_direction = camera_direction;
camera_direction_cartesian = Normalize(SphereToCart(camera_direction));
this->camera_position = camera_position;
}
@@ -36,7 +31,13 @@ RayCaster::~RayCaster() {
sf::Uint8* RayCaster::Cast() {
sf::Color* RayCaster::CastRays(sf::Vector3<float> camera_direction, sf::Vector3<float> camera_position) {
// Setup the camera for this cast
this->camera_direction = camera_direction;
camera_direction_cartesian = Normalize(SphereToCart(camera_direction));
this->camera_position = camera_position;
// The radian increment each ray is spaced from one another
double y_increment_radians = DegreesToRadians(40.0 / resolution.y);

View File

@@ -7,13 +7,11 @@ class RayCaster {
public:
RayCaster(Map *map,
sf::Vector3<int> map_dimensions,
sf::Vector2<int> viewport_resolution,
sf::Vector3<float> camera_direction,
sf::Vector3<float> camera_position);
sf::Vector2<int> viewport_resolution);
~RayCaster();
sf::Uint8* Cast();
sf::Color* CastRays(sf::Vector3<float> camera_direction, sf::Vector3<float> camera_position);
private:
@@ -24,7 +22,7 @@ private:
sf::Vector2<int> resolution;
// The pixel array, maybe do RBGA? Are there even 4 byte data types?
sf::Uint8 *image;
sf::Color *image;
// The direction of the camera in POLAR coordinates
sf::Vector3<float> camera_direction;