Visibility Flag Problem

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Visibility Flag Problem

Post by insider »

I need an object to be visible in my game and hidden in my minimap.
But I can't seem to get it work the way I want it.
It is now visible in my minimap but hidden in the game.
I want just the opposite.
Any pointers would be great :)

Code: Select all

enum VisibilityMasks
{
	visibility_mask_minimap = 1 << 1,
	visibility_mask_game = 1 << 2,
	visibility_mask_selection = 1 << 3
};

Code: Select all

vehicle->laserTurret->GetManualObject()->setVisibilityFlags(VisibilityMasks::visibility_mask_game);
	mCamera->setVisibilityFlags(VisibilityMasks::visibility_mask_game); //Game 
	RTTCam->setVisibilityFlags(VisibilityMasks::visibility_mask_minimap);//Minimap
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: Visibility Flag Problem

Post by lscandolo »

The visibility is handled per viewport, not camera. You need to set the visibility mask, which is AND-ed with the visibility flags of an object to see if it will be drawn or not. So, you want to do somehing like

Code: Select all

vehicle->laserTurret->GetManualObject()->setVisibilityFlags(VisibilityMasks::visibility_mask_game);
   mCamera->getViewport()->setVisibilityMask(VisibilityMasks::visibility_mask_game); //Game 
   RTTCam->getViewport()->setVisibilityMask(VisibilityMasks::visibility_mask_minimap); //Minimap
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: Visibility Flag Problem

Post by insider »

lscandolo wrote:The visibility is handled per viewport, not camera.

Code: Select all

vehicle->laserTurret->GetManualObject()->setVisibilityFlags(VisibilityMasks::visibility_mask_game);
   mCamera->getViewport()->setVisibilityMask(VisibilityMasks::visibility_mask_game); //Game 
   RTTCam->getViewport()->setVisibilityMask(VisibilityMasks::visibility_mask_minimap); //Minimap
I did try that nothing renders to both my Game and minimap cameras and all I have is a blank screen.
Any ideas :)
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: Visibility Flag Problem

Post by lscandolo »

Well, shoot, that's how it's supposed to work. One more thing to try though, the viewports mask is also combined with the scene manager's mask. So maybe you can make sure it's being set appropriately?

Maybe you can check http://ogre3d.org/forums/viewtopic.php?f=2&t=32726, it's a pretty old post, but some other guy was having problems with the scene manager's mask while using a compositor. I don't know if that's your case.
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: Visibility Flag Problem

Post by insider »

lscandolo wrote:Well, shoot, that's how it's supposed to work. One more thing to try though, the viewports mask is also combined with the scene manager's mask. So maybe you can make sure it's being set appropriately?

Maybe you can check http://ogre3d.org/forums/viewtopic.php?f=2&t=32726, it's a pretty old post, but some other guy was having problems with the scene manager's mask while using a compositor. I don't know if that's your case.
Well I got it to work by combining with the scene manager's mask, but still I can't seem to make the laserturret invisible in the minimap, So I am back to square one again.

Code: Select all

int visibilityMask = mSceneMgr->getVisibilityMask();

	vehicle->laserTurret->GetManualObject()->setVisibilityFlags(visibilityMask & VisibilityMasks::visibility_mask_game);
	mCamera->getViewport()->setVisibilityMask(visibilityMask |VisibilityMasks::visibility_mask_game); //Game 
	RTTCam->getViewport()->setVisibilityMask(visibilityMask | VisibilityMasks::visibility_mask_game); //Minimap
The above mentioned code makes the laserturret hidden in game camera but not in the minimap camera, any clues why ?
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: Visibility Flag Problem

Post by lscandolo »

Maybe some other effect is using the same flags you´re using and that´s why it´s behaving strangely. Does it do the same thing if you use a different flag? Something like 0xf00 and 0xf0 for the game and minimap.
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: Visibility Flag Problem

Post by insider »

I got the laserturret to hide in the minimap now but the laserturret looks weird in the Game now, its semitransparent (can't classify it as visible or invisible), it looks corrupt.
The manual object uses the default Culling material provided with Ogre. m_manual->begin("CullingMaterial", Ogre::RenderOperation::OT_LINE_LIST);

Here's how I got the turret hidden in the minimap

Code: Select all

mCamera->getViewport()->setVisibilityMask(VisibilityMasks::MINIMAP);
	RTTCam->getViewport()->setVisibilityMask(VisibilityMasks::MINIMAP);
	vehicle->laserTurret->GetManualObject()->setVisibilityFlags(~VisibilityMasks::MINIMAP );
Where GAME AND MINIMAP are.

Code: Select all

enum VisibilityMasks
	{
		GAME,
		MINIMAP
}
Any ideas how to get the turret visible in the game and hidden in the minimap properly, apologies its my first time using visibility flags :)
Post Reply