Basic application design?

Luth

27-03-2008 09:37:55

Hi!
I'm looking into Mogre a bit those days and trying to experiment a little. Since i'm pretty new to 3D-Engines, i got some questions regarding the design of an basic application. Maybe you guys can help me out there ... or at least give me a hint, that this may be the wrong forum. ;-) Basically i'm concerned about that mainloop vs. input vs. Framelisteners thing and timing ...

It all began when i was a bit bewildered about one of the tutorials mentioning:
In practice, these two things are virtually interchangable, but I have found that these usage guidelines work well for me:

1. If you are updating objects which are being rendered you should use a frame listener to update it every frame. For example, if you are moving an object incrementally across the screen, you should use frame listeners.

2. If you are performing an action which should happen often, but the result of which is not being directly rendered to the screen, you should use a Timer. For example, let's say your program is running at 600 FPS. You do not need to poll the keyboard, joystick(s), and network interfaces every frame (which would be 600 times per second) when polling it 10 times per second wouldn't be a noticable difference to the user.


Erm .... WHY? If this all works as i imagine, it means that the moved object is moving quite fast on a fast computer/low detail scenery and slower on other occasions? So i guess whenever i want something to run at the same speed on different computers, i would have to stick to timers or some other external control mechanism?

Currently it seems that if i want to build a networking application, pulling data out of a database (mainly on user request), let the user manipulate it and visualize it, i could do that with a design like this:


Mainthread:
1. Initialize Application
2. Initialize Ogre (Start a rendering thread)
3. Begin Loop
Listen for Network-Events
Apply changes to data
Listen for Timer-Events
Apply periodical manipulations to data
Listen for userinput events
Apply user changes to data
End Loop

OgreThread:
1. Run Loop
Handle FrameListeners
If Data changed flag =>
Update scenegraph, move objects etc ...
Stop


Doh ... i'm a bit confused about all that. But if this is correct, the resulting programm should handle data changes as soon as they occure no matter how fast the system is, but always rendering it with the highest possible speed.

I could need a hint there, if it is wise to put the rendering in a separate thread and how to initialize mogre that way. Or an advice that other approaches may be more preferable. Maybe make the rendering in a main thread and put the rest in a separate thread, or put rendering and user interaction in one thread ... or stick to one thread completely? Does anyone have good or bad experience with this approach?

Zool

27-03-2008 10:08:14

It'd be better if you posted this question in the main Ogre forums, since it's about general Ogre usage, not specific Mogre/.NET related.
There are a lot of Ogre experts there and you'll get better help.

Luth

27-03-2008 16:24:08

Hmm...right.
Almost thought something like that. If a mod reads this he may delete this thread if it's nerving around here, i'll repost it on the main forums. :mrgreen: