VB.Net - Cannot create/cast an OverlayContainer

GregH

01-01-2006 02:31:53

Hi Folks,

Well I've been using OGRE for about a month now - and getting to the end of Tutorial 3 has been a challenge - but I now have a foggy terrain with animated skydome and a moving camera. The Singleton thing had me stumped for a while (as I haven't had cause to use them in VB.Net).

My latest issue is not being able to create an OverlayContainer. Yes, I know the OverlayManager can create OverlayElements which can later be cast to OverlayContainers, but I'll be damned if I can figure out the syntax in VB.Net to achieve this seamingly simple task...

I've tried various approaches such as:

Dim MyPanel As OverlayElement = OverlayManager.getSingleton.CreateOverlayElement("Panel", "PanelName")

Dim MyContainer as OverlayContainer = CType(MyPanel, OverlayContainer)

...to try and cast MyPanel to a container...but I keep getting Invalid Cast.

Is there anyone out there that has coded nested overlays in VB.Net???

Kindest regards,

Greg H.

rastaman

01-01-2006 05:08:17

may need more helper function i don't see one to get a OverlayContainer but you can get the pannel it should have all the container functions.

dim myPanel as PanelOverlayElement = OverlayManager.getSingleton.CreatePanelElement( "PanelName" )


or to get the container like this:

dim el as OverlayElement = OverlayManager.getSingleton.CreateOverlayElement("Panel", "PanelName")
dim myContainer as OverlayContainer = new OverlayContainer( OverlayElement.getCPtr(el).Handle , false )

GregH

01-01-2006 05:58:05

Hi Rastaman,

Well the Visual Studio IDE likes your syntax for creating an OverlayContainer !!!

I knew about the New() constructor, but wasn't sure what params to pass it.

I'll let you know when my first overlay graces the foggy terrain.

Thanks heaps !

Greg H.

GregH

01-01-2006 06:55:49

Hi Rastaman,

I can hardly Contain myself (pardon the pun). Since applying your advice, I've created a wrapper function for taking the tedium out of conjuring overlay containers...

It goes like this...


Dim MyPanel As OverlayContainer = CreateContainerPanel("MainPanel")

...and it's supported like this...

Public Function CreateContainerPanel(ByVal pContainerName As String) As OverlayContainer

'Creates an OverlayContainer based on the Panel overlay model.

Try

'1. Create an OverlayElement..

Dim NewPanel As OverlayElement = OverlayManager.getSingleton.CreateOverlayElement("Panel", pContainerName)

'2. Create an OverlayContainer using NewPanel...

Return New OverlayContainer(OverlayElement.getCPtr(NewPanel).Handle, False)

Catch

Return Nothing

End Try

End Function


Once again, thanks !

Greg H.