ivan.cuevas Posted October 1, 2015 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
maxi Posted October 14, 2015 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); }
ivan.cuevas Posted October 14, 2015 Author Posted October 14, 2015 Understood, thanks for the clarification.
Recommended Posts