ignacio.castaneda Posted July 14, 2016 Share Posted July 14, 2016 Hello everuone, I am making a boat simulator in C#. The problem is that I had defined in the editor one rigid body (boat) and 10 childs dummy nodes associated to the boat. I need to obtain the water height in each point to calculate hydrostatics in the flush function. How I have to declare these nodes to acces to them in the flush function. Thank you very much. Best Regards Ignacio Link to comment
silent Posted July 18, 2016 Share Posted July 18, 2016 Hi Ignacio, It seems that you need to use Editor functionality to get Nodes from the world. I assume that you already have nodes called "boat" (with 10 children) and "water" in your world, so you can use following code to get the height of the water in these points: public override int flush() { Node boatNode = Editor.get().getNodeByName("boat"); if (boatNode == null) { return 1; } Node waterNode = Editor.get().getNodeByName("water"); if (waterNode == null || waterNode.getType() != Node.OBJECT_WATER_GLOBAL) { return 1; } ObjectWaterGlobal water = ObjectWaterGlobal.create(waterNode); for (int i = 0; i < boatNode.getNumChildren(); i++) { Node testPointNode = boatNode.getChild(i); float height = water.getHeight(testPointNode.getNodeWorldPosition()); Log.message("Node {0}, relative height: {1}\n", testPointNode.getName(), height); } return 1; } 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
ignacio.castaneda Posted July 18, 2016 Author Share Posted July 18, 2016 Thank you for your help, I didn't see the reply. That's answer also the other topic. This will help me to solve the water object problem I have with the code. Thanks again. Best Regards Ignacio Link to comment
Recommended Posts