sweetluna Posted February 22 Share Posted February 22 Hi bgyang, You could check out our C++ VR Template sample that already implements basic example of using Marker Objects in GuiSample.cpp class. But essentially you would do something like this: 1. Enable setMarkerTrackingEnabled 2. In update get number of currently active Markers with getMarkerObjectNum 3. Iterate through each of them with getMarkerObject Here a little code snippet from C++ VR Template that already object transformations and colors based on the size of the marker: // Note that app in this case is Varjo plugin's instance: Unigine::Plugins::Varjo::get() int num = app->getMarkerObjectNum(); if (num > 0) { Math::vec4 colors[3] = { Math::vec4_green, Math::vec4_blue, Math::vec4_red }; for (int i = 0; i < num; i++) { const auto &obj = app->getMarkerObject(i); Mat4 transform = obj.transform; Vec3 size = obj.size; size.y = (size.x + size.z) * 0.1f; // There are up to 3 supported marker sizes // - Small (up to 0.5m) // - Medium (up to 1m) // - Large (up to 3m) int index = Math::clamp((obj.id / 100) - 1, 0, 2); Scalar scale = Scalar(0.01 * (index + 1)); Visualizer::renderBox(vec3(size), transform, colors[index], 0.0f, false); Visualizer::renderDirection(transform.getTranslate(), vec3(transform.getAxisX() * scale), Math::vec4_red, 0.1f, false); Visualizer::renderDirection(transform.getTranslate(), vec3(transform.getAxisY() * scale), Math::vec4_green, 0.1f, false); Visualizer::renderDirection(transform.getTranslate(), vec3(transform.getAxisZ() * scale), Math::vec4_blue, 0.1f, false); } } I hope this will help. 1 May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
Recommended Posts