kai.xia Posted December 1, 2014 Posted December 1, 2014 Hello, I want to create a new camera (may use Player or PlayerDummy) to render part of scene to a texture, and show it on the gui or something like meshobject. I had used to script to archive the request partially by WidgetSpriteViewport and ObjectGui, but I have no idea how to use these two class in C++ API that are not exist in sdk, and I also want to get render texture for manipulating directly. Please give some suggestions, thanks!
unclebob Posted December 1, 2014 Posted December 1, 2014 Hello Xia! We don't have WidgetSpriteViewport in the C++ API yet we have ObjectGui and ObjectGuiMesh in it. In C++ it's possible to create TextureRender (https://developer.unigine.com/en/docs/1.0/cpp_api/reference/api_texturerender_class) instance if you want to get access to render textures. After that you can bind it and render scene via Render::renderViewport. You can access texture data only by copying it from GPU to CPU, you'll get its data as an Image class instance. Then just apply your changes and copy it back to GPU. And yes, its slow. I will be able to provide additional help to you if you give me more information about what you're trying to achieve. Also, please look at AppPanorama source code in C++ as it contains both TextureRender and Render::renderViewport usage.
Recommended Posts