Page 1 of 1

How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 13:07
by cs_cslaa
Hi,

I am a beginner of CEGUI and Ogre, what I am doing is that writing a 3D game with using the OGRE, and I am respond to the GUI part. Indeed, I have very limited knowledge in CEGUI. :( and I want to simply load a image into the game scene and show it. But i cannot find any simply solution to my problem. Except, the method taught in tutorial 2 at the below, which is exactly the code in my porgram, but it does not work. I am wondering are there any other method which will be simpler, and actually where is the root directory of the path that one of the input argument?

Code: Select all

   
      mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
      mGUISystem = new CEGUI::System(mGUIRenderer);
      CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

      rp->setResourceGroupDirectory("imagesets", "C:\\OgreSDK\\bin\\debug\\image/");

Re: How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 13:20
by madeinsoviets
i don't think that the best way to show an image is to do it through CEGUI - try just textures from OGRE. If by some reason you are to do it through CEGUI try this tutorial http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_7 - your part is "Render to Texture"...

Re: How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 13:51
by cs_cslaa
Thanks madeinsoviets, I have read the RTT, but I still do not understand how to load an image(.jpg) to the game scene from an external folder, since it taught me to add the viewport.:(

Re: How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 14:11
by madeinsoviets
If you are new to Ogre - best way to load image is to define it as a part of ogre material and then define way to this material in resources.cfg.

Example of a material definition:

material Examples/OgreLogo
{
technique
{
pass
{
ambient 0.8 0.8 0.8

exture_unit
{
texture ogrelogo.png
}
}
}
}

So, the way is:
1) describe .material file
2) add a way to your texture and .material in resources.cfg
3) create for example a plane or billboard set in Ogre
4) set a material to your playe of billboard set as you defined in .material (for ex. "Examples/OgreLogo")

When you do all of this you wil have an ability to use it in runtime. Other way is to load resources manually, but i strongly recommend you to use the first way, if you can't i can point you to info about loading resources manually..

Re: How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 14:13
by madeinsoviets
Sorry, but i can't do spacing properly in material definition...(

Re: How to load a image into the Ogre game scene?

Posted: Mon Mar 01, 2010 14:56
by cs_cslaa
Sorry madeinsoviets, I am still not very clear how to do that. I have several questions.
1).So first I need to create a file, which the exten is .material, which using the format you have mentioned, then where should I save this file?
2)the ogrelogo.png should put in the texture file,right?
3)then, should i create a plane object in Ogre, and attach the texture to the plane?

Thanks a lot!! :mrgreen:

Re: How to load a image into the Ogre game scene?

Posted: Tue Mar 02, 2010 08:07
by madeinsoviets
Almost...)

1) You need to create material in .material file
2) You need to define a way to this material resources.cfg (always near Ogre binary (.exe) )
3) You need to apply this material to entity (http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_2 -> "Using Shadows in Ogre ")

Re: How to load a image into the Ogre game scene?

Posted: Tue Mar 02, 2010 15:27
by cs_cslaa
Thanks a lot, madeinsoviets!:)

I have successfully loaded an image into the game scene. But may I askyou one more question?

The image,which I want to load into the scene,has some pixel is transparent to the background. But it seems doesn't work when it was loaded into the scene. It had filled with colour. How can I fix this? Actually, the image represnts the shooting cursor for the player.

Thank you very much again!:):):):):)

Re: How to load a image into the Ogre game scene?

Posted: Thu Mar 04, 2010 08:04
by madeinsoviets
You need to describe your effect in .material...
Here is the docs on this topic - glad to help you..)
http://www.ogre3d.org/docs/manual/manual_16.html#SEC39
i think it is scene blend, but i'm not sure - usually designers do that for me) Best way to solve this is to try to find some similar material in media you resieved with the OgreSDK