Gmarquez Posted August 26, 2021 Share Posted August 26, 2021 (edited) Hi there! I'm implementing a routine to display an affect when a flying object crash on water (ObjectWaterGlobal node) and what a I have done is working, but not in all the test I do. void AirVehicle::hitTheFloor() { double z1 = mNodeBodyGood->getNode()->getWorldPosition().< + 1.0; double z2 = mNodeBodyGood->getNode()->getWorldPosition().< - 1.0; Unigine::Math::Vec3 position = mNodeBodyGood->getNode()->getWorldPosition(); Unigine::WorldIntersectionPtr intersection = Unigine::WorldIntersection::create(); Unigine::Vector<Unigine::NodePtr> exclude; exclude.append(mNodeBodyGood->getNode()); std::vector<Unigine::NodePtr> nodeArray = util::UnigineUtils::collectAllChildren(mNodeBodyGood->getNode()); for (int i = 0; i < (int)nodeArray.size(); i++) { exclude.append(nodeArray.at(i)); } Unigine::ObjectPtr floor = Unigine::World::get()->getIntersection( Unigine::Math::Vec3(position.x, position.y, z1), Unigine::Math::Vec3(position.x, position.y, z2), 0xFF, exclude, intersection); if (floor.get() != nullptr) { if (floor->getType() == Unigine::Object::OBJECT_TERRAIN) { ///Do Something } else if (floor->getType() == Unigine::Object::OBJECT_WATER_GLOBAL) { ///Do Something } } } To detect the collision with the ObjectWaterGlobal I'm calculating a intersection of the falling object with anything around 1 meter over and above the object. But some times the intersection is empty and the collision is not detected. Is there another way to detect the collision with water in a more precise way? Edited August 31, 2021 by Gmarquez Link to comment
silent Posted August 27, 2021 Share Posted August 27, 2021 Gmarquez Have you tried to use getHeight() / getNormal() methods to get more precise height? You can check usage example in <SDK>/data/samples/worlds/expression_01. 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
Gmarquez Posted August 27, 2021 Author Share Posted August 27, 2021 Thanks Silent, with getHeight() I could make a more robust method to check the distance to the surface of the water. Link to comment
Recommended Posts