alright, tried a different method of assigning voxel step directions and I

think it's working. The 3 negative walls are still very flat, and the
lower XYZ numbers still distort the viewport
master
MitchellHansen 8 years ago
parent f1c84c85b5
commit 3deb3a2b08

@ -14,18 +14,19 @@ public:
list[55 + dim.x * (55 + dim.z * i)] = 1;
}
// The X walls get red and magenta
for (int x = 0; x < dim.x; x += 2) {
for (int y = 0; y < dim.y; y += 2) {
list[x + dim.x * (y + dim.z * 1)] = 1;
}
}
for (int x = 0; x < dim.x; x += 2) {
for (int y = 0; y < dim.y; y += 2) {
list[x + dim.x * (y + dim.z * 99)] = 2;
}
}
// The Z walls get yellow and some other color
for (int x = 0; x < dim.x; x += 2) {
for (int z = 0; z < dim.z; z += 2) {
list[x + dim.x * (99 + dim.z * z)] = 3;

@ -38,12 +38,7 @@ sf::Color Ray::Cast(){
(int)origin.z
);
// Set the first intersection to be offset by the VOXEL camera position
intersection_t = sf::Vector3<float>(
delta_t.x + voxel.x,
delta_t.y + voxel.y,
delta_t.z + voxel.z
);
// Setup the voxel step based on what direction the ray is pointing
sf::Vector3<int> voxel_step(1, 1, 1);
@ -56,17 +51,29 @@ sf::Color Ray::Cast(){
//if (direction.y < 0.0f) {
// voxel_step.z *= -1;
//}
if (direction.y > PI * 2 + PI / 2 || direction.y < -1 *PI * 2 + PI / 2) {
voxel_step.x *= -1;
}
//if (direction.y > PI * 2 + PI / 2 || direction.y < -1 *PI * 2 + PI / 2) {
// voxel_step.x *= -1;
//}
// Left right
if (direction.z > 1.57) {
//voxel_step.z *= -1;
}
/*if (direction.z > 1.57) {
voxel_step.y *= -1;
voxel_step.x *= -1;
}*/
//if (direction.z <= 3.14f + 1.57f && direction.z > 0.0f + 1.57f) {
// voxel_step.z *= -1;
//}
voxel_step.x *= (cartesian.x > 0) - (cartesian.x < 0);
voxel_step.y *= (cartesian.y > 0) - (cartesian.y < 0);
voxel_step.z *= (cartesian.z > 0) - (cartesian.z < 0);
// Set the first intersection to be offset by the VOXEL camera position
intersection_t = sf::Vector3<float>(
delta_t.x * voxel_step.x + voxel.x,
delta_t.y * voxel_step.y + voxel.y,
delta_t.z * voxel_step.z + voxel.z
);
int dist = 0;
do {

Loading…
Cancel
Save