Aw camera set

From ActiveWiki
Jump to navigation Jump to search


Minimum requirements
Added in version 4.1
SDKbuild 53


int aw_camera_set (int session_id)

Description

Sets the camera view in a browser.

Callback

None (returns immediately)

Notes

The Active Worlds Browser's camera is set to a location defined by the AW_CAMERA_LOCATION_* attributes, the camera target is set by AW_CAMERA_TARGET_* attributes.

The camera location and target must be within visible range in order to render the camera in world correctly.

Only world server administration instances or those owned by a caretaker (i.e. aw_bool (AW_WORLD_CARETAKER_CAPABILITY) returns 1) may use this method.

Arguments

session_id
Session number (must correspond to that of a browser).

Argument attributes

AW_CAMERA_LOCATION_TYPE
AW_CAMERA_LOCATION_SESSION
AW_CAMERA_LOCATION_OBJECT
AW_CAMERA_TARGET_TYPE
AW_CAMERA_TARGET_SESSION
AW_CAMERA_TARGET_OBJECT

Possible camera types are:

AW_CAMERA_TRACK_DEFAULT
Camera not bot controlled. If used for either location or target then it will reset a previously defined camera. Same as setting AW_CAMERA_LOCATION_TYPE to AW_CAMERA_TRACK_AVATAR and AW_CAMERA_TARGET_TYPE to AW_CAMERA_TRACK_AHEAD.
AW_CAMERA_TRACK_AVATAR
Camera is the avatar with session number AW_CAMERA_*_SESSION.
AW_CAMERA_TRACK_OBJECT
Camera is an object with "create name <string>" in its action. Where <string> is the string in AW_CAMERA_*_OBJECT.
AW_CAMERA_TRACK_AHEAD
Camera is following target avatar at shoulder-height. Note, only possible to use this for the target.

Return values

RC_SUCCESS
RC_NOT_INITIALIZED
RC_NO_INSTANCE
RC_NO_CONNECTION
The connection to the world is down.

Returned attributes

None

Usage

void view_from_object(int session_id, char *object_name)
{
  int rc;
  
  /* place the camera at the object with the specified name */
  aw_int_set (AW_CAMERA_LOCATION_TYPE, AW_CAMERA_TRACK_OBJECT);
  aw_int_set (AW_CAMERA_LOCATION_SESSION, 0);
  aw_string_set (AW_CAMERA_LOCATION_OBJECT, object_name);
  
  /* camera will be tracking an avatar with the given session id */
  aw_int_set (AW_CAMERA_TARGET_TYPE, AW_CAMERA_TRACK_AVATAR);
  aw_int_set (AW_CAMERA_TARGET_SESSION, session_id);
  aw_string_set (AW_CAMERA_TARGET_OBJECT, "");
  
  rc = aw_camera_set (session_id);
  if (rc != RC_SUCCESS)
    printf ("Unable to set camera for session %d (reason %d)\n", session, rc);
}

/* make the browser with session number 1443 view its own avatar from the origin
   of an object with "create name Cam1" in its action field */
view_from_object(1443, "Cam1");

See also