Game Development Community

getting the GUI onto which an object is currently rendered on?

by Stefan Beffy Moises · in Torque Game Engine · 06/20/2002 (2:29 pm) · 2 replies

How do I find out onto which Gui an object is currently rendered? Is there a way to distinguish between say the PlayGui and a "Rearviewmirror-GUI", which use both the same scenegraph?
E.g. changing some properties of the object depending on the GUI?
Finding all the GUIs is no problem, it can be done like this:
SimGroup* guiGroup = Sim::getGuiGroup();
	if (guiGroup)
	{
		for (SimSetIterator itr(guiGroup); *itr; ++itr) 
		{
			SimObject* obj = static_cast<SimObject*>(*itr);
			Con::printf("GuiGroup: %s", obj->getClassName());
		}
	}
but how can I find the right GUI during/before rendering to it?
Does that make any sense... ?? :-p

#1
06/20/2002 (4:19 pm)
From guiControl.cc

GuiControl *GuiControl::getParent()
{
	GuiControl *parent = NULL;
	SimObject *obj = getGroup();
	if (obj && (obj->getType() & GuiControlObjectType))
      parent = static_cast<GuiControl*>(obj);
	return parent;
}
#2
06/20/2002 (11:57 pm)
Thanks a lot, that works!
But it still isn't the solution to my problem... :-(

What I'm trying to do is change the dts file for Melv's fxShapeReplicator object, but only in a special MapGui (I change it to a lower detail dts to increase fps in the MapGui) - it works fine, but
as the MapGui is only overlaying the PlayGui, as soon as I change the shapes in the MapGui's (=fxGuiSnooper's) onWake() method, the replicators' shapes in the PlayGui are changing, too, which I don't want...

Here's what I am doing:
GuiControl *parent = NULL;
	SimObject *obj = getGroup();
	if (obj && (obj->getType() & GuiControlObjectType))
		parent = static_cast<GuiControl*>(obj);
	const char* parentGuiName = parent->getName();
	SimSet* mySet = dynamic_cast<SimSet*>(Sim::findObject("fxReplicatorSet"));
	fxShapeReplicator* rep;
	if(mySet)
	{
		for (SimSetIterator itr(mySet); *itr; ++itr) {
			rep = static_cast<fxShapeReplicator*>(*itr);
			if(dStrstr(parentGuiName,"MapGui"))
				rep->SetLowDetailFile();
		}
	}
and it's clear that it does update the PlayGui, too, because I'm only getting a pointer to the "original" fxShapeReplicator/fxReplicatorSet...
So I guess I *have* to totally replace the PlayGui with the MapGui to avoid this problem... :-(
But thanks for your help! :-)