Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 6th March 2005, 06:49 AM   #1
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default How to get a camera?

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
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Old 6th March 2005, 11:44 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default

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.

Code:
	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);
Andy is offline   Reply With Quote
Old 6th March 2005, 12:48 PM   #3
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default

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?).
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Old 6th March 2005, 03:15 PM   #4
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default

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
Andy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 02:25 PM.


AC3D Forum
(C) Inivis Limited 2020