• Create Account

AnEverydayGuy

Member Since 24 Apr 2008
Offline Last Active Oct 31 2013 11:49 AM

How to fit a box in the camera's view frustum

31 January 2013 - 05:09 PM

Hey guys, I'm having a problem with some basic math for a basic concept.

Idea:

I have a rectanglar box in my scene and I want to distance the camera such that the box just fits.

Background:

So right now I have my camera set up so that I can select a heading and an elevation. The software then calculates the camera's position using that data as if the camera is connected to a piece of string attached to the middle of the cube, tethering it to a spherical area. EG: I give it a heading of 45 degress and an elevation of 30 degrees, the camera is positioned 'Southwest' of the cube so it's looking 'Northeast' (45 degrees) and has an elevation of 30 degrees from the ground. If I give it a heading of 180 and an elevation of 90, the top of the screen is 'South' and the camera is directly above the box. (The x-axis is East/West, the y-axis is North/South). Now I'm trying to figure out to calculate the distance the camera needs to be so the box fills the screen. I know how to calculate the distance the camera needs to be so that no matter how the cube is rotated it fits (distance = boundRadius / sin(FOV / 2)). The problem with this is that the box is a wide, narrow rectangle, with little depth so using this method the box fills the screen only at a specific heading and elevation, otherwise there is a lot of empty space.

Current idea:

Since, ultimately, there's no difference between positioning the camera and rotating the mesh, I can think of the camera as being stationary and the mesh is being rotated so it's displayed with the correct heading and elevation. I was thinking that if I calculate the width and height of the box after it's rotated I can use trigonometry to calculate the distance (distance = halfWidth / tan(FOV / 2)). (If there's an easier/better idea, by all means, please let me know). I know how to calculate a 2D square's height and width after a 1D rotation, but I don't know how to calculate a 3D box's height and width after a 2D rotation.

What I know:

The box's height, width and depth; the camera's field of view, elevation (IE: x-axis rotation) and heading (IE: z-axis rotation).

Maya 2010 move tool problem

16 February 2011 - 12:33 AM

I've ran into an odd problem. When I try to translate (move) any part of a mesh (vertex, face, edge, etc; other than as a whole (IE: NOT in object mode)) along the X-axis, it scales the parts rather than moving them. If I'm in object mode or moving along the Y or Z-axis, I can move the mesh or its parts just fine. I've tried restarting Maya, my computer and just making a new scene; but the problem persists, leading me to think I've accidentally changed a setting somewhere. I spent about 2 hours searching the Autodesk website and Google but I haven't found anything to help me fix this.

EDIT:
I figured it out, under the move tool options; I somehow enabled the 'reflection' property (which actually makes sense in hindsight). That'll teach me to stay up till 2 in the morning

Input help

09 January 2009 - 08:11 AM

Alt tab event

06 January 2009 - 03:18 PM

Until a week or so ago I had completely forgot about the 'alt tab' event (when a player 'alt tabs' out of the game and back in). I've decided to make this my priority. Long story short I've tried a couple of tutorials and I've had some issues. I was hoping someone would have a great tutorial (great as in, I'm a total idiot and have no idea what I'm doing) on how to handle the player 'alt tabbing' out of, and into, the game. If it matters I have my window's message pump in a separate thread.