Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMarkS

Posted 02 April 2013 - 07:02 PM

EarthBanana, what you seem to be suggesting is that I project the tiles and then cycle through them to find which are visible. This is terribly inefficient. What I am doing now is to project two vertices that are exactly 1 unit apart and measuring the distance between them. That gives me the exact size in pixels of an object after projection with the mvp matrix. After this, I divide the width and height of the view port by this value to get the exact number of rows and columns that are visible in the viewport. I then get the row and column of the tile in the center of projection. With this information, I can tell which columns are visible at the right and left sides of the view port and which rows are visible at the top and bottom of the view port. This result is exact. The tiles drawn are guaranteed to be visible with no false positives. The projected size of the tile, along with the row and columns extents only need to by calculated when the field of view or view port changes and can be stored. I only need to do about 4 divides and a few comparisons per frame.

What I *want* to do is two fold:

1.) I want to take the mvp matrix and determine the projected size without having to do the projection.
2.) I want to be able to calculate the field of view required to display a tile at a set size, say 256 pixels.

As MichaelNIII stated, this should be possible with soacahtoa. However, nothing I have done has worked. I can get the distance between the view point and the object from the mvp matrix (mvp[2][3]). Let's say that I want the tiles to be 256x256 pixels. According to soacahtoa, the field of view should be: 128/5(the distance in my case)*2. This doesn't work. The correct value is approximately 43.5113 degrees, found through testing, not the 51.2 degrees arrived from 128/5*2.

Equally, I should be able to tell the width in pixels by: ((5 / tan(60 / 2)) * 2) * 10(still not sure why 10 is necessary...). Once again, it doesn't work. The correct value, found by projection, is exactly 176.959 pixels, not 173.20 pixels.

My best guess is that the problem lies in that the distance is in units, not pixels. I would need to convert the distance to pixels or the pixel size to units. I'm not sure how to do this, or even if it is possible.

Unless someone can explain what I'm doing wrong, I am just going to stick with what I have.

#2MarkS

Posted 02 April 2013 - 07:01 PM

EarthBanana, what you seem to be suggesting is that I project the tiles and then cycle through them to find which are visible. This is terribly inefficient. What I am doing now is to project two vertices that are exactly 1 unit apart and measuring the distance between them. That gives me the exact size in pixels of an object after projection with the mvp matrix. After this, I divide the width and height of the view port by this value to get the exact number of rows and columns that are visible in the viewport. I then get the row and column of the tile in the center of projection. With this information, I can tell which columns are visible at the right and left sides of the view port and which rows are visible at the top and bottom of the view port. This result is exact. The tiles drawn are guaranteed to be visible with no false positives. The projected size of the tile, along with the row and columns extents only need to by calculated when the field of view or view port changes and can be stored. I only need to do about 4 divides and a few comparisons per frame.

What I *want* to do is two fold:

1.) I want to take the mvp matrix and determine the projected size without having to do the projection.
2.) I want to be able to calculate the field of view required to display a tile at a set size, say 256 pixels.

As MichaelNIII stated, this should be possible with soacahtoa. However, nothing I have done has worked. I can get the distance between the view point and the object from the mvp matrix (mvp[2][3]). Let's say that I want the tiles to be 256x256 pixels. According to soacahtoa, the field of view should be: 128/5(the distance in my case)*2. This doesn't work. The correct value is approximately 43.5113 degrees, found through testing, not the 51.2 degrees arrived from 128/5*2.

Equally, I should be able to tell the width in pixels by: ((5 / tan(60 / 2)) * 2) * 10(still not sure why 10 is necessary...). Once again, it doesn't work. The correct value, found by projection) is exactly 176.959 pixels, not 173.20 pixels.

My best guess is that the problem lies in that the distance is in units, not pixels. I would need to convert the distance to pixels or the pixel size to units. I'm not sure how to do this, or even if it is possible.

Unless someone can explain what I'm doing wrong, I am just going to stick with what I have.

#1MarkS

Posted 02 April 2013 - 06:58 PM

EarthBanana, what you seem to be suggesting is that I project the tiles and then cycle through them to find which are visible. This is terribly inefficient. What I am doing now is to project two vertices that are exactly 1 unit apart and measuring the distance between them. That gives me the exact size in pixels of an object after projection with the mvp matrix. After this, I divide the width and height of the view port by this value to get the exact number of rows and columns that are visible in the viewport. I then get the row and column of the tile in the center of projection. With this information, I can tell which columns are visible at the right and left sides of the view port and which rows are visible at the top and bottom of the view port. This result is exact. The tiles drawn are guaranteed to be visible. There are no false positives. The projected size of the tile, along with the row and columns extents only need to by calculated when the field of view or view port changes and can be stored. I only need to do about 4 divides and a few comparisons per frame.

What I *want* to do is two fold:

1.) I want to take the mvp matrix and determine the projected size without having to do the projection.
2.) I want to be able to calculate the field of view required to display a tile at a set size, say 256 pixels.

As MichaelNIII stated, this should be possible with soacahtoa. However, nothing I have done has worked. I can get the distance between the view point and the object from the mvp matrix (mvp[2][3]). Let's say that I want the tiles to be 256x256 pixels. According to soacahtoa, the field of view should be: 128/5(the distance in my case)*2. This doesn't work. The correct value is approximately 43.5113 degrees, found through testing, not the 51.2 degrees arrived from 128/5*2.

Equally, I should be able to tell the width in pixels by: ((5 / tan(60 / 2)) * 2) * 10(still not sure why 10 is necessary...). Once again, it doesn't work. The correct value, found by projection) is exactly 176.959 pixels, not 173.20 pixels.

My best guess is that the problem lies in that the distance is in units, not pixels. I would need to convert the distance to pixels or the pixel size to units. I'm not sure how to do this, or even if it is possible.

Unless someone can explain what I'm doing wrong, I am just going to stick with what I have.

PARTNERS