Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function<void(string &)> find_marker_response = [](string &data)
- {
- string err, image, guid;
- bool group = false;
- json11::Json marker = json11::Json::parse(data, err);
- image = marker["image"].string_value();
- guid = marker["marker_id"].string_value();
- if (!marker["group"].is_null())
- group = marker["group"].bool_value();
- if (markers.getRID(guid) != -1 /*&& markers.beenLoaded(guid)*/)
- {
- return;
- }
- FILE *out = fopen((WorkPath + "/Augment/" + guid).c_str(), "wb");
- if (!out)
- {
- return;
- }
- loading = true;
- string img = WebUtil::base64_decode(image);
- fwrite(img.data(), img.size(), sizeof(char), out);
- fclose(out);
- int id;
- easyar::Vec2F sz;
- auto target = loadFromImage(trackers[0], (WorkPath + "/Augment/" + guid), guid, sz);
- markers.addMarkerInfo(guid, target, target->runtimeID(), group);
- remove((WorkPath + "/Augment/" + guid).c_str());
- if (!scene.GetSceneObject(guid).empty())
- {
- loading = false;
- return;
- }
- LoadingEffect* effect = new LoadingEffect;
- effect->setRectSize(sz.data[0], sz.data[1]);
- effect->enableEffect();
- scene.AddObject(effect, guid);
- net.GetMarkerResources(guid, [&](json11::Json &in)
- {
- MarkerInfo.addInfo(guid, guid, in["likes"].int_value(), in["liked"].bool_value());
- auto arr = in["resources"].array_items();
- for (int i = 0; i < arr.size(); i++)
- {
- if (arr[i]["type"].string_value() == "contact")
- {
- string contact;
- net.GetContact(arr[i]["id"].string_value(), contact);
- ContactManager.addContact(guid, contact);
- }
- if (arr[i]["type"].string_value() == "document")
- {
- ContactManager.addDocument(guid, arr[i]["name"].string_value(), arr[i]["id"].string_value());
- }
- if (arr[i]["type"].string_value() == "video")
- {
- VideoRect* resource = new VideoRect;
- resource->SetRectSize(sz.data[0], sz.data[1]);
- scene.AddObject(resource, guid);
- std::string mask_img = "";
- if (!arr[i]["mask"].is_null())
- {
- mask_img = WebUtil::base64_decode(arr[i]["mask"].string_value());
- }
- resource->SetupVideoSource(net.GetAddres() + ":3005/video/" + arr[i]["id"].string_value(), mask_img);
- //resource->SetupVideoSource("http://192.168.88.253:8080/video/mjpeg", mask_img);
- //resource->SetupVideoSource(net.GetAddres() + "/video/" + arr[i]["id"].string_value());
- VideoManager.add_player(&resource->player);
- }
- if (arr[i]["type"].string_value() == "audio")
- {
- AudioSource* resource = new AudioSource;
- scene.AddObject(resource, guid);
- resource->SetupAudioSource(net.GetAddres() + ":3005/audio/" + arr[i]["id"].string_value());
- VideoManager.add_player(&resource->player);
- }
- if (arr[i]["type"].string_value() == "model")
- {
- map<string, CTexture*> textures;
- Mesh *m = new Mesh;
- vector<json11::Json> pos, rot, scl;
- json11::Json trs = arr[i]["position"];
- if (!trs.is_null())
- {
- pos = trs["translation"].array_items();
- rot = trs["rotation"].array_items();
- scl = trs["scale"].array_items();
- }
- else
- {
- pos = arr[i]["translation"].array_items();
- rot = arr[i]["rotation"].array_items();
- scl = arr[i]["scale"].array_items();
- }
- json11::Json j;
- net.GetModel(arr[i]["id"].string_value(), j);
- //m->SetBaseScale(scl[0].number_value()*0.175, scl[1].number_value()*0.175, scl[2].number_value()*0.175);
- m->SetBaseScale(-scl[0].number_value(), scl[1].number_value(), scl[2].number_value());
- string decoded = WebUtil::base64_decode(j["model"].string_value());
- auto tex = j["files"].array_items();
- for (int j = 0; j < tex.size(); j++)
- {
- string data = WebUtil::base64_decode(tex[j]["file"].string_value());
- textures[tex[j]["name"].string_value()] = new CTexture;
- textures[tex[j]["name"].string_value()]->loadTexture2DDeffered((unsigned char*)&data[0], (int)data.size(), true, 0);
- }
- m->LoadFromMemory(decoded, textures);
- scene.AddObject(m, guid);
- }
- }
- });
- effect->disableEffect();
- loading = false;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement