Search the Community
Showing results for tags 'decalortho'.
-
[SOLVED] Problem of DecalOrtho changing Texture at runtime
aka3301 posted a topic in C++ Programming
While I changing Albedo texture at runtime, I got wrong projected image. But it was correct in Editor. Could anyone give advice? Thanks in advance. Here is my sample code Unigine SDK2.7.3 / 2.8.0 int AppWorldLogic::init() { // Write here code to be called on world initialization: initialize resources for your world scene during the world start. ImagePtr img = Image::create(); img->load("image/cat.png"); //img->save("image/test__4.png"); // save to file is ok Unigine::DecalOrthoPtr projector = DecalOrtho::cast(Editor::get()->getNodeByName("DecalOrtho")); MaterialPtr mat0 = projector->getMaterial(); TexturePtr frame_texture = Texture::create(); //img->convertToFormat(Image::FORMAT_RGB8); //frame_texture->create2D(img->getWidth(), img->getHeight(), Texture::FORMAT_RGBA8); frame_texture->create(img); int num = mat0->findTexture("albedo"); if (num != -1) mat0->setTexture(num, frame_texture); PlayerSpectatorPtr g_camera = Unigine::PlayerSpectator::cast(Unigine::Game::get()->getPlayer()); g_camera->setPosition(Vec3(1.0, 0, 100)); return 1; }