Widescreen Gaming Forum

[-noun] Web community dedicated to ensuring PC games run properly on your tablet, netbook, personal computer, HDTV and multi-monitor gaming rig.
It is currently 22 Dec 2024, 04:13

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 07:38 
Offline

Joined: 06 Jul 2008, 20:26
Posts: 42
http://emsai.net/projects/widescreen/fovcalc/

I made this some time ago due to http://www.widescreengamingforum.com/fovcalc.php being limited to only those games and those resolutions.
My calculator is more flexible accept various forms of input for aspect. (res, aspect ratio and aspect decimal "name")

Feel free to link to it from the FOV Calc page on your site,
or alternatively let me know and I'll give you the PHP code used for my calc so your webmaster can implement it on the WGF site. (all I ask in return is a link back to my calc page as the auth of this script)

If wanted though, I could improve this further by adding a javascript that reads a list of known game FOV's that can be selected to autopopulate the "Old FOV" input field, it will be made so easy that one only need to add 1 line per game in a txt file, should be easy for a webmaster to keep that up-to-date then.
If this is wanted, lemme know and I'll see about getting this done during this month. (maybe before xmas?)


Top
 Profile  
 


 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 07:47 
Offline

Joined: 06 Jul 2008, 20:26
Posts: 42
I'm not dissing Borbosha's calc though, and if you folks would like to see a merge of the code and adding of the autopopulation to the fields maybe he and I could work together on this even.


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 09:02 
Offline
Insiders
Insiders
User avatar

Joined: 14 Apr 2007, 02:13
Posts: 1514
I had thrown together an AJAX one a long time ago but I never got around to throwing a front-end on it or make it look any decent.

http://imk.cx/pc/fovcalculator/calc.xhtml

_________________
Widescreen Fixer - https://www.widescreenfixer.org/

Widescreen Fixer Twitter - https://twitter.com/widescreenfixer
Personal Twitter - https://twitter.com/davidrudie


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 09:32 
Offline

Joined: 06 Jul 2008, 20:26
Posts: 42
Nice! Looks like you got the math right too, I guess we are using the same math even.

A combination of all 3 tools might be the best maybe?

For example:
I like the list of games in the one on this site, it should be to the right of the old FOV input field though IMO.
I like the automatic/AJAX calculation in yours, saves people from having to press a button (or hit enter).
I like how the one on my site allows so many different forms of input. (a drop down list to the right side of these with the most common would also be nice though)

Or maybe it could default to pre-selections and instead have a Advanced mode toggle?

Not sure why the tool on this site has different results than yours or mine though.

Is Borbosha still active here? Would be nice to pool all our code and ideas together, I don't care who does the final coding etc. It would just be nice to see the three merged as all three have advantages and disadvantages the others do not etc.

I'd be willing to license my source under the zlib/MIT/BSD license if you and Borbosha are willing to do the same, that way any of us (or someone else) could easily merge the tools.


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 15:16 
Offline
Founder
Founder
User avatar

Joined: 13 Oct 2003, 05:00
Posts: 7358
Rescator, thanks for the offer. I know there are some other issues with our current calc. If you can give me the php code, that would be great.

As far as the list, most of those games are old, and not sure how popular. We can just keep a table of known FOVs.

Dopefish, would your AJAX one work in a php page?


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 20:37 
Offline

Joined: 06 Jul 2008, 20:26
Posts: 42
Rescator, thanks for the offer. I know there are some other issues with our current calc. If you can give me the php code, that would be great.


Just sent you a PM with the code.

Dopefish, would your AJAX one work in a php page?

Considering that he's most likely using PHP for the AJAX responses it should be mergeable in some way? At least I hope so.


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 12 Dec 2008, 23:01 
Offline
Insiders
Insiders
User avatar

Joined: 14 Apr 2007, 02:13
Posts: 1514
Nice! Looks like you got the math right too, I guess we are using the same math even.


My main FOV calculator uses ASM. I've posted the ASM for that before. The AJAX one uses PHP.

Anyway, some advanced stuff is neat. I made mine more along the lines for gamers and end-users. It only offers the most common aspect-ratios because there's little need for other options. It would only complicate things with certain people. The only other thing that might be useful is maybe adding a list of resolutions to go along with the aspect-ratios because not everyone understands them.

Anyway, I have no problem handing out the source. It's a common algorithm.



calc.js
Code:

   /* By Dopefish -- http://imk.cx/ -- <[email protected]> */
   
   var xmlHttp;
   
   function calculate()
   {
       xmlHttp = GetXmlHttpObject();
       if(xmlHttp == null)
       {
           alert("Your web browser does not support AJAX.");
           return;
       }
   
       var cb1 = document.forms[0].cb1.value;
       var cb2 = document.forms[0].cb2.value;
       var fov = document.forms[0].fov.value;
   
       var url = "fovcalc.php";
       url = url + "?cb1=" + cb1;
       url = url + "&cb2=" + cb2;
       url = url + "&fov=" + fov;
   
       xmlHttp.open("GET", url, true);
       xmlHttp.onreadystatechange = stateChanged;
       xmlHttp.send(null);
   }
   
   function stateChanged()
   {
       if(xmlHttp.readyState == 4)
       {
           document.getElementById("fovResult").innerHTML = xmlHttp.responseText;
       }
   }
   
   function GetXmlHttpObject()
   {
       var xmlHttp = null;
       try
       {
           xmlHttp = new XMLHttpRequest();
       }
       catch(e)
       {
           try
           {
               xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
           }
           catch(e)
           {
               xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
           }
       }
       return xmlHttp;
   }
   




fovcalc.php
Code:

   <?php
   
   /* By Dopefish -- http://imk.cx/ -- <[email protected]> */
   
   if(isset($_GET['cb1']) && isset($_GET['cb2']) && isset($_GET['fov'])):
   
       $ComboBox1   = $_GET['cb1'];
       $ComboBox2   = $_GET['cb2'];
       $FieldOfView = $_GET['fov'];
   
       echo Rad2Deg(2 * ATan(($ComboBox2 / $ComboBox1) * Tan(Deg2Rad($FieldOfView) / 2)));
   
   else:
   
       echo "Not all fields were set.";
   
   endif;
   
   ?>
   




calc.xhtml -- Implement this in your own way. :)
Code:

   <?xml version="1.0" encoding="utf-8"?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
       <head>
           <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
           <title>fovCalculator</title>
           <script type="text/javascript" src="calc.js"></script>
       </head>
   
       <body>
   
           <div>
   
               <form action="">
                   <div>
                       Source Aspect Ratio:<br />
                       <select name="cb1" class="dropdown" onchange="calculate(this.value)">
                           <option value="1.25">5:4</option>
                           <option value="1.3333333333333333333333333333333" selected="selected">4:3</option>
                           <option value="1.6">16:10</option>
                           <option value="1.6666666666666666666666666666667">15:9</option>
                           <option value="1.7777777777777777777777777777778">16:9</option>
                           <option value="3.75">15:4 (3 x 5:4)</option>
                           <option value="4">12:3 (3 x 4:3)</option>
                           <option value="4.8">24:5 (3 x 16:10)</option>
                           <option value="5">15:3 (3 x 15:9)</option>
                           <option value="5.3333333333333333333333333333333">16:3 (3 x 16:9)</option>
                       </select>
   
                       <br /><br />
   
                       Destination Aspect Ratio:<br />
                       <select name="cb2" class="dropdown" onchange="calculate(this.value)">
                           <option value="1.25">5:4</option>
                           <option value="1.3333333333333333333333333333333">4:3</option>
                           <option value="1.6" selected="selected">16:10</option>
                           <option value="1.6666666666666666666666666666667">15:9</option>
                           <option value="1.7777777777777777777777777777778">16:9</option>
                           <option value="3.75">15:4 (3 x 5:4)</option>
                           <option value="4">12:3 (3 x 4:3)</option>
                           <option value="4.8">24:5 (3 x 16:10)</option>
                           <option value="5">15:3 (3 x 15:9)</option>
                           <option value="5.3333333333333333333333333333333">16:3 (3 x 16:9)</option>
                       </select>
   
                       <br /><br />
   
                       Default FOV:<br />
                       <input type='text' name='fov' onkeyup="calculate(this.value);" />
                   </div>
               </form>
   
               <br />
   
               Corrected FOV:<br />
               <div id="fovResult"></div>
   
           </div>
   
       </body>
   
   </html>
   

_________________
Widescreen Fixer - https://www.widescreenfixer.org/

Widescreen Fixer Twitter - https://twitter.com/widescreenfixer
Personal Twitter - https://twitter.com/davidrudie


Top
 Profile  
 
 Post subject: FOV Calculator v2.0 ?
PostPosted: 17 Dec 2008, 03:29 
Offline
Insiders
Insiders
User avatar

Joined: 14 Apr 2007, 02:13
Posts: 1514
I updated the PHP code to be a bit smaller. I forgot about the Deg2Rad() and Rad2Deg() functions when I wrote that long ago.

_________________
Widescreen Fixer - https://www.widescreenfixer.org/

Widescreen Fixer Twitter - https://twitter.com/widescreenfixer
Personal Twitter - https://twitter.com/davidrudie


Top
 Profile  
 
PostPosted: 18 Feb 2009, 21:43 
Offline

Joined: 18 Feb 2009, 21:40
Posts: 3
I made mine more along the lines for gamers and end-users. It only offers the most common aspect-ratios because there's little need for other options. It would only complicate things with certain people. The only other thing that might be useful is maybe adding a list of resolutions to go along with the aspect-ratios because not everyone understands them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  




Powered by phpBB® Forum Software © phpBB Group