PDA

View Full Version : Get/Set Camera Position From C++


wegnif
17th February 2011, 02:15 PM
How do I get the position of the 3D camera from the PlugIn interface? I want to programmatically generate screenshots at different positions and orientations.

I've tried ac_object_get_centre(ac_views_get_default_camera() ), and it gives the position of something, but it doesn't seem to change as I move the 3D view around.

Once I get the position, how can I move the camera? ac_camera_move_forward() doesn't seem to do anything either.

Andy
18th February 2011, 04:42 AM
Almost, but the camera is not an ACObject.but an ACEntity.

Once you have the ACCamera from ac_views_get_default_camera(),
you should be able to use the ac_entity_set/get* functions to set/get the values. (origin (Point3), location (Point3), rotation (Point3), spin (Point3), scale (float), move_dist (float), move_angle (float), walk_vehicle (Boolean), offset (Point3), fov (float))

The ac_camera_move_* functions should work fine although you may need to redraw the view after(?) You must ensure that it's in walk mode for many of the functions to work, since they don't make sense in spin mode.

You may also find that a lot of this can be done from a script too. You can also call tcl_command(char *) with a script command inside your plugin.

wegnif
18th February 2011, 10:44 AM
Thanks Andy, that did it!

wegnif
15th March 2011, 11:59 AM
It seems that 'direction' is also one of the values that can be set.

wegnif
29th June 2011, 12:24 PM
Is there a way in Walk mode to change the camera's roll angle? I've tried the rotation and spin properties and they don't seem to have any effect.

Andy
30th June 2011, 06:07 AM
Sorry, no, 'up' is fixed.

jmaida
2nd October 2011, 10:13 PM
This has nothing to do with get/setting camera (but that was useful information). I just using this thread to get this question out. How is the URL used in the object property entry? I mean I enter URL, but so what. I can't see how it is acted on by anything in AC3D or by the object.