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.

AppGameKit Classic Chat / 3D plane scaling question

Author
Message
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 27th Jul 2015 12:40
I wonder if anybody could help me with a 3D problem?

I need to create a plane object and scale it so that for any given distance (d) from the camera and camera field of view (fov) the plane will be the exact size to fit the screen.

What would be the best way to calculate this using Tier 1.
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 27th Jul 2015 13:26
I once made a HUD using planes that use the principles you need. I'll post the code below:

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 27th Jul 2015 14:21
There is a command CreateObjectQuad(), this is a special quad object that always fits the screen. You need to draw it manually with DrawObject() each frame you want it to render.

JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 27th Jul 2015 14:51
Zerotown: thanks for the code. I kind of need to do the opposite of what you're doing; you change the distance between the hud panel and the camera to get the correct size (ZDist#) whereas I need to resize the plane depending on the distance between the plane and the camera (which can change).

Matty H: The Quad function looks useful. In the documentation, it says it will fill the entire screen. Is that the case if I subsequently change the distance between the quad and the camera?

I've just done some beer-mat maths and it seems that I should be using this formula to get the plane size:

planeLength = Sin(fov / 2) * d

Will try it out tonight.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 27th Jul 2015 15:33
Quote: "The Quad function looks useful. In the documentation, it says it will fill the entire screen. Is that the case if I subsequently change the distance between the quad and the camera?"


You can't change the distance, the quad misses out that part of the transformation pipeline for faster rendering times. The quad is mainly used for shaders and may not suit your purposes, but it's good to be aware of it at least

Login to post a reply

Server time is: 2024-11-25 19:33:41
Your offset time is: 2024-11-25 19:33:41