piotr.karkocha Posted September 28, 2018 Share Posted September 28, 2018 Hi! I am wondering how to move properties between projects - lets say I would like to use the light switcher, switch receiver (light source going on/off) and the sun control available in the Superposition project in a new file. I have imported all the cpp. and headers from Superposotion data folder into my project´s data folder. I even tried to copy paste the code from the Superpositions light switcher into the switch property cpp of the vr template, adding all the headers and files included in the light switcher cpp, but I still dont get its funcionality in the new file. I think it could be a problem with inheritance, or maybe GUI? I only have a basic knowledge of programming, but I gues it cant be that hard! Please help:) Link to comment
alexander Posted October 1, 2018 Share Posted October 1, 2018 Hi Piotr, Properties are simply data containers without any logic. All the logic (for example, in the VR Template) are inside the Component System and its components. Superposition was developed before the Component System. It uses AppWorldLogic to update objects for each frame and it reads the property parameters only in init() method. So, all you need to do: 1) Convert ObjSwitcher.h/cpp (and ObjSwitchReceiver, etc.) to a component of the Component System: 1.1) Inherit from the VRInteractable (instead of the Obj) class 1.2) Add constructors/destructors/getPropertyName functions 1.3) Remove unnecessary code (checkObject, Tooltips::hide, saveState/restoreState, etc) 2) Register new classes inside the AppSystemLogic: ComponentSystem::get()->registerComponent<ObjSwitcher>(); Best regards, Alexander Link to comment
piotr.karkocha Posted October 9, 2018 Author Share Posted October 9, 2018 Hi Alexander, great! thanks for your help! Link to comment
piotr.karkocha Posted October 16, 2018 Author Share Posted October 16, 2018 I hope i did everything right - but even after registering the property in the AppSystemLogic, it still does not appear in the project. so does a prop. file need to be created manually, or is it generated automatically and Ishould assume i did something wrong? Link to comment
silent Posted October 17, 2018 Share Posted October 17, 2018 Hi Piotr, Could you please provide a simple test scene with this issue? That would help us to understand the root cause faster. Thanks! 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
piotr.karkocha Posted October 18, 2018 Author Share Posted October 18, 2018 Hi Silent, My bad, I was doing something wrong, the code does not compile. The problem seems to be located in the Switcher.h, error says: "virtual is not allowed" in the constructor. I wasn't also sure, if the Property Parameters should also be listed in the Switcher.h, instead of the init function of the Switcher.cpp, as in the other properties in Vr Template? I have attached the files with code. Thanks, Pio ObjSwitcher.cpp ObjSwitcher.h ObjSwitchReceiver.cpp ObjSwitchReceiver.h Link to comment
piotr.karkocha Posted October 18, 2018 Author Share Posted October 18, 2018 Ok, I have another idea - there is a switch property in the VR template. So instead of converting the old ones, I thought about changing the switch.cpp/.h. Fox from Unigine helped me on one thing and I thought his solution could be as well applicable to this case (https://developer.unigine.com/forum/topic/5126-adding-controller-functionalitychanging-a-material/?tab=comments#comment-26420). I would like the switch to toggle visibility of the children of the object the property is attached to. So if I have a node with a switch property and make it a parent of let's say three lights, then, when the switch is enabled, they are visible and get ivnisible when the switch is disabled. So, similar to the way Fox showed it to me, I wanted to do something like this: Switch.h public: PROPERTY_PARAMETER(String, parent_name, "parent"); //<--- name of the parent to use its children for visibility switching Unigine::Vector<NodePtr> my_children; // vector of children to be used for the object <--- int children_index = 0; private: void shutdown() override; Switch.cpp void ObjSwitch::init() { { // clearing the vector my_children.clear(); // getting the name of the parent object for the group which visibility should be changed NodePtr parent_obj = Node::get()->findNode(parent_name.get()); int num = parent_obj->getNumChildren(); // adding all its children to the vector for (int i = 0; i < num; i++) { my_children.append(parent_obj->getChild(i)); } } // method performing vector cleanup on shutdown void ObjMovable::shutdown() { my_children.clear(); } I know it's far from right and I don't know how to code that when switch is disabled, the visibility goes off and on when its enabled. Thanks, Pio Link to comment
Recommended Posts