A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Fri Oct 26, 2007 6:50 am
hi.
i load an image file using Material like this code
Code: Select all
MaterialPtr img;
img = MaterialManager::getSingleton().create(fileName, "General", false);
img->getTechnique(0)->getPass(0)->createTextureUnitState(fileName + ".jpg");
imgNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(fileName);
rect = new Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial(fileName);
rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
rect->setBoundingBox(AxisAlignedBox(-100.0*Vector3::UNIT_SCALE, 100.0*Vector3::UNIT_SCALE));
imgNode = mSceneMgr->getSceneNode(fileName);
imgNode->attachObject(rect);
mSceneMgr->getSceneNode(fileName)->setVisible(true);
the image's background that i load is loaded too.
how can i load an image file, but i don't want to load the background too
can i rotate the image?
thx for the help
Last edited by r1cky1708 on Sun Nov 11, 2007 8:11 pm, edited 1 time in total.
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Sat Oct 27, 2007 6:53 am
i use that code to make menu option.
and the fps always going down.
do i must destroy the imgNode?
zolt4n
Kobold
Posts: 32 Joined: Sun Nov 04, 2007 10:04 am
Post
by zolt4n » Fri Nov 09, 2007 11:45 am
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Fri Nov 09, 2007 1:36 pm
Code: Select all
// Initialisation
_material = Ogre::MaterialManager::getSingleton().create(Name + "/default", "General");
_container = (OverlayContainer*) OverlayManager::getSingletonPtr()->createOverlayElement("Panel", Name);
_container->setMaterialName(_material->getName());
_container->setPosition(xPos, yPos);
_guiOverlay = OverlayManager::getSingletonPtr()->create(Name);
_guiOverlay->add2D(_container);
_guiOverlay->show();
// set picture
_texture = TextureManager::getSingleton().load(fileName,"General");
TextureUnitState *pTexState;
if(_material->getTechnique(0)->getPass(0)->getNumTextureUnitStates())
pTexState = _material->getTechnique(0)->getPass(0)->getTextureUnitState(0);
else
pTexState = _material->getTechnique(0)->getPass(0)->createTextureUnitState( _texture->getName() );
pTexState->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
_material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
can you give me the initialitation of
Code: Select all
_material
_container
_guiOverlay
_texture
b'cos i try to use your code, but it got an error compile
thx
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Fri Nov 09, 2007 1:44 pm
i can use your program now.
but how to set width and height of the image?
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Fri Nov 09, 2007 1:45 pm
thx, i can do the width and height
zolt4n
Kobold
Posts: 32 Joined: Sun Nov 04, 2007 10:04 am
Post
by zolt4n » Fri Nov 09, 2007 2:16 pm
I don't know how to load an another pic if someone find ...
zolt4n
Kobold
Posts: 32 Joined: Sun Nov 04, 2007 10:04 am
Post
by zolt4n » Fri Nov 09, 2007 2:29 pm
find !!!
if (!_texture.isNull())
_texture->freeInternalResources();
_texture = TextureManager::getSingleton().load(fileName, _group);
_texture->reload();
But I think that is a little durty.
Now if you find for alpha on pic say me !!!
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Fri Nov 09, 2007 5:35 pm
what do you mean by alpha on pic?
like you don't want to load the background of an image?
i use this
Code: Select all
MaterialPtr material2 = MaterialManager::getSingleton().create("menu", "General");
material2->getTechnique(0)->getPass(0)->createTextureUnitState("jarum.png");
material2->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA );
material2->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material2->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material2->getTechnique(0)->getPass(0)->setLightingEnabled(false);
zolt4n
Kobold
Posts: 32 Joined: Sun Nov 04, 2007 10:04 am
Post
by zolt4n » Fri Nov 09, 2007 6:25 pm
Something like transparency
like
_container->setColour(ColourValue(1, 1, 1, 0.5));
it's working for text but don't for pic
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Sun Nov 11, 2007 4:42 pm
did you already use your program for make a menu
i load that overlay again, and it getting dark
here is the screenshot
and this is the image that getting dark
zolt4n
Kobold
Posts: 32 Joined: Sun Nov 04, 2007 10:04 am
Post
by zolt4n » Sun Nov 11, 2007 5:21 pm
In fact is not for a menu more for a hud (little item on bottom).
And I want my overlay to appear , disappear ....
with transparency during the game.
I find something like that but it don't work very well because colour red is allways transparent now...
Code: Select all
// this line is ok to my transparency with setColour but native transparency on png don't work now
_material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_COLOUR);
// this line is now to native transparency , but red is allways transparent ... I'm desapointed ...
_material->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CompareFunction::CMPF_GREATER_EQUAL, 255);
ps : r1cky1708 I send you a private messge
r1cky1708
Gnoblar
Posts: 13 Joined: Fri Oct 26, 2007 6:34 am
Post
by r1cky1708 » Sun Nov 11, 2007 8:01 pm
i can load my image right now, but i'm using my own code
i forgot have resize it
here is the mistake, this is what i use
Code: Select all
rect->setBoundingBox(AxisAlignedBox(-100.0*Vector3::UNIT_SCALE, 100.0*Vector3::UNIT_SCALE));
and, here is the right one
Code: Select all
rect->setBoundingBox(AxisAlignedBox(-100000.0*Vector3::UNIT_SCALE, 100000.0*Vector3::UNIT_SCALE));
for zolt4n,
for your alpha, i'll try to find that