[NEWBY] Ogre Event handling / Native .Net evt handling

Olivier

26-05-2006 21:42:42

Hi,

First, thanks a lot for all the great work.
Intallinf Ogre SDK 1.2, and OgreDotNet works like a charm.

Tutorials are great, and sample app demo is great to play around with ogre.

But then i'm a little bit confused about event handling.

Developping with c#,
I've integrated a renderWindow in a pane control.

This works all great.

Then i come to register to events, like in tut 4.

Event handling works great on the "Ogre side", but the application behave as if key and mouse events were grabbed and no more send to my visual control, hence, it prevents me from using any control.

What could i do to prevent this grab ?
What did i do wrong ?

Olivier

posixninja

27-05-2006 04:26:23

I don't have much experince with C#, but did you pass the events down to the base classes? perhaps if you posted some source someone would be better able to help you.

Olivier

27-05-2006 10:44:04

Made an archive containing the code.
Its a VC# 2005 Express project

Beware if you run this that you have to check all the ogre cfg files,
and set your classpath to access ogre and ogre dotnet dlls.

http://olivier.thevenin.free.fr/OgreDotNet%20Demo%201.zip

This example is freely adapted from SampleApplication and WinFroms sample.

The code is not (and not meant to) be great code.
Just a learning app.

The problem is:
when i click on "register events" button, the application creates OgreDotNet.EventHandler and registers events.
Then, all the windows control in the application don't receive any events anymore.

So, i wonder if i do something wrong, or if ogre input handler is grabbing all events (i guess the latest) ?
What can i do to correct this ?

Olivier

rastaman

27-05-2006 15:33:38

Hi Olivier
If you use Ogre's input manager then it will take over controle of the keyboard and mouse with directinput in windows. Look at the constructor for OgreDotNet.EventHandler there is a third paramater (bool bHandleInput), pass false there and it will not create the input manager, it will still get FrameStar/FrameEnd. Then you will need to handle input in your program.

Olivier

27-05-2006 15:56:49

Hi Olivier
Look at the constructor for OgreDotNet.EventHandler there is a third paramater (bool bHandleInput), pass false there and it will not create the input manager, it will still get FrameStar/FrameEnd.

Ok, this is clear for me now.

:oops: I should have paid much attention to this constructor.

Actually, i try to understand the ogredotnet api by using:
- tuts,
- ogre api for common objects,
- VC# introspection and source code for OgreDotNet specific stuff.

I missed this point.

Thanks very much

Olivier

Olivier

29-05-2006 22:35:00

Hi again,

i'm insisting a little bit on the event being grabbed.

As i didn't want to recompute event structure (from window style x,y to 3d world style x,y,z), and as i didn't want to go in too deeply to the moment in reinventing all that done,

i decided to shared event captured by ogre with other applications.

for this, i did modify the file : ogrenew\PlatformManagers\Win32\src\OgreWin32Input8.cpp

like this:


Index: PlatformManagers/Win32/src/OgreWin32Input8.cpp
===================================================================
RCS file: /cvsroot/ogre/ogrenew/PlatformManagers/Win32/src/OgreWin32Input8.cpp,v
retrieving revision 1.22
diff -u -r1.22 OgreWin32Input8.cpp
--- PlatformManagers/Win32/src/OgreWin32Input8.cpp 6 Feb 2006 06:18:52 -0000 1.22
+++ PlatformManagers/Win32/src/OgreWin32Input8.cpp 28 May 2006 09:49:14 -0000
@@ -101,7 +101,7 @@

// Make the window grab keyboard behaviour when foreground
hr = mlpDIKeyboard->SetCooperativeLevel(mHWnd,
- DISCL_FOREGROUND | DISCL_EXCLUSIVE);
+ DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
if (FAILED(hr))
throw Exception(hr, "Unable to set DirectInput keyboard device co-operative level.",
"Win32Input8 - initialise");
@@ -225,7 +225,7 @@
/* Absolute mouse input. We can derive the relative input from this. */
FAILED( hr = mlpDIMouse->SetProperty( DIPROP_AXISMODE, &dipdw.diph ) ) ||
/* Exclusive when in foreground, steps back when in background. */
- FAILED( hr = mlpDIMouse->SetCooperativeLevel( mHWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE ) ) )
+ FAILED( hr = mlpDIMouse->SetCooperativeLevel( mHWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ) ) )
{
OGRE_EXCEPT( hr, "Unable to initialise mouse", "Win32Input8::initialiseImmediateMouse" );
}
@@ -265,7 +265,7 @@

// Make the window grab mouse behaviour when foreground
hr = mlpDIMouse->SetCooperativeLevel(mHWnd,
- DISCL_FOREGROUND | DISCL_EXCLUSIVE);
+ DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
if (FAILED(hr))
throw Exception(hr, "Unable to set DirectInput mouse device co-operative level.",
"Win32Input8 - initialise");
@@ -323,7 +323,7 @@

mHWnd = hWnd;

- ShowCursor(FALSE);
+ ShowCursor(TRUE);


// Register with the DirectInput subsystem and get a pointer


This makes direct input events shared, and cursor visible.

I know this may not be a very good way to do it, but it suits my needs.

I have some questions about this:
1- What implications can there be to share events with every body (every things seems almost fine for me, but i know nothing about cegui and others yet. will other things still work ?)

2- With this methods, z coordonate of event is always constants (0.5). Would it be a side effect of this, or, do i miss something else in ogre ?

3- If sharing events may not be such a problem, could it be possible to set some flag in platform input manager to grab or share events depending on your needs ?

Those are not fundamental questions, but any lights will be appreciated.

However, thanks for the great job already done.
The more i use it, the more i like it

Olivier

rastaman

02-06-2006 16:05:40

Olivier:
I think these questions would be better asked in the Main Ogre Forum.