Vp object add: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Sleepy E (talk | contribs)
mNo edit summary
Sleepy E (talk | contribs)
Add example, some information on attributes
Line 2: Line 2:
|parameters=
|parameters=
|attributes=
|attributes=
   {{sdk attribute row|int    |OBJECT_TYPE           |Type of object}}
   {{sdk attribute row|int    |object_type           |Type of object (0 - 3D Model, 2 - Particle emitter, 3 - Path object) }}
   {{sdk attribute row|float  |OBJECT_X             |X coordinate}}
   {{sdk attribute row|float  |object_x             |X coordinate}}
   {{sdk attribute row|float  |OBJECT_Y             |Y coordinate}}
   {{sdk attribute row|float  |object_y             |Y coordinate}}
   {{sdk attribute row|float  |OBJECT_Z             |Z coordinate}}
   {{sdk attribute row|float  |object_z             |Z coordinate}}
   {{sdk attribute row|float  |OBJECT_ROTATION_X     |Rotation axis X}}
   {{sdk attribute row|float  |object_rotation_x     |Rotation X axis}}
   {{sdk attribute row|float  |OBJECT_ROTATION_Y     |Rotation axis Y}}
   {{sdk attribute row|float  |object_rotation_y     |Rotation Y axis}}
   {{sdk attribute row|float  |OBJECT_ROTATION_Z     |Rotation axis Z}}
   {{sdk attribute row|float  |object_rotation_z     |Rotation Z axis}}
   {{sdk attribute row|float  |OBJECT_ROTATION_ANGLE |Rotation angle}}
  {{sdk attribute row|float  |object_rotation_angle |Rotation angle in radians}}
   {{sdk attribute row|string |OBJECT_MODEL         |Model}}
  {{sdk attribute row|float  |object_yaw            |Yaw angle in degrees (these are used instead of X,Y,Z axis when rotation angle is set to INFINITE)}}
   {{sdk attribute row|string |OBJECT_ACTION         |Action}}
  {{sdk attribute row|float  |object_pitch          |Pitch angle in degrees}}
   {{sdk attribute row|string |OBJECT_DESCRIPTION   |Description}}
   {{sdk attribute row|float  |object_roll          |Roll angle in degrees}}
   {{sdk attribute row|data  |OBJECT_DATA           |Data}}
   {{sdk attribute row|string |object_model         |Model}}
   {{sdk attribute row|string |object_action         |Action}}
   {{sdk attribute row|string |object_description   |Description}}
   {{sdk attribute row|data  |object_data           |Data}}
|returncodes=
|returncodes=
   {{sdk return code row|NOT_IN_WORLD |Bot is not currently in a world}}
   {{sdk return code row|not_in_world|Bot is not currently in a world}}
|returnattributes=
|returnattributes=
   {{sdk attribute row|int|OBJECT_ID|Object id}}
   {{sdk attribute row|int|object_id|Object id that was assigned to the new object}}
|behavior=
|behavior=
* Upon successful creation of an object, {{sdk event|OBJECT}} is triggered for those who have subscribed to it.
* Upon successful creation of an object, {{sdk event|OBJECT}} is triggered for those who have subscribed to it.
|caveats=
|caveats=
|examples=
|examples=
Build a street1.rwx object at 0X 0Y 0Z.
<syntaxhighlight lang="c">
void handle_object_add(VPInstance sdk, int rc, int ref)
{
  if (rc)
    printf("Couldn't build object (reason %d)\n", rc);
  else
    printf("Object built successfully!\n");
}
int main(int argc, const char* argv[])
{
  //...
 
  vp_callback_set(sdk, VP_CALLBACK_OBJECT_ADD, handle_object_add);
  vp_int_set(sdk, VP_OBJECT_TYPE, 0); // 3D Model
  vp_float_set(sdk, VP_OBJECT_X, 0.0);
  vp_float_set(sdk, VP_OBJECT_Y, 0.0);
  vp_float_set(sdk, VP_OBJECT_Z, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_X, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_Y, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_Z, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_ANGLE, 0.0);
  vp_string_set(sdk, VP_OBJECT_MODEL, "street1.rwx");
  vp_string_set(sdk, VP_OBJECT_ACTION, "");
  vp_string_set(sdk, VP_OBJECT_DESCRIPTION, "");
  rc = vp_object_add(sdk);
  if (rc)
    printf("Couldn't build object (reason %d)\n", rc);
  //...
}
</syntaxhighlight>
|seealso=
|seealso=
* {{sdk method|object_change}}
* {{sdk method|object_change}}
* {{sdk method|object_delete}}
* {{sdk method|object_delete}}
* {{sdk callback|OBJECT_ADD}}
* {{sdk callback|object_add}}
}}
}}

Revision as of 21:55, 16 December 2016

Method call snippet vp_object_add(instance);

Build a new object.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for

Used attributes

This method uses data set in these attributes when called:

Attribute Usage
VP_OBJECT_TYPE Type of object (0 - 3D Model, 2 - Particle emitter, 3 - Path object)
VP_OBJECT_X X coordinate
VP_OBJECT_Y Y coordinate
VP_OBJECT_Z Z coordinate
VP_OBJECT_ROTATION_X Rotation X axis
VP_OBJECT_ROTATION_Y Rotation Y axis
VP_OBJECT_ROTATION_Z Rotation Z axis
VP_OBJECT_ROTATION_ANGLE Rotation angle in radians
VP_OBJECT_YAW Yaw angle in degrees (these are used instead of X,Y,Z axis when rotation angle is set to INFINITE)
VP_OBJECT_PITCH Pitch angle in degrees
VP_OBJECT_ROLL Roll angle in degrees
VP_OBJECT_MODEL Model
VP_OBJECT_ACTION Action
VP_OBJECT_DESCRIPTION Description
VP_OBJECT_DATA Data

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)
VP_RC_NOT_IN_WORLD Bot is not currently in a world

The following attributes will be returned in VP_CALLBACK_OBJECT_ADD if the operation was successful:

Attribute Usage Also returned for
VP_OBJECT_ID Object id that was assigned to the new object

Behavior

  • Upon successful creation of an object, VP_EVENT_OBJECT is triggered for those who have subscribed to it.

Examples

Build a street1.rwx object at 0X 0Y 0Z.

void handle_object_add(VPInstance sdk, int rc, int ref)
{
  if (rc)
    printf("Couldn't build object (reason %d)\n", rc);
  else
    printf("Object built successfully!\n");
}

int main(int argc, const char* argv[])
{
  //...
  
  vp_callback_set(sdk, VP_CALLBACK_OBJECT_ADD, handle_object_add);

  vp_int_set(sdk, VP_OBJECT_TYPE, 0); // 3D Model
  vp_float_set(sdk, VP_OBJECT_X, 0.0);
  vp_float_set(sdk, VP_OBJECT_Y, 0.0);
  vp_float_set(sdk, VP_OBJECT_Z, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_X, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_Y, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_Z, 0.0);
  vp_float_set(sdk, VP_OBJECT_ROTATION_ANGLE, 0.0);
  vp_string_set(sdk, VP_OBJECT_MODEL, "street1.rwx");
  vp_string_set(sdk, VP_OBJECT_ACTION, "");
  vp_string_set(sdk, VP_OBJECT_DESCRIPTION, "");
	
  rc = vp_object_add(sdk);
  if (rc)
    printf("Couldn't build object (reason %d)\n", rc);

  //...
}

See also