Find the location of a 2D image that can stretched in a camera's view
Hi everyone,
I have the following maxscript problem: "Find the location of a 2D image that can stretched 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,
Comments
Unless I'm misunderstanding
Unless I'm misunderstanding you this seems like something can could most likely be handled best w/o scripting at all. You can just use a linked xform modifier to link the verts of a spline or in my simple sample attached, the verts of a pyramid.
Using the mesh route you'll end up getting a distorted mesh if your camera moves too far. Best idea would be to use a renderable spline which would give you a constant width. If you really need the conical look, I'd suggest using linked xform on the spline thats instanced into a loft object. That should do the trick.
Thanks again Grant, For my
Thanks again Grant,
For my case, I would prefer it to be done with scripting, because I have lots of scenes and objects to be generated. For each scene I need to highlight 10-20 boxes (objects), and I have all the information about the objects and the cameras, so it is only connecting pyramids to the camera becomes the problem.
Or perhaps you have alternative suggestion on my problem. I am interested to generate output images of "a camera looking at several highlight objects, in this case boxes". My solution is to draw pyramids from the camera to the boxes
You're in luck - there's
You're in luck - there's already a script that does this called Camera Plane (Maya Style) -
http://www.scriptspot.com/3ds-max/camera-plane-maya-style
Christopher Grant
Thank you Grant for the
Thank you Grant for the reply. That is what I have been searching for :)
I have another question:
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 the sense, the output will look like the camera is looking at or highlighting the object.
Do you happen to know the solution? Thank you.
Sincerely,
Wilson
LookAt Constraint maybe help
LookAt Constraint maybe help you, but if you wish to use 3 cameras, then you will need also 3 planes, and only one visible at the same time. I do not know what you trying to achieve and why you complicate the things, and if dont like Environment Map for same reason, why you not to use sky-dom (hemisphere) instead of plane?
my recent MAXScripts RSS (archive here)