New Wiki page, "Using CEGUI in OgreDotNet"

EagleEye

01-03-2006 19:22:05

http://www.ogre3d.org/wiki/index.php/Us ... OgreDotNet

GregH

03-03-2006 04:07:52

Hi EagleEye,

I've been implementing some of your CEGUI code in the new WIKI doc, and have managed to display an (empty) TaharezLook framewindow in the center of my OGRE render window.

I note that GUISys.SetDefaultMouseCursor is called fairly early in the process...I kind of thought that the SetupWindow sub would cause focus (and hence the mouse pointer) to shift from the main OGRE render window and into the CEGUI framewindow...but it doesn't. The OGRE Render window continues to receive mousemove input and the super-imposed framewindow sits on top and does sweet FA (that's Futile Adornment).

BTW...the whole reason for delving into CEGUI was because I wanted a mouse cursor available to try out the RayQuery tutorial. So I guess I have these questions:

1a. Is there any way to get a mouse cursor to show in the OGRE RenderWindow without using CEGUI...

1b. If so how does one control the appearance of it?


2. How do you set focus to a CEGUI "desktop", "framewindow" etc..., complete with custom cursor? As I said, I can show the framewindow, but with no cursor (despite the SubScribeEvents and Activate methods).

3. Is it correct to assume that the cursor that the User will (eventually) see over the main render window is in fact moving around inside the transparent "Desktop" window you mention in your WIKI doc, and that calculations/events are based on the position of that cursor?


PLEASE NOTE: I have not specified WithEvents for the window...could that cause the lack of mouse cursor? My empty framewindow inherits from your FrameWindowBase class, which has a WithEvents specified for MyWindow...but the IDE bitches that my OptionsWindow doesn't specify any events (which are inherited I'd have thought?)...


Cheers,

GregH.

EagleEye

03-03-2006 07:10:25

For my Ogre Event Listener, I have a bunch of event handler functions.

I also have a boolean variable called "GUIHasFocus". I have a key bound to toggling GUI focus, so that in my Ogre Event Handler functions, it will inject the relevant input in to CEGUI.

Here's my mouse stuff:

Protected Sub MouseMoved(ByVal e As MouseMotionEvent) Handles OEvents.MouseMoved
Try
If GUIHasFocus Then
GUISys.InjectMouseMove(e.DeltaX * Convert.ToSingle(Window.Width), e.DeltaY * Convert.ToSingle(Window.Height) * 3)
If e.DeltaZ <> 0 Then GUISys.injectMouseWheelChange(e.DeltaZ * 4)
Else
Dim vPitch As New Radian(-e.DeltaY * mDeltaTime * 500.0F * MouseReverse)
If (CharacterPitch + vPitch.ValueDegrees) <= 90 And (CharacterPitch + vPitch.ValueDegrees) >= -90 Then
CharacterPitch += vPitch.ValueDegrees
Nodes(0).Pitch(vPitch, Node.TransformSpace.TS_LOCAL)
End If
Nodes(0).Yaw(New Radian(-e.DeltaX * mDeltaTime * 500.0F), Node.TransformSpace.TS_WORLD)
vPitch.Dispose()
End If
Catch ex As Exception

End Try
End Sub
Protected Sub MouseDragged(ByVal e As MouseMotionEvent) Handles OEvents.MouseDragged
MouseMoved(e)
End Sub
Public Sub MousePressed(ByVal e As MouseEvent) Handles OEvents.MousePressed
Try
If GUIHasFocus Then
If Not GettingKeyBind Then
Select Case e.ButtonID
Case 16
GUISys.InjectMouseButtonDown(MouseButton.Left)
Case 32
GUISys.InjectMouseButtonDown(MouseButton.Right)
Case 64
GUISys.InjectMouseButtonDown(MouseButton.Middle)
End Select
Else
GettingKeyBind = Not GettingKeyBind
Select Case Convert.ToInt32(OptionsWindow.Page1.cmbBindGroup.getSelectedItem.getID)
Case 0
B.AddMouseBind(New Bind(TempBind.ActionName, TempBind.ActionNumber, TempBind.SubAction, e, TempBind.ActionString))
End Select
OptionsWindow.RefreshBinds()
End If
Else
DoToggles(B.GetMouseProperties(e))
End If
Catch ex As Exception

End Try
End Sub
Public Sub MouseReleased(ByVal e As MouseEvent) Handles OEvents.MouseReleased
Try
If GUIHasFocus Then
Select Case e.ButtonID
Case 16
GUISys.InjectMouseButtonUp(MouseButton.Left)
Case 32
GUISys.InjectMouseButtonUp(MouseButton.Right)
End Select
Else
DoToggles(B.GetMouseProperties(e))
End If
Catch ex As Exception

End Try
End Sub

EagleEye

03-03-2006 07:19:19

The OGRE Render window continues to receive mousemove input and the super-imposed framewindow sits on top and does sweet FA (that's Futile Adornment).

See my previous reply...

BTW...the whole reason for delving into CEGUI was because I wanted a mouse cursor available to try out the RayQuery tutorial. So I guess I have these questions:

1a. Is there any way to get a mouse cursor to show in the OGRE RenderWindow without using CEGUI...


The mouse cursor for CEGUI, as far as I'm aware, is only for use within CEGUI. I'm not sure how to show a mouse cursor within Ogre itself.

2. How do you set focus to a CEGUI "desktop", "framewindow" etc..., complete with custom cursor? As I said, I can show the framewindow, but with no cursor (despite the SubScribeEvents and Activate methods).

You have to "inject" the input from the ogre event listener in to CEGUI, as I showed above.

3. Is it correct to assume that the cursor that the User will (eventually) see over the main render window is in fact moving around inside the transparent "Desktop" window you mention in your WIKI doc, and that calculations/events are based on the position of that cursor?

Correct. You are, in fact, interacting with a transparent sheet that contains all of your windows.

I have recently decided to dump CEGUI and go with a windows forms approach, because I simply don't like the CEGUI implementation... so I won't be much further help in this topic.

PLEASE NOTE: I have not specified WithEvents for the window...could that cause the lack of mouse cursor? My empty framewindow inherits from your FrameWindowBase class, which has a WithEvents specified for MyWindow...but the IDE bitches that my OptionsWindow doesn't specify any events (which are inherited I'd have thought?)...

Naw... the withevents thing just tells the calling class to expect raised events from the base class for the type you're declaring. Use WITHEVENTS for CEGUI elements, because they ALL raise events (as they are all inherited from the "Window" base class which contains most of the events.), and you are probably going to be wanting to handle them... some events, like resize and such, you don't need to handle externally... they're handled internally by the CEGUI classes themselves (though you can override them).

The classes I defined for my windows, which contain the MyWindow objects, etc... those are foundation classes for my specific window definitions... None of those raise any events, really.

GregH

03-03-2006 08:29:30

Hi EagleEye,

Well, once again a comprehensive answer...but it has left me in a quandry. Do I keep digging into CEGUI territory, or as you say "dump it
for a Windows Forms" approach !!!

Since I am very familiar with using Windows forms, the thought is tempting. Were you thinking of creating a 100% transparent borderless form over the render window and then "skinning" other child windows with your own graphics elements? I know it can be done.

Are there any resource documents on the OGRE site that would assist in any of this? I know you'll understand that time is too short to learn new technologies that are likely to be dumped further down the road...


Cheers

GregH.

EagleEye

03-03-2006 08:37:13

Greg, it really would help if you had an IM program of some kind. All of my IM contact info is in my profile here... you could get quicker answers from me that way. :)

GregH

03-03-2006 09:24:15

Hi EagleEye,

I'll figure out how to set up an IM, AM, PM and any other M program if you can help me get a freaking cursor with which to control my OGRE render window!!! When I've set up a *M thing I let you know.

In the meantime, I mucking around with semi-transparent windows (real ones) over the top of my main render window...still can't shift focus away from render window though. :(

It's a pain, but I figure we will all need to present non-rendered options windows et al to our Users, and provide a way to interact with the main gig. Just can't see how to do that yet.

Cheers,

GregH.

GregH

03-03-2006 10:10:49

Hi Folks,

I've just been fooling around with a semi-opaque windows form with a single button that can been displayed over the top of my main render window when KeyCode.O is pressed.

It gets focus OK, I can see a suspended render of my scene through the winform, it has a cursor and when I click the button the form gracefully vanishes...the main render window resumes animation and all is happy with the virtual world, without any additional code. And guess what...you can repeat the process without problems!

There are a couple of odd behaviours that I won't trouble you with now, and that I'll crash tackle into conformity... but I'm thinking that if I can skin the winform (as I have done in the past using replacement GUI elements...eg: DinoSkin and also Terracotta) I *should* be able to create a GregHarezLook of my own without the need to use CEGUI.

Also...I've spent a truckload of time creating custom controls for VB.Net, so making a GUI with the right look and feel *should* be a walk in the park...but that's a whole other sphere of development.

Cheers,

GregH.

EagleEye

03-03-2006 19:18:58

Wow Greg, I would really love to get ahold of those custom controls. :)

I have a custom tab control that's really nice, but I would love to custom-skin my windows forms so they don't look like "default" shit, ya know?

GregH

03-03-2006 23:50:18

Hi EagleEye,

Default "shit" is right - I don't know if you Americans have heard of Fisher-Price toys - they are red, green and blue plastic with rounded edges so kiddies can't mame themselves whilst playing. Reminds me of the XP look and feel. How ummmm safe.

As I was saying before, I have successfully skinned windows forms in VB Classic - haven't tried it in VB.Net but I'm pretty sure it can be done, and I will research this and share my results.

I have also been teaching folk (that's my other job when I'm not OGREing) to create green-field custom controls with embedded animations, special behaviours etc... as I always knew that they'd be needed for games development.

On a final note: light dawned on wooden head last night :idea: Of course we can have a cursor in the OGRE render window without CEGUI !!!

I just have to create some simple cursor shaped meshes and tie them to the current unseen X-Y pointer location and voila - 3D cursors. Hell, I could even animate the little suckers...funny how your mind gets into a rut ain't it !! I can't think of a single reason why this wouldn't work.

[Edited]

Stop press: I've just had my second good thought for the day (I'll have to get drunk more often :twisted: ) ... I could make a 2D overlay panel that travels X-Y to display a cursor graphic and if I wanted to, I could use a textarea to use as a tooltip that travels with the cursor. Overlays support transparency levels, materials and can have their visibility switched very easily. I'll give it a go soon.

[Edited again]

Hmmm...there's a cursor.png in my textures folder...I think the 2D approach may have been used before...but I still claim credit for reinventing this particular wheel :wink:

Cheers,

GregH.

GregH

04-03-2006 04:02:33

Hi Folks,

Well, I now have a standard white arrow cursor moving around my render window using the 2D overlay method. The mouse 'ballistic' is a little sluggish, but in the game I'm creating it won't matter because the cursor will be center-screen for most of the time.

I'm going to try the 3D mesh-cursor approach to see how it reacts (and besides, I can do neat stuff to the little meshes using scale, rotate etc..)

Also, it appears that standard winforms can co-exist with the OGRE render window, and I rediscovered an old skinning program so I can dress 'em up for a non-Fisher Price look. Sorry CEGUI, but I haven't got time to build interfaces from pixels up.

Hickup...kinda warm in here ain't it ? :twisted:

Cheers,

GregH.

EagleEye

04-03-2006 07:24:05

Yup yup yup... here's some of what I'm doing...

rastaman

04-03-2006 18:35:48

you guys are abandoning CeguiNet ?

EagleEye

04-03-2006 19:19:09

Yeah, but not because it doesn't work... rather because it's a pain in the ass and we have Windows Forms available to us to use. Having a forms designer built in to Visual Studio is so much nicer to work with than having to do everything by hand.