Aw laser beam

From ActiveWiki
Jump to: navigation, search


Minimum requirements
Added in version 5.0
SDKbuild 85


int aw_laser_beam ()

Description

Display a laser beam to neighbors in world.

Callback

None (returns immediately)

Event

AW_EVENT_LASER_BEAM

Notes

This method will trigger AW_EVENT_LASER_BEAM for all neighbors, provided that they are subscribing to the event.

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.

The laser beam is only drawn, if the target coordinates are within the view frustum.

The laser beam target texture from the default/texture subfolder is only drawn if the target coordinate is not covered by other objects.

Each avatar session can draw a single laser beam at a time.

The source session id must exist.

The source coordinates are currently not used, and should be set to 0 (zero).

The target coordinates are mandatory.

The target session id is not used by the browser as such, and is currently just informatical.

The use of attributes and their meaning may change and/or may be extended the future.

Arguments

None

Argument attributes

AW_LASER_BEAM_SOURCE_TYPE (enum)

supported only: AW_LASER_BEAM_SOURCE_TYPE_AVATAR

AW_LASER_BEAM_SOURCE_ID (int)

must be the session id of the source location, if AW_LASER_BEAM_SOURCE_TYPE_AVATAR was used

AW_LASER_BEAM_SOURCE_X (int)

0, begin coordinate X in centimeters, not used, reserved

AW_LASER_BEAM_SOURCE_Y (int)

0, begin coordinate Y in centimeters, not used, reserved

AW_LASER_BEAM_SOURCE_Z (int)

0, begin coordinate Z in centimeters, not used, reserved

AW_LASER_BEAM_TARGET_TYPE (enum)

supported only: AW_LASER_BEAM_TARGET_TYPE_COORDS, AW_LASER_BEAM_TARGET_TYPE_NONE

AW_LASER_BEAM_TARGET_ID (int)

0, optional the session id of the target location if an avatar (see notes)

AW_LASER_BEAM_TARGET_X (int)

end coordinate X in centimeters

AW_LASER_BEAM_TARGET_Y (int)

end coordinate Y in centimeters

AW_LASER_BEAM_TARGET_Z (int)

end coordinate Z in centimeters

AW_LASER_BEAM_STYLE (enum)

supported only: AW_LASER_BEAM_STYLE_LINE

AW_LASER_BEAM_COLOR (ARGB32 - int)

color of the laser beam line

AW_LASER_BEAM_DEFINITION (char/wchar)

don't use, reserved.

Return values

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

Returned attributes

None

Usage

// inform neighbors that beam is on or has changed
// Line is a pair of 3d vectors, not described here
// line is used for specifying the target coordinate in world
// the unit used with line is 1 meter
int beam_on (Line& line)
{
  aw_int_set (AW_LASER_BEAM_SOURCE_TYPE, AW_LASER_BEAM_SOURCE_TYPE_AVATAR);
  aw_int_set (AW_LASER_BEAM_SOURCE_ID, aw_session ()); // mandatory
  aw_int_set (AW_LASER_BEAM_SOURCE_X, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_SOURCE_Y, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_SOURCE_Z, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_TARGET_TYPE, AW_LASER_BEAM_TARGET_TYPE_COORDS);
  aw_int_set (AW_LASER_BEAM_TARGET_ID, 0);
  aw_int_set (AW_LASER_BEAM_TARGET_X, (int)floorf(line.end.x * 100.0f));
  aw_int_set (AW_LASER_BEAM_TARGET_Y, (int)floorf(line.end.y * 100.0f));
  aw_int_set (AW_LASER_BEAM_TARGET_Z, (int)floorf(line.end.z * 100.0f));
  aw_int_set (AW_LASER_BEAM_STYLE, AW_LASER_BEAM_STYLE_LINE);
  aw_int_set (AW_LASER_BEAM_COLOR, 0xffff0000); // opaque, red
  aw_string_set (AW_LASER_BEAM_DEFINITION, NULL);  // must be NULL, reserved
  return aw_laser_beam ();
}
// inform neighbors that beam is off
int beam_off ()
{
  aw_int_set (AW_LASER_BEAM_SOURCE_TYPE, AW_LASER_BEAM_SOURCE_TYPE_NONE);
  aw_int_set (AW_LASER_BEAM_SOURCE_ID, aw_session ()); // mandatory
  aw_int_set (AW_LASER_BEAM_SOURCE_X, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_SOURCE_Y, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_SOURCE_Z, 0); // must be 0 (zero), reserved
  aw_int_set (AW_LASER_BEAM_TARGET_TYPE, AW_LASER_BEAM_TARGET_TYPE_NONE);
  aw_int_set (AW_LASER_BEAM_TARGET_ID, 0);
  aw_int_set (AW_LASER_BEAM_TARGET_X, 0);
  aw_int_set (AW_LASER_BEAM_TARGET_Y, 0);
  aw_int_set (AW_LASER_BEAM_TARGET_Z, 0);
  aw_int_set (AW_LASER_BEAM_STYLE, AW_LASER_BEAM_STYLE_LINE);
  aw_int_set (AW_LASER_BEAM_COLOR, 0);
  aw_string_set (AW_LASER_BEAM_DEFINITION, NULL);  // must be NULL, reserved
  return aw_laser_beam ();

}

See also