Example based on Clay's Wiki Tutorial #1

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Example based on Clay's Wiki Tutorial #1

Post by saetrum »

Hi everyone,

1st off I want to thank Clay for his work on the Tutorials on the wiki. They are outstanding.

2nd - I've followed the first tutorial and made a small sample program which integrates the tutorial and adds a CEGUI menu and a (very) basic state machine.

3rd - I'm still learning all of this stuff, so if you see mistakes (I'm sure there are many) let me know. I'm not professing to be an expert here. I just want to help, and be helped. :lol:

I wanted to make this available for people to look at in the hopes that:
1) it will help someone who is struggling to integrate CEGUI into their project/tutorial.
2) I can get feedback and suggestions on how to improve my game structure (i.e. better state machine, improved resource handling - cleaning up, initializing)
3) Give a complete newbie a program they can download and run and see something immediately.

[edit] Complete project is no longer available, as it was not really useful to have my dlls without an exe. The source only version will be updated, and if someone needs the project files, let me know and I can help you get them setup.[/edit]


edit: 2/23/2005 - based on Ogre v1-0 not 1.0RC, using CEGUImk2 .2
Source only version is available here

edit: 2/25/2005 - initial version for tutorial 2 available
source only version is temporarily unavailable
To use this version, you will need to unzip this and then add the .dlls (Ogre & CEGUI) to the debug and release folders in bin. You will also need to copy the Media directory from ogrenew/Samples over the top of the existing Media directory.
Last edited by saetrum on Thu Mar 03, 2005 1:12 am, edited 7 times in total.
Mr. Turner
Halfling
Posts: 88
Joined: Sun Sep 05, 2004 7:01 pm
Location: Belgium

Post by Mr. Turner »

Hi,

This is some great work, it could have spared me a lot of time figuring out CEGui - Ogre.

For the suggestions, I would declare the renderer, scenemanager, GUI_System as static in the base state class. So all inherited classes have it automatically set the right pointer.

BTW: I'm still getting some errors with Ogre 1.0 RC & latest CEGUI, when the gamestate is changed.

It's really cool that you want to do this.

Mr. Turner
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Thanks for the encouragement.

I will look into making some static variables for the main system related objects.

What error are you getting when changing states? Maybe I can help.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

New version available with Load screen & static member variables as suggested. Also uses windows look instead of Taharez look for CEGUI.
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1

Post by Clay »

Very nice. You motivated me to get off of my ass and update the wiki with the Ogre 1.0.0 versions of tutorials 2 & 3. =)

One suggestion, I noticed you implemented your own singleton pattern, and it's good. Since we are using ogre though (which also has a very nice singleton interface), why not try implementing it as an Ogre::Singleton? This isn't immediately useful in this example, but if you ever need to subclass your singletons you will want to use Ogre's Singleton interface or something similar. Might be good practice.

Edit: Oh, if you are using that framework for a full game you might want to chunk off your state machine and your states into their own classes, and have your GameStateMachine + GameState inherit from them. The primary reason is that you may have to use the state patern again later on, so you don't want to duplicate the code. Just a suggestion though.[/list]
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Thank you again for your tutorials. They are very well written and easy to follow! 8)

I guess I didn't realize the Ogre::Singleton was as flexible as it is. Looks like it would be very useful to use. It looks like you can make a base Singleton class and then inherit from it...that's a nice feature!

I'm not sure I understand the suggestion about the state machine. Are you suggesting that I split the GameStateManager (poor naming on my part it should be StateManager) into multiple classes? Or are you saying the GameState should be more like a StateManager with several states contained within it?

I'd really like to improve my design, so I'd appreciate any and all suggestions that you can offer.

Thanks!
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1

Post by Clay »

Ah sorry, I misunderstood what you were doing (I didn't get fully familiar with the code). You are doing basically what I suggested, I just didn't notice.
They are very well written and easy to follow!
Thanks. =)

I think I might not be able to make this week's tutorial. We'll see.
Mr. Turner
Halfling
Posts: 88
Joined: Sun Sep 05, 2004 7:01 pm
Location: Belgium

Post by Mr. Turner »

The windowslook looks better indeed.

The new version also fully works on my comp. I guess it was something in my cegui config.

BTW: If you want to support the latest version of CEGui (and Ogre), you should add the resourcegroup to the createTexture(texturename, "General").

Don't know if you already looked at the SSSF FrameWork. Maybe you can borrow some ideas of it.

MT
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »


I think I might not be able to make this week's tutorial. We'll see.
No problems...you've given me plenty to work with at the moment.
Ah sorry, I misunderstood what you were doing (I didn't get fully familiar with the code). You are doing basically what I suggested, I just didn't notice.
Actually, you gave me an idea, after saying this. I think that it would be useful to have a StateManager(currently GameStateManager in my code) and then have a GameStateManager inherit from it. The StateManager would handle all the menu related states, and the GameStateManager would handle the various game states. I think this will require a little tweaking depending on what type of game is being designed however.

BTW: If you want to support the latest version of CEGui (and Ogre), you should add the resourcegroup to the createTexture(texturename, "General").

Don't know if you already looked at the SSSF FrameWork. Maybe you can borrow some ideas of it.
I didn't realize that texture had changed recently. Is that in 1.0 RC, or in CVS head?

I haven't looked at SSSF framework, I'll check it out. Thanks.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

New Version uploaded. Many of the suggestions implemented. Added Credits page. Use Ogre Singleton. Changed GameStateManager to StateManager. Used more XML for CEGUI instead of c++ code.

Next release will probably be source only, as I am running out of space.
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1

Post by Clay »

Yeah, if you post stuff like this you should split the media into its own zip so you can post multiple copies of your code really cheaply (add a note in a readme about needed the media folder and where to get it).

Actually your dlls are useless for me anyway since you don't include an executable file. If I have to compile and link the application I have to use my DLLs anyway, since I'm using the pyogre version of the Ogre dlls.
notatoa
Gnoblar
Posts: 7
Joined: Tue Nov 16, 2004 11:41 am

Post by notatoa »

Hi, can anyone give me the source only, I have slow dial-up and cannot download 23 mb :cry:
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Source only version is available. See link in the 1st post. Note, this version does include the background image files as well as the windowslook.scheme and .tga. As these are not included in the Ogre samples media directory.

It's only ~460KB, so I will keep including those files unless the download becomes too large again.
Mr. Turner
Halfling
Posts: 88
Joined: Sun Sep 05, 2004 7:01 pm
Location: Belgium

Post by Mr. Turner »

I didn't realize that texture had changed recently. Is that in 1.0 RC, or in CVS head?
It's in the CEGui Mk2 CVS HEAD. That's the only thing that changed.
You could also comment it out, so if users get the error, they can switch while users of the older system still have working code.

Mr. Turner
notatoa
Gnoblar
Posts: 7
Joined: Tue Nov 16, 2004 11:41 am

Post by notatoa »

@saetrum : thanks for the source and for the example in the first place :D , they are really helpful

@clay : thank you for providing the magnificient tutorials, I hope for it to continue.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

I'm glad it's helpful. I will try to get out a new version of the source files out today with some more changes. New fonts, and high scores added (reading & writing to a file - based on the YAT high score table).
notatoa
Gnoblar
Posts: 7
Joined: Tue Nov 16, 2004 11:41 am

Post by notatoa »

I am trying to get a simple thing to work but can't.. :( , While an ogre scene is rendering , if I press escape I get the menu (which clears the screen). How do i pause the rendering (when the menu comes up) and resume it (when I exit the menu) ? Any ideas would be great.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

I haven't implemented that feature yet, as you can tell, but there are the pause & resume functions that you can use. That way you can put all the code you need to to halt the animation in pause (shouldn't really need to do anything) and all the code to resume the animation in resume. Then in the state manager instead of calling initialize and cleanup, it will call resume.

The main code change is in the frameStarted and frameEnded functions, make them change state without cleaning up. This will serve as a pause, but you will probably want to add something to the pause function, so that you know it is paused. I.e. write "Paused" across the screen or something to that effect.

edit:

I will update this project to use ogre 1.0 final as soon as it's released. Until then, I am working on refining some of the UI screens and other small maintenance tasks.

Thanks.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Removed the link to the full project as it wasn't helping experienced users, and it was confusing new people. The source only version will be updated as I work on it. Currently the source only version (see first post for download), is compatible with Ogre v1-0, not with Ogre 1.0 RC. That means you have to download Ogre from cvs, or wait for Ogre 1.0 final to be released.

I know this isn't very newbie friendly, but I was having a lot of problems trying to maintain the older version. Let me know if you have questions, getting ogre from cvs is actually very easy.

Latest version of CEGUI was used as well.

A few things have been added: high scores table, with file input/output (binary), options state, high scores sort.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Just to let everyone know that I have started on tutorial 2 and have updated the project to reflect my progress there. You can download that version from the link in the 1st post. I've also renamed some of the files and restructured so that example application and example framelistener are no longer used.

I don't know if I'll keep updating this post with the changes as they will be more and more specific to my particular project and less generally useful. However, if there is anyone who wants updates, let me know and I'll reconsider.

I will try to post a version of all of Clay's tutorials however.

:D
User avatar
Goosey
Halfling
Posts: 88
Joined: Wed Sep 29, 2004 3:33 am
Location: Ohio, USA

Post by Goosey »

Just thought I would give anyone getting General Protection Fault crashes a heads up: I was able to fix it by replacing the xerces-c_2_5_0.dll with the one from the CEGUI VS7.1 Dependencies package. I imagine it is related to this issue: 1.0 : Problem running Demo_Gui.exe

Will probably only affect VS7.1 users, but if you have this problem maybe this is how to fix it.
I <3 the OGRE Wiki, and SO SHOULD YOU! :)
DarkBrute
Kobold
Posts: 32
Joined: Sun Feb 20, 2005 7:08 am

Post by DarkBrute »

Aren't Clay's tutorials the ones who explain how to get started on the OGRE programming?

If so, I got a question. I used one of them (the one where you make a ship appear and you can move it around) but it doesn't seem to work with the precompiled versions.

I mean, they generally work, until it gets time to manipulate the ship. I think it is because the directories are different.

So, how would I fix this?
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Actually Clay's tutorials are the "intermediate" tutorials, and should be tried after completing the other tutorials. Check out the wiki for more info on Clay's tutorials. They really are good!
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

Latest source for tutorial 2 uploaded.

Changes include: options screen allows you to choose the scale of the robots. Left click creates a robot, middle click moves all robots to that point. Robots have a random speed. Robots stay ontop of the terrain. No robot limit (my 4 year old son got ~250 robots on screen before he was bored :lol: )

Things I need help with: Why don't the robots turn correctly? They sometimes turn, but other times they "sidestep" to the next point. Check out the code in Walker.cpp if you get a chance. Any advice is welcome.
gabriele_scibilia
Gnoblar
Posts: 13
Joined: Tue Mar 15, 2005 4:59 pm

Post by gabriele_scibilia »

Please add this to your overridden ExampleApplication::setup(), just for those are hitting ESC cancelling the config dialog box.

Code: Select all

	if (!ExampleApplication::setup())
		return false;