How to create a new imageset?

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

majc
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Sat Apr 12, 2008 20:55

How to create a new imageset?

Postby majc » Sat Aug 02, 2008 18:11

I want to create a new imageset to load my crosshair instead of loading it in TaharezLook imageset.
Until now i did this:

Crosshair.imageset

Code: Select all

<?xml version="1.0" ?>

<Imageset Name="Crosshair" Imagefile="crossHair2.png" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
   <Image Name="crossHair2" XPos="0" YPos="0" Width="33" Height="33" />
</Imageset>


and i got this error:

CEGUI.log

Code: Select all

02/08/2008 18:58:42 (Error)   CEGUI::UnknownObjectException in file \Projects\CEGUI\cegui_mk2-v0-6-2003\src\CEGUIImagesetManager.cpp(183) : ImagesetManager::getImageset - No Imageset named 'Crosshair' is present in the system.


This error tells me that i have to target this new imageset file somehere else but where?
Do i have to create other file?

I tryed this:

Code: Select all

#include "cGUIInterface.h"

cGUIInterface::cGUIInterface(cGraphicalInterface *graphicalInterface)
{
   // setup GUI system
   mGraphInterface = graphicalInterface;
   mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mGraphInterface->getWindow() , Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mGraphInterface->getSceneManager());
   mGUISystem = new CEGUI::System(mGUIRenderer);
   mWindowManager = &CEGUI::WindowManager::getSingleton();
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
    (CEGUI::System::getSingleton().getResourceProvider());
   rp->setResourceGroupDirectory("imagesets", "./ogrenew/DarkFuture/Media/gui/Imagesets");
   Imageset* wlis = ImagesetManager::getSingleton().createImageset(
   "Crosshair.imageset", "imagesets");
}

void cGUIInterface::loadScheme()
{
   CEGUI::SchemeManager::getSingleton().loadScheme("TaharezLookSkin.scheme");
}
void cGUIInterface::setImage()
{
   MouseCursor::getSingleton().setImage("Crosshair", "crossHair2");
}

void cGUIInterface::setPosition()
{
   MouseCursor::getSingleton().setPosition(CEGUI::Point(385,285));
}

void cGUIInterface::createCrosshair()
{
   //loadScheme();
   setImage();
   setPosition();
}

cGUIInterface::~cGUIInterface()
{
}


and gave me a memory error in this line:

r

Code: Select all

p->setResourceGroupDirectory("imagesets", "./ogrenew/DarkFuture/Media/gui/Imagesets");


I think im not writing the correct path, i have the foler here:

Code: Select all

C:\ogrenew\DarkFuture\Media\gui\Imagesets


Can i use this kind of code with ogre or do i have to use ogre specific code like i see in a post that used ogre resource manager ( http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3440 ) ?
Im asking this because i can get more information use only CEGUI code than use OGRE/CEGUI code


Thanks in advance!

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Sun Aug 03, 2008 11:48

I create imagesets dynamically in a couple of ways (the first of these is the one that seems to be pertinent to you - the key is to create a scheme file and then load this scheme file).

Scenario 1:
The first way is to define a scheme file and to load it as follows:

Code: Select all

void Troupe::loadTargetIconScheme(const std::string& schemeName)
   {
      std::string schemeFileName(schemeName+".scheme");
      try
      {
         if( !CEGUI::SchemeManager::getSingleton().isSchemePresent(schemeFileName) )
         {
            CEGUI::Scheme* scheme = CEGUI::SchemeManager::getSingleton().loadScheme(schemeFileName);
            assert(scheme && "Troupe::loadTargetIconScheme: Failed to load scheme");

         }
      }
      catch(CEGUI::AlreadyExistsException aece)
      {
         // This is already loaded, no need to do it again.
      }
   }


The scheme file, in this case, might look like:

    <?xml version="1.0"?>
    <GUIScheme Name="TargetIcons">
    <Imageset Name="TargetIcons" Filename="TargetIcons.imageset"/>
    <LookNFeel Filename="TargetIcons.looknfeel"/>
    <WindowSet Filename="CEGUIFalagardWRBase"/>
    <FalagardMapping WindowType="TargetIcons/AircraftButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="AircraftIconButton"/>
    <FalagardMapping WindowType="TargetIcons/DirectionalButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="DirectionalIconButton"/>
    <FalagardMapping WindowType="TargetIcons/DirectionlessButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="DirectionlessIconButton"/>
    </GUIScheme>




loadScheme should do the work for you assuming that all the resources that relate to the imageset can be found.

Scenario 2:

In general you dont need to create imagsets in this fashion. The alternative simply relies on access to one or more images. In this case what I do is something along the lines of the following:

Code: Select all

void DisplayedImage::load(const std::string& imageName, const std::string& imageLabel, const std::string& imageFileName, const std::string& imageGroup)
   {
      assert(mImgWindow && "DisplayedImage::load: null image window");
      mImgsetName = imageName;
      mImgName = imageName;

      try
      {
         /*
         ** 1] Load an image from file
         ** 2] Create a texture from this loaded image
         ** 3] Create an imageset based on this texture
         ** 4] Define the image to be the entire imageset
         */
         Ogre::Image image;
         image.load(imageFileName, imageGroup);
         float w = image.getWidth();
         float h = image.getHeight();
         if(w <= 0 || h <= 0)
         {
            std::stringstream sserr;
            sserr << "Invalid image dimensions " << imageFileName;
            SVTConsole::getSingleton().printError(sserr.str());
         }
         mWidth = w;
         mHeight = h;

         mOgreTexture = Ogre::TextureManager::getSingleton().loadImage(imageName+".Texture", imageGroup, image);
         assert(!mOgreTexture.isNull() && "DisplayedImage::load: failed to load image");
         mCeguiTexture = GUIManager::getSingleton().getRenderer()->createTexture(mOgreTexture);
         assert(mCeguiTexture && "Template1Menu::load: failed to create cegui texture");
         mCeguiImageSet = CEGUI::ImagesetManager::getSingleton().createImageset(mImgsetName, mCeguiTexture);
         assert(mCeguiImageSet && "Template1Menu::load: failed to create imageset");
         mCeguiImageSet->defineImage(mImgName, CEGUI::Point(0.0f, 0.0f),   
                                 CEGUI::Size(mWidth, mHeight), CEGUI::Point(0.0f,0.0f));
      
         
      }
      catch (CEGUI::Exception ce)
      {
         SVTConsole::getSingleton().printError(ce);
      }
      catch (Ogre::Exception oe)
      {
         SVTConsole::getSingleton().printError(oe);
      }
   }


Notice with this approach that I load the image into a texture, and then create the imageset from the texture.

In summary:
The first scenario seems to make more sense for you. You have your image files pre-defined, and should define a scheme file that references your imageset. Then you should load the scheme file
Last edited by daves on Sun Aug 03, 2008 12:04, edited 1 time in total.

majc
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Sat Apr 12, 2008 20:55

Postby majc » Sun Aug 03, 2008 11:57

you are right, the first scenario makes more sense for me but i have one problem, can i define a scheme file without:

Code: Select all

 <FalagardMapping WindowType="TargetIcons/AircraftButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="AircraftIconButton"/>
<FalagardMapping WindowType="TargetIcons/DirectionalButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="DirectionalIconButton"/>
<FalagardMapping WindowType="TargetIcons/DirectionlessButton" TargetType="CEGUI/PushButton" Renderer="Falagard/Button" LookNFeel="DirectionlessIconButton"/>


?

because i only want to display an image without any kind of buttons.
Thanks for your reply :)

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Sun Aug 03, 2008 11:59

Yes you can. You dont need the looknfeel line. This was just a quick example I grabbed.

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Sun Aug 03, 2008 12:00

Keep in mind if you are already using an application scheme (e.g. windowslook) it already references an imageset. Just add the imageset declaration to that file and this will also work.

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Sun Aug 03, 2008 12:01

Example:

Code: Select all

<?xml version="1.0" ?>
<GUIScheme Name="SVTLookSkin">
   <Imageset Name="SVTLook" Filename="SVTLook.imageset" />
  <Imageset Name="SVTSplashScreenLook" Filename="SVTSplashScreenLook.imageset" />
  <Imageset Name="SVTColorChooserLook" Filename="SVTColorChooserLook.imageset" />
  <Imageset Name="SensisLogos" Filename="SensisLogos.imageset" />
  <Imageset Name="SVTSymbols" Filename="SVTSymbols.imageset" />
  <Font Name="Tahoma-12" Filename="tahoma-12.font" />
  <Font Name="Tahoma-10" Filename="tahoma-10.font" />
  <Font Name="Tahoma-8" Filename="tahoma-8.font" />
   <LookNFeel Filename="SVTLook.looknfeel" />
   <WindowSet Filename="CEGUIFalagardWRBase" />

 ...
 
</GUIScheme>



See multiple imagesets referenced in one scheme.

majc
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Sat Apr 12, 2008 20:55

Postby majc » Mon Aug 04, 2008 01:22

Thanks alot for your help :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 13 guests