Lales.Charles Posted April 2, 2020 Share Posted April 2, 2020 Dear Unigine team, Could be simple question: how can I display 2d text at fix position like the CIGI info? Following documentation, I use Visualizer::renderMessage2D but I don't get position and center idea... and how to make then fix and not relative to screen size. Is there sample I haven't found? Subsidiary question: in this case, it is a Component displaying during update call.. correct? Wasn't there a COMPONENT_RENDER before..? Kind regards, Charles Link to comment
cash-metall Posted April 3, 2020 Share Posted April 3, 2020 This is WidgetLabel //in init: WidgetLabelPtr label = WidgetLabel::create(Gui::get()); label->setFontOutline(1); Gui::get()->addChild(label, Gui::ALIGN_BOTTOM | Gui::ALIGN_LEFT); //in update: label->setText(String::format("helloworld! %d\nhelloworld! %.2f\nhelloworld! \"%s\"", 1, 0.33333, "HI!")); 10 hours ago, Lales.Charles said: Wasn't there a COMPONENT_RENDER before..? ow it's called a post_update COMPONENT_POST_UPDATE(post_update); Link to comment
Lales.Charles Posted April 3, 2020 Author Share Posted April 3, 2020 Hi, Super, works nicely! Added setFontHOffset and setFontVOffset to align with other info. How would it be possible to let relative screen position avaible in Component/prop file? PROP_PARAM(Int, hud_flags, Gui::ALIGN_TOP | Gui::ALIGN_LEFT, "HUD screen position"); -> working, but Int doesn't display nicely.. PROP_PARAM(Enum, hud_flags, Gui::ALIGN_TOP | Gui::ALIGN_LEFT, "HUD screen position"); -> idealy with drop down list multiple selection e.g. masks panel For rendering, you suggested update(), but I tested with post_update and works fine. What would be proper way? Is there any difference? Kind regards, Charles Link to comment
cash-metall Posted April 3, 2020 Share Posted April 3, 2020 25 minutes ago, Lales.Charles said: For rendering, you suggested update(), but I tested with post_update and works fine. What would be proper way? Is there any difference? update or post_update - it depends on your situation. you can use any method. 28 minutes ago, Lales.Charles said: How would it be possible to let relative screen position avaible in Component/prop file? PROP_PARAM(Switch, hud_flags, 0, "Left,Right,Center", "HUD screen position"); Link to comment
Lales.Charles Posted April 3, 2020 Author Share Posted April 3, 2020 (edited) Hi, Thanks for quick answer.. but guess it is bit too quick. Update / post_update -> what is the difference please. Complete doc (2.10) search on post_update or COMPONENT_POST_UPDATE doesn't bring any result... No indication neither in ComponentSystem.h PROP_PARAM(Switch, hud_flags, 0, "Left,Right,Center", "HUD screen position"); -> yes working but... How let user multiple selection? e.g. Gui::ALIGN_TOP | Gui::ALIGN_LEFT without listing all consistent combination... Should I try mask? Kind regards, Charles Edited April 3, 2020 by Lales.Charles Link to comment
Lales.Charles Posted April 3, 2020 Author Share Posted April 3, 2020 Hi, I can do this: PROP_PARAM(Switch, hud_h, 0, "Left,Center,Right", "HUD screen horizontal position"); PROP_PARAM(Switch, hud_v, 0, "Top,Center,Bottom", "HUD screen vertical position"); But something else may be easier / nicer directly linked to UnigineGui.h enum.. ... and more generally to any enum with multiple selection possible. enum { ALIGN_CENTER = 1 << 0, ALIGN_LEFT = 1 << 1, ALIGN_RIGHT = 1 << 2, ALIGN_TOP = 1 << 3, ALIGN_BOTTOM = 1 << 4, ALIGN_EXPAND = 1 << 5, ALIGN_OVERLAP = 1 << 6, ALIGN_BACKGROUND = 1 << 7, ALIGN_FIXED = 1 << 8, }; Kind regards, Charles Link to comment
cash-metall Posted April 3, 2020 Share Posted April 3, 2020 1 hour ago, Lales.Charles said: Update / post_update -> what is the difference please. Complete doc (2.10) search on post_update or COMPONENT_POST_UPDATE doesn't bring any result... No indication neither in ComponentSystem.h ok, I just didn’t fully understand the question. The main difference between update and post-update is in the order of the call. 1 hour ago, Lales.Charles said: How let user multiple selection? e.g. Gui::ALIGN_TOP | Gui::ALIGN_LEFT without listing all consistent combination... Should I try mask? in you case you can try using several switches in one group PROP_PARAM(Mask, align, 0) // or PROP_PARAM(Toggle, align_center, 0, "ALIGN_CENTER", "","ALIGN") PROP_PARAM(Toggle, align_left, 0, "ALIGN_LEFT", "","ALIGN") PROP_PARAM(Toggle, align_right, 0, "ALIGN_RIGHT", "","ALIGN") PROP_PARAM(Toggle, align_top, 0, "ALIGN_TOP", "","ALIGN") PROP_PARAM(Toggle, align_bottom, 0, "ALIGN_BOTTOM", "","ALIGN") // in init int gui_flag = 0; if (align_top.get()) gui_flag |= Gui::ALIGN_TOP; if (align_bottom.get()) gui_flag |= Gui::ALIGN_BOTTOM; //..... Gui::get()->addChild(label, gui_flag); ... masks would be the best way, but I see no way to set names for each bit. it spoils this way. Link to comment
Lales.Charles Posted April 3, 2020 Author Share Posted April 3, 2020 Hi, Thanks for documentation, may I suggest to make sure it pop-up with search on post_update & co + COMPONENT_POST_UPDATE & co Thanks for your proposition to deal with, but like better last submitted to avoid inconsistent options e.g. ALIGN_TOP | ALIGN_BOTTOM PROP_PARAM(Switch, hud_h, 0, "Left,Center,Right", "HUD screen horizontal position"); PROP_PARAM(Switch, hud_v, 0, "Top,Center,Bottom", "HUD screen vertical position"); Can you take into account as suggestion something more user-friendly for enum as type in prop maybe..? Kind of switch automatically populated with enum names (yes yes, not direct in C++...) and offering XOR / OR selection option? i.e. single / multiple selection? Kind regards, Charles Link to comment
Lales.Charles Posted June 30, 2020 Author Share Posted June 30, 2020 Dear Unigine support, Regarding this text display in 2D, everything is fine but with VR (Vive) activated, how is it possible to see the info as well? In Gui related classes, e.g. WidgetLabel, I don't see anything. In demo VR, texts are ObjectText and can be display as child of the entity, but then is there an easy way to stay in front of camera? Kind regards Charles Link to comment
alexander Posted July 2, 2020 Share Posted July 2, 2020 Hi Charles, Regarding this text display in 2D, everything is fine but with VR (Vive) activated, how is it possible to see the info as well? You need to create an ObjectGui (or ObjectGuiMesh) and attach widgets to it.Is there an easy way to stay in front of camera? Unfortunately no. Fixed text is very hard to read in VR. Plus, it breaks 3d/parallax effect. It's best to use text as a static 3d object. Best regards, Alexander Link to comment
Lales.Charles Posted July 3, 2020 Author Share Posted July 3, 2020 Hi, Thanks, working well, at least / first place as cockpit MFD. This can be used as well to simulate HUD projected on windshield... ... but really no way to simulate kind of AR? You suggest more e.g. on click of control button to add an ObjectGui as child of current player, for the user to keep it closed to him.. but without following head movement.. right? Kind regards, Charles Link to comment
silent Posted July 7, 2020 Share Posted July 7, 2020 It's always complicated to do a text in VR :) You can implement something similar to HL: Alyx approach with moving texts: https://www.youtube.com/watch?v=IcNoa7kszBI&feature=youtu.be&t=1628 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Lales.Charles Posted July 13, 2020 Author Share Posted July 13, 2020 Hi, In fact I simply implemented what you already demonstrate in VR demo with Gui sample. User can display/hide the panel on demand, it is child of Vive controller. This way, if resolution is not fine (e.g. Vive standard compared to pro), user can bring the panel closer and read info. It is also useful outside of aircraft where there's no MFD/cockpit to read from. Kind regards, Charles 1 Link to comment
Recommended Posts