PDA

View Full Version : Find pos 2D image that stretch fully in a camera's view


wideLego
03-27-2009, 01:26 AM
Hi everyone,

I have the following maxscript problem that I would like to solve: "How to find the position of an input 2D image the (x,y,z) that stretch fully in a camera's view".

In the viewport, I have a free camera ($Camera01) and a set of objects. Given a 2D bitmap image as an input (of certain width and height), I would like to "place" the image as the "background" of $Camera01, meaning:
1. Create a plane and assign its material properties to use the image file, let's named it $Plane01. Hence $Plane01 defines the image object.
2. Transform $Plane01 according to $Camera01 using $Plane01.transform = $Camera01.transform (now $Plane01 has the same position, orientation as $Camera01)
3. To move (and possibly rotate) $Plane01 to fit the entire view of $Camera01, i.e. how can I calculate: how far I should move $Plane01 backwards (according to some properties, maybe the $Camera01's fov or range, which I have no clue of. Logically, it must be something related to $Camera01.fov and its range. My intuition is to align the 4 corners of $Plane01 (x,y,width,height) with the 4 points of the $Camera01.fov. but I don't know how that can be performed).

What I expect after Step 3 is when I set my view to $Camera01, I still see all of the existing objects, but now with the image as the background.

Note that: the output I'm looking for is similar to when setting the image as background map under the "Rendering -> Environment Map" section and render it. But my interest is not the rendering output. Rather, I am interested in information about the $Plane01 properties, such as $Plane01.pos, $Plane01.transform for further processing.

Thank you in advance.

Sincerely,
Wilson

wideLego
03-27-2009, 04:32 PM
Hi everyone,

Grant has replied to my problem. The solution is here http://www.scriptspot.com/3ds-max/camera-plane-maya-style.

Now I am facing another maxscript problem:

Given a camera $Camera01 and an arbitrary object, say $Box1 with (width, height, and depth), I would like to create a pyramid in which its base touches one of the $Box1 face, say the width and height; while the peak of the pyramid touches the $Camera01.pos. In a sense, the output will look like the camera is highlighting the object.

Does anyone knows the solution to this? Thank you in advance.

Sincerely,
Wilson

PiXeL_MoNKeY
03-27-2009, 05:17 PM
Martin Briedt also has a script object that does what you want with the camera. You can find it on his script site here (http://scripts.breidt.net/#imagePlane). I believe his viewFrustum (http://scripts.breidt.net/#viewFrustrum) script will address you other request.

-Eric

CGTalk Moderation
03-27-2009, 05:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.