andre.elijah Posted October 20, 2016 Share Posted October 20, 2016 Hi there, I'm wondering if there are any internal Unigine projects, or a scripting example that shows how you can enable real-time material or mesh swapping for an ArchViz scene, allowing users to change fabrics or pieces of furniture at runtime? Thanks! Link to comment
koshachy Posted October 21, 2016 Share Posted October 21, 2016 Hi, Andre!I have written a small C++ sample for you, which shows how to "switch" one node to another node. You can find in the attachment 3 files: AppWorldLogic.h AppWorldLogic.cpp unigine.cpp When you create new C++ project (like in this tutorial), you have these files in your project folder: AppWorldLogic.h and AppWorldLogic.cpp are in the into the your_project_folder/source folder unigine.cpp is in the your_project_folder/data/project_name/ folder You can simply replace these files (or write the same instructions from scratch). After building the application, you can launch it and click on the material_ball node and it will be switched to a box primitive. The essential thing of the project is located into update() method where we check the mouse button click and perform a raycasting to find intersected objects. Don't hesitate to ask any questions! Regards unigine.cpp AppWorldLogic.cpp AppWorldLogic.h Link to comment
andre.elijah Posted October 21, 2016 Author Share Posted October 21, 2016 Thank you so much! I will get it implemented over the next day or two and let you know how I made out. Thanks a million! Link to comment
koshachy Posted October 25, 2016 Share Posted October 25, 2016 Hi, Andre! How the things are going? Any updates? I've slightly improved the sample above: from now on LMB click changes material on the left box, albedo_color parameter on the right box. Here are two files in the attachment, AppWorldLogic.h AppWorldLogic.cpp unigine.cpp can be used from the previous answer. Pay attention to the update() method, where the logic is implemented. Regards,Andrey AppWorldLogic.cpp AppWorldLogic.h Link to comment
andre.elijah Posted October 26, 2016 Author Share Posted October 26, 2016 Thanks Andrey, I was actually delayed solving some other issues I've been having. I will test this implementation tomorrow and let you the moment I'm done. Thanks again! Link to comment
Recommended Posts