#include #include #include #include "Aw.h" /** * Creates and initializes a new camera structure. * * The initialized structure must be manually destroyed using free(). * The remaining fields of the camera are to be set by yourself. * * The value NULL may be specified for the camera name to indicate * that a name is not to be assigned. * * @param name String containing the camera's name. * @return An initialized aw_object_data_camera structure. */ aw_object_data_camera* new_camera(const char* name) { size_t nlen = (name == NULL)? 0 : strlen(name); size_t psiz = nlen + sizeof(aw_object_data_camera); aw_object_data_camera* cam = NULL; cam = (aw_object_data_camera*)malloc(psiz); memset(cam, 0, psiz); cam->name_len = (unsigned char)(nlen); if (nlen != 0) memcpy(cam->str_data, name, nlen); return cam; } /** * Prepares an initialized camera structure to be built in the world. * * After calling this function use either the aw_object_add or * aw_object_load SDK methods after setting additional attributes * defining the location, etc. * * @param cam The object to be built. */ void prepare_camera(const aw_object_data_camera* cam) { unsigned int psiz = 0; psiz = sizeof(aw_object_data_camera); psiz += cam->name_len; aw_string_set(AW_OBJECT_DESCRIPTION, ""); aw_string_set(AW_OBJECT_ACTION, ""); aw_int_set(AW_OBJECT_TYPE, AW_OBJECT_TYPE_CAMERA); aw_data_set(AW_OBJECT_DATA, (char*)(cam), psiz); }