ivan.cuevas Posted October 1, 2015 Share Posted October 1, 2015 Hi all, In the attached example the objective is to keep the cube over the water surface. The problem is there is not a visual matching between the height returned by ObjectWater::getHeight() and the visual representation. It's something wrong in node expression? It's an ObjectWater problem? Thanks. water_height.cpp water_height.world Link to comment
maxi Posted October 14, 2015 Share Posted October 14, 2015 Hi Ivan, ObjectWater::getHeight gets current offset of a given point relative to the water surface, to correct this offset, you need to add a negative value of offset: { Node n= getNode(); ObjectWater w= class_cast("ObjectWater", engine.editor.getNodeByName("ocean2")); dvec3 pos= n.getWorldPosition(); float h= w.getHeight(pos); pos.z -= h; n.setWorldPosition(pos); } Link to comment
ivan.cuevas Posted October 14, 2015 Author Share Posted October 14, 2015 Understood, thanks for the clarification. Link to comment
Recommended Posts