How to load a image into the Ogre game scene?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

cs_cslaa
Just popping in
Just popping in
Posts: 6
Joined: Mon Mar 01, 2010 12:58

How to load a image into the Ogre game scene?

Postby cs_cslaa » Mon Mar 01, 2010 13:07

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/");

madeinsoviets
Just popping in
Just popping in
Posts: 13
Joined: Sat Feb 27, 2010 09:16

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

Postby madeinsoviets » Mon Mar 01, 2010 13:20

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"...

cs_cslaa
Just popping in
Just popping in
Posts: 6
Joined: Mon Mar 01, 2010 12:58

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

Postby cs_cslaa » Mon Mar 01, 2010 13:51

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.:(

madeinsoviets
Just popping in
Just popping in
Posts: 13
Joined: Sat Feb 27, 2010 09:16

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

Postby madeinsoviets » Mon Mar 01, 2010 14:11

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..

madeinsoviets
Just popping in
Just popping in
Posts: 13
Joined: Sat Feb 27, 2010 09:16

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

Postby madeinsoviets » Mon Mar 01, 2010 14:13

Sorry, but i can't do spacing properly in material definition...(

cs_cslaa
Just popping in
Just popping in
Posts: 6
Joined: Mon Mar 01, 2010 12:58

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

Postby cs_cslaa » Mon Mar 01, 2010 14:56

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:

madeinsoviets
Just popping in
Just popping in
Posts: 13
Joined: Sat Feb 27, 2010 09:16

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

Postby madeinsoviets » Tue Mar 02, 2010 08:07

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 ")

cs_cslaa
Just popping in
Just popping in
Posts: 6
Joined: Mon Mar 01, 2010 12:58

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

Postby cs_cslaa » Tue Mar 02, 2010 15:27

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!:):):):):)

madeinsoviets
Just popping in
Just popping in
Posts: 13
Joined: Sat Feb 27, 2010 09:16

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

Postby madeinsoviets » Thu Mar 04, 2010 08:04

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


Return to “Help”

Who is online

Users browsing this forum: No registered users and 2 guests