VPSDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VP.h
Go to the documentation of this file.
1 #ifndef __VP_SDK
2 #define __VP_SDK
3 
4 #if defined(WIN32) || defined(UNDER_CE)
5 # ifdef VPSDK_EXPORTS
6 # ifdef VPSDK_STATIC
7 # define VPSDK_API extern "C"
8 # else
9 # define VPSDK_API extern "C" __declspec(dllexport)
10 # endif
11 # else
12 # ifdef __cplusplus
13 # ifdef VPSDK_STATIC
14 # define VPSDK_API extern "C"
15 # else
16 # define VPSDK_API extern "C" __declspec(dllimport)
17 # endif
18 # else
19 # ifdef VPSDK_STATIC
20 # define VPSDK_API extern
21 # else
22 # define VPSDK_API __declspec(dllimport)
23 # endif
24 # endif
25 # endif
26 #else
27 # if defined(VPSDK_EXPORTS) && (__GNUC__ >= 4)
28 # ifdef __cplusplus
29 # define VPSDK_API extern "C" __attribute__ ((visibility ("default")))
30 # else
31 # define VPSDK_API extern __attribute__ ((visibility ("default")))
32 # endif
33 # else
34 # ifdef __cplusplus
35 # define VPSDK_API extern "C"
36 # else
37 # define VPSDK_API extern
38 # endif
39 # endif
40 #endif
41 
42 /* API Version */
43 #define VPSDK_VERSION 2
44 
48 typedef enum vp_event_t
49 {
135 
144 
155 
165 
172 
178 
180 
186 
192 
203 
210 
221 
231 
243 
251 
258 
265 
267 } vp_event_t;
268 
269 typedef enum vp_callback_t
270 {
288 
315 } vp_callback_t;
316 
317 /* Ints */
318 typedef enum vp_int_attribute_t
319 {
323 
328 
331 
334 
339 
343 
347 
350 
356 
358 
364 
366 
370 
373 
374 /* Floats */
376 {
382 
388 
411 
417 
421 
424 
425 /* Strings */
427 {
430 
434 
436 
439 
442 
445 
447 
449 
452 
453 /* Data */
455 {
460 
464 typedef enum vp_proxy_type_t {
468 
469 typedef enum vp_url_target_t {
473 
474 #ifdef __cplusplus
475 namespace vpsdk {
476  struct VPInstance_;
477 }
478 
479 typedef vpsdk::VPInstance_ *vp_instance_t;
480 #else
481 typedef void* vp_instance_t;
482 #endif
483 
485 
486 typedef void(*VPEventHandler)(VPInstance);
487 typedef void(*VPCallbackHandler)(VPInstance, int, int);
488 
489 typedef struct vp_terrain_cell_t {
490  float height;
491 
492  /* 1 bit visibility, 2 bits rotation, 1 bit padding, 12 bits texture */
493  unsigned short attributes;
495 
496 #define VP_PACK_TERRAIN_ATTRIBUTES(tex, rotation, visible) ((tex & 0x1FFF) | \
497  (visible << 15) | \
498  (rotation << 13))
499 
500 #define VP_UNPACK_TERRAIN_VISIBILITY(x) ((x & 0x8000) >> 15)
501 #define VP_UNPACK_TERRAIN_ROTATION(x) ((x & 0x6000) >> 13)
502 #define VP_UNPACK_TERRAIN_TEXTURE(x) (x & 0x0FFF)
503 
511 };
512 
519 };
520 
529 #ifdef __cplusplus
530 VPSDK_API int vp_init(int version=VPSDK_VERSION);
531 #else
532 VPSDK_API int vp_init(int version);
533 #endif
534 
540 
544 VPSDK_API int vp_destroy(VPInstance instance);
545 
553 VPSDK_API int vp_connect_universe(VPInstance instance, const char * host, int port);
554 
567 VPSDK_API int vp_login(VPInstance instance, const char * username, const char * password, const char * botname);
568 
576 VPSDK_API int vp_wait(VPInstance instance, int milliseconds);
577 
589 VPSDK_API int vp_enter(VPInstance instance, const char * worldname);
590 
596 VPSDK_API int vp_leave(VPInstance instance);
597 
605 VPSDK_API int vp_say(VPInstance instance, const char * message);
606 
621  int session,
622  const char* name,
623  const char* message,
624  int effects,
625  unsigned char red,
626  unsigned char green,
627  unsigned char blue);
628 
633 VPSDK_API int vp_event_set(VPInstance instance, vp_event_t eventname, VPEventHandler event);
634 
639 VPSDK_API int vp_callback_set(VPInstance instance, vp_callback_t callbackname, VPCallbackHandler callback);
640 
645 VPSDK_API void * vp_user_data(VPInstance instance);
646 
652 VPSDK_API void vp_user_data_set(VPInstance instance, void * data);
653 
667 VPSDK_API int vp_state_change(VPInstance instance);
668 
669 VPSDK_API int vp_int(VPInstance instance, vp_int_attribute_t name);
670 VPSDK_API float vp_float(VPInstance instance, vp_float_attribute_t name);
671 VPSDK_API const char* vp_string(VPInstance instance, vp_string_attribute_t name);
672 VPSDK_API const char* vp_data(VPInstance instance, vp_data_attribute_t name, int* length);
673 
674 VPSDK_API int vp_int_get(VPInstance instance, vp_int_attribute_t name, int* value);
675 VPSDK_API int vp_float_get(VPInstance instance, vp_float_attribute_t name, float* value);
676 VPSDK_API int vp_string_get(VPInstance instance, vp_string_attribute_t name, char** value);
677 
678 VPSDK_API int vp_int_set(VPInstance instance, vp_int_attribute_t name, int value);
679 VPSDK_API int vp_float_set(VPInstance instance, vp_float_attribute_t name, float value);
680 VPSDK_API void vp_string_set(VPInstance instance, vp_string_attribute_t name, const char * str);
681 VPSDK_API int vp_data_set(VPInstance instance, vp_data_attribute_t name, int length, char* data);
682 
688 VPSDK_API int vp_query_cell(VPInstance instance, int x, int z);
689 
707 VPSDK_API int vp_object_add(VPInstance instance);
708 
715  int object_id, int session_to);
716 
723  int object_id, int session_to);
724 
744 
753 VPSDK_API int vp_object_click(VPInstance instance, int object_id,
754  int session_to, float hit_x,
755  float hit_y, float hit_z);
756 
761 VPSDK_API int vp_object_delete(VPInstance instance, int object_id);
762 
767 VPSDK_API int vp_object_get(VPInstance instance, int object_id);
768 
774 VPSDK_API int vp_world_list(VPInstance instance, int time);
775 
776 /* VPSDK_API void* vp_callback_pointer(VPInstance instance); */
777 /* VPSDK_API void vp_callback_pointer_set(VPInstance instance, void* ptr); */
778 
784 VPSDK_API int vp_user_attributes_by_id(VPInstance instance, int user_id);
785 
790 VPSDK_API int vp_user_attributes_by_name(VPInstance instance, const char * name);
791 
792 VPSDK_API int vp_friends_get(VPInstance instance);
793 VPSDK_API int vp_friend_add_by_name(VPInstance instance, const char* name);
794 VPSDK_API int vp_friend_delete(VPInstance instance, int friend_id);
795 
804 VPSDK_API int vp_terrain_query(VPInstance instance, int tile_x, int tile_z, int revision[][4]);
805 
817  int tile_x, int tile_z,
818  int node_x, int node_z,
819  struct vp_terrain_cell_t* cells);
820 
832 VPSDK_API int vp_avatar_click(VPInstance instance, int avatar_session);
833 
845  int target_session,
846  const char* world,
847  float x, float y, float z,
848  float yaw, float pitch);
849 
856 VPSDK_API int vp_url_send(VPInstance instance,
857  int session_id,
858  const char* url,
859  vp_url_target_t url_target);
860 
861 #endif