camid cam_get_camera(uint idx) { if(idx >= Cameras.size()) return camid(); return camid(idx, Cameras[idx]->get_signature()); }
/** * Looks up camera by name, returns -1 on failure */ camid cam_lookup(char *name) { size_t i, size=Cameras.size(); for(i = 0; i < size; i++) { if(Cameras[i] != NULL && !stricmp(Cameras[i]->get_name(), name)) return camid(i, Cameras[i]->get_signature()); } return camid(); }
camid cam_create(char *n_name, vec3d *n_pos, matrix *n_ori, object *n_object, int n_object_host_submodel) { camera *cam = NULL; camid cid; //Get signature int sig = cam_get_next_sig(); //Get name char buf[NAME_LENGTH] = {'\0'}; if(n_name == NULL) sprintf(buf, "Camera %d", cid.getSignature()); else strncpy(buf, n_name, NAME_LENGTH-1); //Find a free slot cam = new camera(buf, sig); cid = camid(Cameras.size(), sig); Cameras.push_back(cam); //Set attributes if(n_pos != NULL) cam->set_position(n_pos); if(n_ori != NULL) cam->set_rotation(n_ori); if(n_object != NULL) cam->set_object_host(n_object, n_object_host_submodel); return cid; }
camera::~camera() { //Check if this is in use if(Current_camera.getSignature() == this->sig) { Current_camera = camid(); } }
void cam_close() { //Set Current_camera to nothing Current_camera = camid(); for (auto ii = Cameras.begin(); ii != Cameras.end(); ++ii) { delete * ii; } Cameras.clear(); }
void cam_close() { //Set Current_camera to nothing Current_camera = camid(); Cameras.clear(); }
camid game_render_frame_setup(){return camid();}