Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] New "Set Camera FOV" based on two angles!!!

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 24th Sep 2007 04:22 Edited at: 6th May 2008 05:12
[Edit]Forgot to put [DBP] in the title, my apologies, not sure if it would work in DBC, too[/Edit]

Some of you may have read my post asking if this was possible in DBP... well I decided to go ahead and make some code to "simulate", if nothing else, the effect of setting the FOV of a camera based upon an X (Horizontal) and Y (Vertical) Angle.

You can view the snippet in the CodeBase, or for easier access:



The Code is described in my CodeBase entry, which you can view here http://www.thegamecreators.com/?m=codebase_view&i=3391f38320c9833f630894df5e9c6711

Please comment (or CONSTRUCTIVELY criticise), because I love to read what other people think about my code


Your one and only,

~PlystirE~

Attachments

Login to view attachments
Essence
22
Years of Service
User Offline
Joined: 12th Oct 2002
Location: The Netherlands
Posted: 5th Oct 2007 17:55
So basicly, if you use this, you could create 'portal-cameras' or TV screens (on a plane) w/o it getting all stretched out or blurry...

If thats the case, sounds usefull

ps. cant access DBP right now, I'm visiting my parents atm...

Current project: MiRevu Visual Gaming Engine
thread: http://forum.thegamecreators.com/?m=forum_view&t=103073&b=8
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 6th Oct 2007 03:01
@Essence:

Exactly, what I made this for is so that I could have a camera very close to a doorway, and still be able to have it see everything through it.

With this simple function the camera's fov angle could be one angle vertically and another horizontally, allowing some pretty neat effects, as well as some nice compatability in certain cases.

And, thanks for the response, I was beginning to wonder if everyone thought it was useless.


The one and only,
~PlystirE~

In Soviet Russia, road forks you!

Mom: I may not be the alpha and omega, but I can sure as hell be yours!
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 17th Oct 2007 19:09
Erm - I think the DBPro FOV angle is based on a diagonal measurement. You could use the same aspect ratio, but the new FOV would need to be sqrt((Yangle#^2)+(Xangle#^2))

I can't be bothered to invent a signature
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 18th Oct 2007 08:11 Edited at: 18th Oct 2007 08:12
Well, the one I posted works great, and the version you mentioned... well, gave me a completely different result.

I checked this by doing the following:

- Set the initial FOV to 90 (So both x and y will be 90 degrees)
- I then set two keys to run your distance formula and my function respectively.
- Using the values 90 and 45 for XAngle and YAngle respectively, the results came as follows for the two key presses:

Pressing the key for my function, the image was stretched in the y direction so the top quarter and bottom quarter of the screen (effectively HALF the screen) were no longer visible. The image was unchanged in the x direction... this is what should happen because the XAngle was left at 90 degrees, and the initial FOV was also 90.

Pressing the key for your distance formula, the image simply had a zoom effect that was based upon the images current aspect/FOV setting. Meaning, if I pressed this key FIRST, the original image zoomed outward. If I had pushed the key for my function BEFORE this key, then it had a very strong zoom out effect of the image produced by my function.


I suppose if you wanted to zoom your camera without actually moving it, then your distance formula may come in handy, but it certainly does not do the same thing as what this function was built to do.

If you would like to test it, then I can put together a simple program that will do that for you.


The one and only,
~PlystirE~

Dammit, Jim! I'm a programmer not a graphic designer!!!
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 5th Nov 2007 17:54
I stand corrected then. Your function would be useful, when coupled with the command to set where the camera is displayed on the screen. By keeping them both at the same aspect ratio would make some very strange effects.

Your signature has been erased by a hyper-intelligent pan-dimensional being (a mod)

Login to post a reply

Server time is: 2024-11-22 12:52:18
Your offset time is: 2024-11-22 12:52:18