• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualMoonkis

Posted 29 November 2012 - 05:06 PM

I'm just letting you know that I changed the degree convention, x-positive is now 0 and increase the angle y going conter-clockwise ( Which helps with just keeping it: cos(a)*d and sin(a)*d )

Also I'v been trying to adapt your code here ( since you can't multiply vectors in SFML I'm giving an alternative version a go ) it currently looks like this:
  double K = std::tan(player.fov/2);
double distance_to_screen = 300;
sf::Vector2f left_vector(look_vector.x, -look_vector.y);
sf::Vector2f far_left_end = look_vector;
far_left_end.x + K * left_vector.x; far_left_end.y + K * left_vector.y;
sf::Vector2f one_column_increment(-2.0,-2.0);
one_column_increment.x * K * left_vector.x / w; one_column_increment.y * K * left_vector.y / w;
sf::VertexArray ray(sf::Lines, 2);
ray[0] = sf::Vector2f(player.x+5, player.y+5);
for( int i = 0; i < w; i++ )
{
ray[1] = sf::Vector2f( player.x+5 + far_left_end.x + i * one_column_increment.x, player.y+5 + far_left_end.y + i * one_column_increment.y);
rwind.draw(ray);
}

Though I did not get it to work as intended.

By the way, don't stress man, I'm just happy that you are helping me ( Can't stress that enough ) so take your time.

### #4Moonkis

Posted 29 November 2012 - 04:59 PM

I'm just letting you know that I changed the degree convention, x-positive is now 0 and increase the angle y going conter-clockwise ( Which helps with just keeping it: cos(a)*d and sin(a)*d )

Also I'v been trying to adapt your code here ( since you can't multiply vectors in SFML I'm giving an alternative version a go ) it currently looks like this:
  double K = std::tan(player.fov/2);
double distance_to_screen = 300;
sf::Vector2f left_vector(look_vector.x, -look_vector.y);
sf::Vector2f far_left_end = look_vector;
far_left_end.x + K * left_vector.x; far_left_end.y + K * left_vector.y;
sf::Vector2f one_column_increment(-2.0,-2.0);
one_column_increment.x * K * left_vector.x / w; one_column_increment.y * K * left_vector.y / w;
sf::VertexArray ray(sf::Lines, 2);
ray[0] = sf::Vector2f(player.x+5, player.y+5);
for( int i = 0; i < w; i++ )
{
ray[1] = sf::Vector2f( player.x+5 + far_left_end.x + i * one_column_increment.x, player.y+5 + far_left_end.y + i * one_column_increment.y);
rwind.draw(ray);
}

Though I did not get it to work as intended.

By the way, don't stress man, I'm just happy that you are helping me ( Can't stress that enough ) so take your time.

This is just a wild guess but I'm guessing that my ray I's suppose to look like this:

_-^^^^^^^-_
------------- - -
\ / \ /
\ / \ /
\ / \ /
\ / \ /
\ / \ /
\ / \ /
O and not like this ( as it's currently looking ) O

### #3Moonkis

Posted 29 November 2012 - 04:58 PM

I'm just letting you know that I changed the degree convention, x-positive is now 0 and increase the angle y going conter-clockwise ( Which helps with just keeping it: cos(a)*d and sin(a)*d )

Also I'v been trying to adapt your code here ( since you can't multiply vectors in SFML I'm giving an alternative version a go ) it currently looks like this:
  double K = std::tan(player.fov/2);
double distance_to_screen = 300;
sf::Vector2f left_vector(look_vector.x, -look_vector.y);
sf::Vector2f far_left_end = look_vector;
far_left_end.x + K * left_vector.x; far_left_end.y + K * left_vector.y;
sf::Vector2f one_column_increment(-2.0,-2.0);
one_column_increment.x * K * left_vector.x / w; one_column_increment.y * K * left_vector.y / w;
sf::VertexArray ray(sf::Lines, 2);
ray[0] = sf::Vector2f(player.x+5, player.y+5);
for( int i = 0; i < w; i++ )
{
ray[1] = sf::Vector2f( player.x+5 + far_left_end.x + i * one_column_increment.x, player.y+5 + far_left_end.y + i * one_column_increment.y);
rwind.draw(ray);
}

Though I did not get it to work as intended.

By the way, don't stress man, I'm just happy that you are helping me ( Can't stress that enough ) so take your time.

This is just a wild guess but I'm guessing that my ray I's suppose to look like this:
_-^^^^^^^-_
------------- - -
\ / \ /
\ / \ /
\ / \ /
\ / \ /
\ / \ /
\ / \ /
O and not like this ( as it's currently looking ) O

### #2Moonkis

Posted 29 November 2012 - 04:52 PM

I'm just letting you know that I changed the degree convention, x-positive is now 0 and increase the angle y going conter-clockwise ( Which helps with just keeping it: cos(a)*d and sin(a)*d )

Also I'v been trying to adapt your code here ( since you can't multiply vectors in SFML I'm giving an alternative version a go ) it currently looks like this:
  double K = std::tan(player.fov/2);
double distance_to_screen = 300;
sf::Vector2f left_vector(look_vector.x, -look_vector.y);
sf::Vector2f far_left_end = look_vector;
far_left_end.x + K * left_vector.x; far_left_end.y + K * left_vector.y;
sf::Vector2f one_column_increment(-2.0,-2.0);
one_column_increment.x * K * left_vector.x / w; one_column_increment.y * K * left_vector.y / w;
sf::VertexArray ray(sf::Lines, 2);
ray[0] = sf::Vector2f(player.x+5, player.y+5);
for( int i = 0; i < w; i++ )
{
ray[1] = sf::Vector2f( player.x+5 + far_left_end.x + i * one_column_increment.x, player.y+5 + far_left_end.y + i * one_column_increment.y);
rwind.draw(ray);
}

Though I did not get it to work as intended.

By the way, don't stress man, I'm just happy that you are helping me ( Can't stress that enough ) so take your time.

### #1Moonkis

Posted 29 November 2012 - 04:51 PM

I'm just letting you know that I changed the degree convention, x-positive is now 0 and increase the angle y going conter-clockwise ( Which helps with just keeping it: cos(a)*d and sin(a)*d )

Also I'v been trying to adapt your code here ( since you can't multiply vectors in SFML I'm giving an alternative version a go ) it currently looks like this:
  double K = std::tan(player.fov/2);
double distance_to_screen = 300;
sf::Vector2f left_vector(look_vector.x, -look_vector.y);
sf::Vector2f far_left_end = look_vector;
far_left_end.x + K * left_vector.x; far_left_end.y + K * left_vector.y;
sf::Vector2f one_column_increment(-2.0,-2.0);
one_column_increment.x * K * left_vector.x / w; one_column_increment.y * K * left_vector.y / w;
sf::VertexArray ray(sf::Lines, 2);
ray[0] = sf::Vector2f(player.x+5, player.y+5);
for( int i = 0; i < w; i++ )
{
ray[1] = sf::Vector2f( player.x+5 + far_left_end.x + i * one_column_increment.x, player.y+5 + far_left_end.y + i * one_column_increment.y);
rwind.draw(ray);
}


PARTNERS