Jump to content

[SOLVED] Cigi with superimposed reticule


photo

Recommended Posts

Hello,

For calibration purpose, I need to superimpose a special reticule (a grid-like object) on the rendered screen*. I can do this easily by creating a custom object, assigning it a cigi type, and parenting it to the cigi ownship with a Cigi entity message. Problem is: I must not do it through cigi messages, because I must show/animate the reticule even when no host is active.

On the master, I can get the parent node of the Cigi player and manually attach my own reticule. I also called addSyncNode with the reticule and the syncker. But on the slaves, the reticule doesn't look like it's linked to the ownship.

Any ideas?

*Think of the reticule as something drawn on the windshield of an helicopter, hence linked to the helicopter itself, not linked to the view/pilot's eye.

Link to comment

Hi,

Try to use addSyncNode with the parent node of the Cigi player also.
The thing is Cigi add to sync only root nodes (NodeDummies + NodeReferences for each Entity/View), but the inner hierarchy (for performance reasons) does not have a link "Master ID -> Slave ID" (all nodes created at run time have random IDs). So, when Slave try to sync your reticule, it can not find a parent node with such ID.

Best regards,
Alexander

Link to comment

Hi alex, I added the parent node of the cigi player and it worked ! Thanks !

Now, I also need to have it when I switch from the cigi camera to my free roaming camera. While I can switch camera thanks with the code provided below, my reticule ("calib") is now only syncked in cigi mode. Here is the code:

int AppWorldLogic::init() {
	spectator = PlayerSpectator::create();
	spectator->setZFar(200000.0f);
	spectator->setMinVelocity(50.0f);
	spectator->setMaxVelocity(500.0f);
	cigi_player = Game::get()->getPlayer(); // save current CIGI camera

	calib = Editor::get()->getNodeByName("Calib");
	if (calib.get())
	{
		NodePtr cigi_parent = cigi_player->getParent();
		if (cigi_parent.get())
			calib->setParent(cigi_parent);

		int syncker_index = Engine::get()->findPlugin("Syncker");
		if (syncker_index != -1)
		{
			Syncker::ManagerInterface* syncker_manager = (Syncker::ManagerInterface*)Engine::get()->getPluginData(syncker_index);
			if (syncker_manager->isMasterInitialized())
			{
				Syncker::MasterInterface* syncker = syncker_manager->getMaster();
				syncker->addSyncNode(calib);
				syncker->addSyncNode(cigi_parent);

				// these two lines don't help :(
				syncker->addSyncNode(spectator->getNode());
				syncker->addSyncNode(spectator->getPlayer()->getNode());
			}
		}
	}

	return 1;
}

int AppWorldLogic::update() {
	// switch the camera by press the SPACE button
	if (App::get()->clearKeyState(' ') && !Console::get()->getActivity())
	{
		is_cigi_player = !is_cigi_player;
		if (!is_cigi_player) {
			Log::message("Spectator player\n"); // switch to manual camera
			spectator->setWorldTransform(cigi_player->getWorldTransform()); // make position and rotation of our camera the same as the CIGI camera
			Game::get()->setPlayer(spectator->getPlayer()); // set to our camera
			calib->setParent(Game::get()->getPlayer()->getNode());
			calib->setRotation(Math::quat(270, 0, 0));
		}
		else {
			Log::message("CIGI player\n"); // switch to automatic CIGI camera
			Game::get()->setPlayer(cigi_player);
			NodePtr cigi_parent = cigi_player->getParent();
			if (cigi_parent.get()) {
				calib->setParent(cigi_parent);
				calib->setRotation(Math::quat(0, 180, 90)); // for some reason, the base rotation is different between cigi and spectator (?)
			}
		}
	}

	return 1;
}

What am I missing?

Link to comment
// these two lines don't help :(

Hi. You need to call Master::createNode() to all dynamically created nodes (at run time, not in the Editor) if you want to sync them between machines.
Unigine's Documentation: createNode method
So,

// these two lines don't help :(
syncker->addSyncNode(spectator->getNode());
syncker->addSyncNode(spectator->getPlayer()->getNode());

// this line should help you
syncker->createNode(spectator->getNode());

 

// for some reason, the base rotation is different between cigi and spectator (?)

Yeah, CIGI uses X axis as Forward, Y axis as Right and Z as Down.
Unigine uses X as Right, Y as Up and Z as Back for the player nodes.

Best regards,
Alexander

Link to comment
  • silent changed the title to [SOLVED] Cigi with superimposed reticule
×
×
  • Create New...