MouseEvents and OgreDotNet

ColeZero

25-03-2006 18:56:34

Hi,

i'm working on a 3DEditor. It's completly written in C#, and its using Ogre 1.20....

Iam using a Panel as a Viewport for rendering all the ogre stuff.
like in the windows-forms demo.

Now my question:

i want to click on that viewport and select the rendered mesh-object for example..
The Problem ist how to use the Mouse- and Framelistener in the windows-form, to create a ray and so on...
i mean, if i activate my frame- and mouse listener the mouse is only in my OgreRenderViewport and not on a windows form.

And i can't use the windows-forms MouseEventAgrs because the coordinates of the mouse a relative to the desktop.

its hard to explain.....and i hope someone knows what i mean,
sorry for my bad english^^

Before, i used Irrlicht.NET in my 3DEditor and it worked fine, but now i want to Ogre.

the_cX

26-03-2006 03:23:47

i would not try to use any of the ogre input in this case.

set up a call back for a click event on the control that your rendering to. the x,y coordinates that you;; receive are relative to the controls position, not the desktop. at that point you can make some type of method to 'inject' that mouse click into ogre, ie. tell ogre that a mouse click has happened at x,y.

although you might have to do something even more clever because mouse events for Windows.Forms.Panel have been deprecated in .net 2.0.

Robert Isele

26-03-2006 18:33:36

mouse events for Windows.Forms.Panel have been deprecated in .net 2.0.
really? According to the docs the Panel.MouseClick event is new to .Net2.0 and not declared as deprecated.

the_cX

26-03-2006 23:06:40

your right.

my bad, my memory got jumbled there for a second.

it was key events that were deprecated on Windows.Forms.Panel, not mouse events (except for PreviewKeyDown).

so to ColeZero:

the mouse events should be a snap to get working for your editor, but your going to have to do some magic to get the key events to work. ;)

ColeZero

27-03-2006 17:00:24

Ok thx,
iam working with VS2005, so i'm using .NET2.0.

The magic, that you mean is the problem right now^^
But i figured out how i can solve it, maybe i release a simple demo showing what i mean, its a little bugy, but i think it will work

the_cX

27-03-2006 21:42:44

cool.

tell me how your solving it...

Robert Isele

27-03-2006 23:51:54

I think you could just register to the keyevents of the parentform and only process them if the panel actually got the focus.

EDIT: you could use a UserControl instead of the Panel aswell. That's what I do. UserControls support both mouse and key events. plus while the panel only supports the mouseClicked event, the UserControl supports also the MouseDown and MouseUp events (might prove usefull in some cases)

ColeZero

28-03-2006 16:44:37

Yeah iam using a UserControl, iam working on a Library, something like an OgreManager.

With the .dll you can create a Viewport, like a Panel, there you can use the events...
and it worked i can rotate my simple Box with the mouse in the view but there a still bugs.
I have to catch exceptions, like if you don't have selected an object, for example..

leep

26-08-2006 08:17:50

ColeZero: Dont' know if you're still monitoring this thread, but did you ever have any more luck getting input (keyboard/mouse) from the windows form into Ogre? I'm getting ready to embark on that exact same adventure and any samples/pointers you could throw out here would be benificial not only to me but probably many others who browse this forum as well! :D Thanks a TON in advance! :)