joseph.howell Posted April 26, 2016 Share Posted April 26, 2016 Hi, I'm trying to implement ObjectGui + WidgetSpriteVideo in C++, following the example in gui_00. So far, nothing shows up. Here's my initialization code: objectGui = ObjectGui::create(20.0f, 15.0f); objectGui->setTransform(Mat4(translate(0.0f, 0.0f, 8.0f) * rotateY(90.0f) * rotateZ(90.0f))); objectGui->setMaterial(lookupId.c_str(), "*"); objectGui->setProperty("surface_base", "*"); objectGui->setMaterialState("mode", 1, 0); GuiPtr gui = objectGui->getGui(); sprite_video = WidgetSpriteVideo::create(gui, "resources/data/sanctuary.ogv"); gui->addChild(sprite_video->getWidget(), Gui::ALIGN_EXPAND); sprite_video->setVideoTime(0.0f); sprite_vide->play(); If I replace my gui pointer with the regular GUI, then it works as expected and I can see the video playing, but it takes up the whole screen. //replace this one line and it works on the whole screen gui GuiPtr gui = Gui::get(); //objectGui->getGui(); So it's like I can't see the ObjectGui I created. Even though I know my camera is at the origin when I start up, and it should be putting that ObjectGui around the origin too. I have flown around, trying different camera angles just in case the ObjectGui was back-facing. It doesn't show up from any angle. Suggestions? Thanks Link to comment
joseph.howell Posted April 26, 2016 Author Share Posted April 26, 2016 I put nearly identical code in my script file (but adapted to UnigineScript of course) and it works... does ObjectGui only work from script? -- Update -- I also got ObjectGui working with WidgetSprite in C++. For some reason, I just can't get WidgetSpriteVideo working. But it looks like I can use WidgetSprite for my needs. Link to comment
maxi Posted April 27, 2016 Share Posted April 27, 2016 Hi Joseph, I've just tested this in c++ and it is working fine, here is code sample: objectGui = ObjectGui::create(20.0f, 15.0f); objectGui->setTransform(Mat4(translate(0.0f, 0.0f, 8.0f) * rotateY(90.0f) * rotateZ(90.0f))); objectGui->setMaterial("gui_base", "*"); objectGui->setProperty("surface_base", "*"); objectGui->setMaterialState("mode", 1, 0); GuiPtr gui = objectGui->getGui(); sprite_video = WidgetSpriteVideo::create(gui, "data/unigine.ogv"); gui->addChild(sprite_video->getWidget(), Gui::ALIGN_EXPAND); sprite_video->setVideoTime(0.0f); sprite_video->play(); From your code I would check, if object gui's material in lookupId variable is derived from gui_base ? Link to comment
joseph.howell Posted April 27, 2016 Author Share Posted April 27, 2016 The only thing I see different is the "gui_base" for the material. The lookup id value was for a material I derived from "mesh_base", maybe that was the problem. I'll try making that change when I get the chance, But for now, the WidgetSprite is doing what I need. I'm streaming video from a webcam, so I need to update the image in the WidgetSprite each frame. So I don't think WidgetSpriteVideo is the right fit for me. Thanks Link to comment
Recommended Posts