dongju.jeong Posted February 5, 2021 Share Posted February 5, 2021 I applied the seasonal changes of the terrain using the parameters shown in the picture. To apply syncker synchronization, should I just use "syncNode (const unigine::NodePtr &in_node, unsigned char mask = ~0)" function? (put in landsacpe node in "in_node" parameter, mask = Master::OBJECT) Link to comment
cash-metall Posted February 5, 2021 Share Posted February 5, 2021 runtime terrain changes are not synchronized. you can do it manually using custom messages. int AppWorldLogic::init() { // for slave auto sm = Plugins::Syncker::Manager::get(); if (sm) { auto slave = sm->getSlave(); if (slave) { // method on_terrain_update will be called on the slave when the message "terrain_update" arrives. slave->setMessageReceivedCallback("terrain_update", MakeCallback(this, &AppWorldLogic::on_terrain_update)); } } return 1; } void AppWorldLogic::update_terrain(int detail, float threshold, float width, float contrast) { auto terrain = checked_ptr_cast<ObjectTerrainGlobal>(World::getNodeByType(Node::OBJECT_TERRAIN_GLOBAL)); // < too slow. find and save terrain should be in init // apply parameters to terrain terrain->getDetail(detail)->setMaskThreshold(threshold); terrain->getDetail(detail)->setMaskWidth(width); terrain->getDetail(detail)->setMaskContrast(contrast); auto sm = Plugins::Syncker::Manager::get(); // < too slow. find and save syncker should be in init if (sm) { auto master = sm->getMaster(); if (master) { // send message "terrain_update" with parameters BlobPtr blob = Blob::create(); blob->writeInt(detail); blob->writeFloat(threshold); blob->writeFloat(width); blob->writeFloat(contrast); master->sendMessage("terrain_update", blob); } } } void AppWorldLogic::on_terrain_update(const Unigine::BlobPtr &message) { // read message in the same order of parameters int detail = message->readInt(); float threshold = message->readFloat(); float width = message->readFloat(); float contrast = message->readFloat(); // invoke update_terrain for apply parameters update_terrain(detail, threshold, width, contrast); } int AppWorldLogic::update() { // for master if (App::clearKeyState('t')) { update_terrain(1, 2.0, 3.0f, 4.0f); } return 1; } 1 Link to comment
dongju.jeong Posted February 5, 2021 Author Share Posted February 5, 2021 (edited) Thank you for the detailed sample. It wasn't as simple as I thought.I have question.... Exactly what changes do the two masks I marked synchronize? Edited February 5, 2021 by dongju.jeong Link to comment
cash-metall Posted February 8, 2021 Share Posted February 8, 2021 OBJECT - other parameters of objects except NodeFlags and Transform (particles trasform for object particles, bones transform for object skinned) OBJECT_SURFACE - all paramters of surfaces (surface flags and information about inherit materials on each surfaces) 1 Link to comment
Recommended Posts