Going to need to get rid of the spherical camera
This commit is contained in:
@@ -23,6 +23,9 @@ class Ray {
|
|||||||
// The 3d voxel position the ray is currently at
|
// The 3d voxel position the ray is currently at
|
||||||
sf::Vector3<int> voxel;
|
sf::Vector3<int> voxel;
|
||||||
|
|
||||||
|
// The 2d pixel coordinate
|
||||||
|
sf::Vector2<int> pixel;
|
||||||
|
|
||||||
// Reference to the voxel map
|
// Reference to the voxel map
|
||||||
Map *map;
|
Map *map;
|
||||||
|
|
||||||
|
|||||||
13
src/Ray.cpp
13
src/Ray.cpp
@@ -13,6 +13,7 @@ Ray::Ray(
|
|||||||
sf::Vector3<float> camera_position,
|
sf::Vector3<float> camera_position,
|
||||||
sf::Vector3<float> ray_direction) {
|
sf::Vector3<float> ray_direction) {
|
||||||
|
|
||||||
|
this->pixel = pixel;
|
||||||
this->map = map;
|
this->map = map;
|
||||||
origin = camera_position;
|
origin = camera_position;
|
||||||
direction = ray_direction;
|
direction = ray_direction;
|
||||||
@@ -46,6 +47,13 @@ sf::Color Ray::Cast() {
|
|||||||
fabsf((float) (1.0 / cartesian.z))
|
fabsf((float) (1.0 / cartesian.z))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//97, 25, 34 is an interesting example of the problems
|
||||||
|
// Ahhh, ya know what? This is a problem with how spherical coords
|
||||||
|
// work when approaching 0 on the chi axis as rotation about
|
||||||
|
// the theta axis is completely useless. A viewing frustum will
|
||||||
|
// be needed unfortunately
|
||||||
|
|
||||||
|
|
||||||
// Intersection T is the collection of the next intersection points
|
// Intersection T is the collection of the next intersection points
|
||||||
// for all 3 axis XYZ.
|
// for all 3 axis XYZ.
|
||||||
|
|
||||||
@@ -59,6 +67,11 @@ sf::Color Ray::Cast() {
|
|||||||
delta_t.z + origin.z
|
delta_t.z + origin.z
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (pixel.x == 0){
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
int dist = 0;
|
int dist = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ sf::Color* RayCaster::CastRays(sf::Vector3<float> camera_direction, sf::Vector3<
|
|||||||
|
|
||||||
//-resolution.y / 2
|
//-resolution.y / 2
|
||||||
// Start the loop at the top left, scan right and work down
|
// Start the loop at the top left, scan right and work down
|
||||||
for (int x = 0; x < resolution.x; x++) {
|
for (int y = 0; y < resolution.y; y++) {
|
||||||
for (int y = 0; y < resolution.y; y++) {
|
for (int x = 0; x < resolution.x; x++) {
|
||||||
|
|
||||||
// The direction the final ray will point.
|
// The direction the final ray will point.
|
||||||
// First take a reference to the base direction to setup the viewport
|
// First take a reference to the base direction to setup the viewport
|
||||||
|
|||||||
Reference in New Issue
Block a user