Crosshairs with PyCEGUI

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

r0ot_
Just popping in
Just popping in
Posts: 4
Joined: Sun Nov 27, 2011 19:44

Crosshairs with PyCEGUI

Postby r0ot_ » Sun Nov 27, 2011 19:49

I'm using Python-Ogre as a 3d graphics rendering system. As far as PyCEGUI looks, I should be able to create a simple "plus" shaped looking static image in the very center of the rendered display window. Does anyone know if this is possible?

+

Looking something similar to this, but a little bigger.
Last edited by r0ot_ on Mon Nov 28, 2011 00:24, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Crosshairs with PyCEGUI

Postby Kulik » Sun Nov 27, 2011 23:27

Yeah, this definitely is possible by just adding the widget, centring it and setting the image accordingly.

r0ot_
Just popping in
Just popping in
Posts: 4
Joined: Sun Nov 27, 2011 19:44

Re: Crosshairs with PyCEGUI

Postby r0ot_ » Sun Nov 27, 2011 23:57

Could you help me out with a bit of a code example maybe?
I don't know much about PyCEGUI, I'm sure in some time I'll get around to learning a lot more about it, but because what I'm trying to do here with the crosshairs is relatively simple, a simple code example would be much appreciated.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Crosshairs with PyCEGUI

Postby Kulik » Mon Nov 28, 2011 00:22

I definitely won't write the code out for you, that would create a precedence and everyone would start storming here demanding code from me.

Just read the documentation and crawl your way through the code, it's not hard. The CEGUI in practice tutorials contain C++ and python code, start with that.

r0ot_
Just popping in
Just popping in
Posts: 4
Joined: Sun Nov 27, 2011 19:44

Re: Crosshairs with PyCEGUI

Postby r0ot_ » Mon Nov 28, 2011 00:30

Kulik wrote:I definitely won't write the code out for you, that would create a precedence and everyone would start storming here demanding code from me.

Just read the documentation and crawl your way through the code, it's not hard. The CEGUI in practice tutorials contain C++ and python code, start with that.


You're right, you definitely shouldn't create such a precedence. However, looking through the tutorials, I'm not sure which one will give me the desired result. I see a lot about buttons and windows, but I don't want any of that, I'm looking for an image.

Would the tutorial on creating widgets be the best course of action in your experience for getting my desired result?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Crosshairs with PyCEGUI

Postby Kulik » Mon Nov 28, 2011 09:53

Yes

To me you seem afraid of investing time and effort :-) You are trying to achieve something super simple, learning basics of CEGUI will enable you to see the way to do it immediately.

Sometimes going through a series of tutorials takes less time than posting questions on a forum.

r0ot_
Just popping in
Just popping in
Posts: 4
Joined: Sun Nov 27, 2011 19:44

Re: Crosshairs with PyCEGUI

Postby r0ot_ » Mon Nov 28, 2011 23:19

I've made stunning progress :D

Here's the code I've added so far (simply following the tutorial lesson):

Code: Select all

        CEGUI.SchemeManager.getSingleton().create("TaharezLook.scheme")
        myImageWindow = CEGUI.WindowManager.getSingleton().createWindow("TaharezLook/StaticImage","PrettyWindow")
        myImageWindow.setPosition(CEGUI.UVector2(CEGUI.UDim(0.5,0), CEGUI.UDim(0.5,0)))
        myImageWindow.setSize(CEGUI.UVector2(CEGUI.UDim(0,150),CEGUI.UDim(0,100)))
        myImageWindow.setProperty("Image","set:TaharezLook image:full_image")
        CEGUI.System.getSingleton().setGUISheet(myImageWindow)

This obviously doesn't give me the image I want, but that's just something I can change, I think.
So, the image that is displayed above is "full_image", which for an image file, doesn't have an extension like .png, .jpg, .gif, etc. I also can't find the image file "full_image" anywhere in the filesystem for cegui or ogre. My Question: how can I go about changing the image I have to an image of my own creation? (i.e. crosshairs.png)

Also, I don't mean to get ahead of myself, but will transparency in an image file show up as being transparent in my rendered window as well?

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Crosshairs with PyCEGUI

Postby Jamarr » Tue Nov 29, 2011 01:37

r0ot_ wrote:So, the image that is displayed above is "full_image", which for an image file, doesn't have an extension like .png, .jpg, .gif, etc. I also can't find the image file "full_image" anywhere in the filesystem for cegui or ogre. My Question: how can I go about changing the image I have to an image of my own creation? (i.e. crosshairs.png)


I believe that in 0.7x you are still require to use Imagesets to use textures. An imageset is an xml file that references a texture (bmp, png, etc.) and defines sub-images to be referenced in the looknfeel/layout/properties of windows. Typically people create a sub-image entry in the imageset called "full_image" which defines the area for the entire texture. Take a look at this FAQ entry on the wiki. If you want to set a windows image property, it would look something like this: window->setProperty("Image", "set:<imagesetName> image:<subImageName>").

Also, I don't mean to get ahead of myself, but will transparency in an image file show up as being transparent in my rendered window as well?


CEGUI does support transparent imagery.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests