Vb.Net 2005 Eihort Using Iterators


08-04-2006 14:55:53

Hi Folks,

Though it's early days, and you probably aren't as crazy as I am about tackling the bleeding edge stuff (well in fact I have no choice), the day will come when you may want to know how to use iterators...us VB.Net junkies are used to For..Each with collections.

With assistance from the_Cx, who provided some C++ code, I figured out how to extract the names of animations stored in a mesh using VB.Net. The code sample will be enough to give you the general idea so you can iterate other ...ummm...iteratable (?) its.

It goes like this:

'The following code works for Eihort...

Dim NewAnimationSet As AnimationStateSet = NewSceneObject.Entity.GetAllAnimationStates

'Only do this if we have some animations to work with...

If Not NewAnimationSet Is Nothing Then

Dim AnimationIterator As AnimationStateIteratorWrap = NewAnimationSet.getAnimationStateIterator

While AnimationIterator.hasMoreElements

'Retrieve the name of the animation and store it in the global
'animation collection...


End While

End If

...there is a caveat however...I tried to do the same thing to retrieve the available types of scenemanagers (I have a problem, because Eihort uses a different method of creating Sm's - it assumes you know the stringy name of the type you want - and I don't. The Dagon notes tell you 'OctreeSceneManager' but it doesn't support SetWorldGeometry - help please)...but the iterator doesn't appear to work:

Dim SMIW As SceneManagerIteratorWrap = MyOgreRoot.GetSceneManagerIterator

While SMIW.hasMoreElements


End While

This may be my mistake, or perhaps this functionality has not yet been implemented? Be gentle here...I'm still bruised by the migration.

Anyway, the first code snippet works perfectly.