Notifications
Clear all

[Closed] Trouble getting ALL information about a cam

Really quick boring background (sorry)

I am taking a MaxScript class, and of course we have one of those obligatory assignments where we have to write a script that will generate a pretty/interesting scene using the random functions, etc… (this is not what I am having problems with)

The problem:

The issue is that my scene looks best from a certain angle, so I would like to add to the end of my script some code that will also generate a camera positioned and oriented in this specific way, so that my prof can simple run my script, pick the camera I also provide, and render, and I know she will be seeing the scene as I intend.

So using the perspective view, I aligned as I wanted, and then choose View>Create Camera From View. I was planning on then just using the listener window to get all the relevant info from this new camera($Camera01.position, rotation, fov…) and hardcode the creation of a camera with those values into my script.

But after doing so, I can’t seem to get at a few values that I think I need. I can access $Camera01.position as well as $Camera01.fov, but can’t seem to access .rotation, which being since a camera is a derived obj of Node, I thought I could get to and set. Further, .target returns a Point[3], but if I try to create a camera with a target it won’t take because apparently the target has to be a Node reference.

So I admit I am confused. I am hoping someone can tell me how to create a camera from a view, and then get at the nuts and bolts data (position, rotation/target, fov), which should be all I need, so that I can hardcode a camera with those values into my script.

Really sorry for the long-winded post, I appreciate any help someone can give to a rookie.

2 Replies

you could try using transforms instead…

create a camera and place it to your liking.
select the camara afterwards

foo = $.transform
foo_target = $.target.transform
– these should get your transforms for the camera and its target

now delete your camera and create a new one using this

the_cam = targetcamera()
the_cam.transform = foo
the_cam.target.transform = foo_target

i hope this helps!

Here is some code that does the same as the View>Create Camera From View, but using a simples, Free camera without a target:


 newCam = FreeCamera() --create new free camera
 newCam.transform = inverse (viewport.getTM())  --set the transform (PRS) to the viewport's ones
 newCam.FOV = viewport.getFOV() --set the FOV to match the view
 viewport.setCamera newCam --set the camera into the current viewport
 

Might be of help…

Cheers,
Bobo