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
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
