Strange experiece with 2D rectangle.

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
Kristian
Hobgoblin
Posts: 542
Joined: Sun Jan 12, 2003 7:35 pm
Location: Copenhagen, Denmark

Strange experiece with 2D rectangle.

Post by Kristian » Sun May 22, 2005 8:14 pm

Hello,

Ive written a class that takes a texture and animated it between other textures for displaying animated sprites.
And I used to display theese on panel overlayelements and the sprites worked just fine.

However when i tryed to switch to using a 2D rectangle i experienced a very strange error the texture wasnt showing up at all.

However when i add theese 3 lines to the code it works fine on 2d rects as well :

Code: Select all

	mOverlayElement = Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", mName + String("/BombermanSprite/OverlayElem") + unique, false);
	mOverlay = Ogre::OverlayManager::getSingletonPtr()->create( mName + String("/BombermanSprite/Overlay") + unique );
	mOverlayElement->setMaterialName( mMaterial->getName() );
(allright maybe I probatly dont need to create a overlay, havent tested that yet since I incidently discovered this ).


The technique i use to animate the sprites it to manualle create a material with a texture unit state which sets the texture every time the sprite anumation is updated. Im preloading around 50 frames for the sprite and I've tried with other graphics as well and the error is still the same.

Any ideas why something like this couold be happening ?
0 x
Kristian, crying out loud: "If it works. Don't fix it!" :p
HCA
HCA2
GuppyLife

User avatar
Kristian
Hobgoblin
Posts: 542
Joined: Sun Jan 12, 2003 7:35 pm
Location: Copenhagen, Denmark

Post by Kristian » Sun May 29, 2005 11:46 pm

Am I the only one experiencing this ?


when i execute the following the texture doesnt show:

Code: Select all

	MaterialPtr mat = Ogre::MaterialManager::getSingletonPtr()->create("Menu/BackgroundMaterial", "General" );
	mat->getTechnique(0)->getPass(0)->createTextureUnitState("guibg.jpg");

	Ogre::SceneManager* scenemgr = Core::Application::getSingleton().getSceneManager();
	Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
	rect->setCorners(-1.0, 1.0, 1.0, -1.0);
	rect->setBoundingBox( AxisAlignedBox(-100000.0 * Ogre::Vector3::UNIT_SCALE, 100000.0 * Ogre::Vector3::UNIT_SCALE));
	//rect->setMaterial("Menu/BackgroundMaterial");
	rect->setMaterial("Menu/BackgroundMaterial");
	rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
	SceneNode* node = scenemgr->getRootSceneNode()->createChildSceneNode();
	node->attachObject(rect);
	node->setVisible(true);

but when i add this piece of code it works fine

Code: Select all

	Ogre::OverlayElement* e = Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "Menu/BackgroundElement" );
	e->setMaterialName("Menu/BackgroundMaterial");

The texture is a 64x64 jpg but I tryed with diffirent textures as well.
0 x
Kristian, crying out loud: "If it works. Don't fix it!" :p
HCA
HCA2
GuppyLife

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Mon May 30, 2005 7:54 am

Kristian wrote:

Code: Select all

rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
Could this be it? This tells Ogre to draw the rectangle before anything else. If you want it to appear above your scene, try using e.g. RENDER_QUEUE_6. Also make sure you disable depth-check (and probably also lighting).
0 x

Post Reply