karim.salama Posted November 20, 2020 Posted November 20, 2020 Greetings, I'm trying to update a node depending on the position of two other nodes in UnigineScript. First I load the node structure from a .node (reference file) and get its root using the getReference() function. Here is how the structure looks like : root pole1 pole2 top I add a NodeTrigger to pole1 and pole2 and set their position callback using the setPositionCallback() function. The same function is used as a callback for both NodeTriggers. After this new structure being initialized, the callback seems to be correctly set sometimes only for pole1, sometimes for pole2, sometimes for both and sometimes for none of them. Any ideas on what can be causing this undefined behavior? Thanks in advance
silent Posted November 20, 2020 Posted November 20, 2020 Hi Karim, Could you please send us a minimal test scene that we can check and debug on our side? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
karim.salama Posted November 20, 2020 Author Posted November 20, 2020 (edited) I was creating a minimal test scene and I accidentally solved the problem haha. At some point, I was using getPosition instead of getWorldPosition. But, I have another question : how can I edit the texCoordinates0 for a static mesh in Unigine script? For now, here is my code which compiles but crashes the editor upon execution : Mesh topbar = node_cast(gantry.findNode("top")); Vec3 p1 = trigger1.getWorldPosition(); Vec3 p2 = trigger2.getWorldPosition(); float x = p1.x - p2.x; float y = p1.y - p2.y; float z = p1.z - p2.z; Vec3 dir = Vec3(x,y,z); float l = length(dir); Node topbar_node = node_cast(topbar); Vec3 s = topbar_node.getScale(); s.z = l; int indices = topbar.getNumTIndices(0); for(int i = 0; i < indices; i++) { Vec2 temp = topbar.getTexCoord0(i, 0); topbar.setTexCoord0(i, Vec2(l,temp.y), 0); } Thanks Edited November 20, 2020 by karim.salama
karim.salama Posted November 20, 2020 Author Posted November 20, 2020 (edited) Nevermind, it just worked for a couple of times in a row. Here is a minimal test scene I attached to the post. You have to change the Unigine sdk path in launch.bat. To test the plugin, you click on the "Create Gantry" button in the wiring tool window and choose "gantry_template.node" Thanks wiring_minimal.zip Edited November 20, 2020 by karim.salama
silent Posted November 20, 2020 Posted November 20, 2020 Thanks! We can take a look at this more closely on Monday. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
karim.salama Posted November 23, 2020 Author Posted November 23, 2020 Hi @silent, I managed to achieve the desired effect by keeping track of the node in the nodeInit method, and applying the necessary updates in the plugin's update function. I think this issue is solved. Thank you.
silent Posted November 24, 2020 Posted November 24, 2020 Yeah, sorry for that. Totally forgot about this thread. If you need some assistance with that in the future, please don't hesitate to write here :) How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts