View Full Version : How to get a camera?
PerFnurt
6th March 2005, 06:49 AM
Scratching my head, can't figure out how to access the 3D view's camera using the plug-in SDK.
Assuming the approch would be like call ac_views_get_3d(), and query it's "camera" entity, but the camera is an entity of its own and there's no "ac_entity_get_entity" function.
Thanks
Andy
6th March 2005, 11:44 AM
We'll need to add the entity_get_entity function.
You should be able to use:
Prototype Boolean ac_entity_get_value(ACEntity *e, char *resname, char *restype, void *valaddr)
ACEntity *cam;
ac_entity_get_value(e, "camera", "entity", &cam)
Remember there may be more than one 3d window - get_default_camera will get the first 3d camera.
ACCamera *cam = ac_views_get_default_camera();
if (cam == NULL)
{
printf("no camera found (probably no 3d view available) - camera location is default");
...
}
else
{
ac_entity_get_point_value((ACEntity *)cam, "location", &loc);
ac_entity_get_point_value((ACEntity *)cam, "offset", &offset);
ac_entity_get_point_value((ACEntity *)cam, "direction", &vec);
ac_entity_get_float_value((ACEntity *)cam, "scale", &scale);
Point3 rotp;
ac_entity_get_point_value((ACEntity *)cam, "rotation", &rotp);
rotx = rotp.x;
roty = rotp.y;
ac_entity_get_float_value((ACEntity *)cam, "fov", &fov);
ac_entity_get_boolean_value((ACEntity *)cam, "walk_vehicle", &is_walk_vehicle);
PerFnurt
6th March 2005, 12:48 PM
Ah, didn't see that one. No real need for a entity_get_entity then, thanks.
Btw, ac_views_get_default_camera isn't available, its commented out.
No problem though, there's the ac_views_get_3d ( or I guess one could use ac_views_get_list and react on some type=6, right?).
Andy
6th March 2005, 03:15 PM
Strange :? I'm not sure why that's commented out. It's exported though so you should be able to put it back in.
The other methods you mentioned will also be fine.
Andy
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.