[Solved] Vb.Net - Entity.GetAllAnimationStates

GregH

27-01-2006 10:13:40

Hi Folks,

Ok...so I've created some animated meshes in Max, and I can make 'em fly, swim, crawl and vote. :roll:

I can do this because I created the meshes and I know the name of the states that I used when creating the suckers.

Soooo...I thought hmmm...there must also be a way of interrogating the mesh (as an Entity) to obtain an array or collection of some kind containing the AnimationState names as strings.

This led me to...you guessed it... Entity.GetAllAnimationStates, which I had hoped would do the trick. But my IDE is telling me that this returns a type OgreDotNet.SWIGTYPE_p_std__mapTstd__string_Ogre__AnimationState_t

that I haven't got clue one about using !!!

Do I parse it, peek it, poke it or serve it with a good chianti?

I then trawled the main forum on this topic, and stumbled onto a post that referred to a type AnimationStateSet (that does not appear anywhere in OgreDotNet ???). Ouch.

Ideally, I would like to build an array or collection of anim state names without having to resort to parsing the original XML skeletons files (which kinda leaves one's IP out there for anyone to snavel).

Cheers,

G. PS// The Vote animation was the hardest by far.. :wink:

rastaman

27-01-2006 14:08:08

Hi GregH
you need to update ogredotnet from cvs. It should have been in cvs since Dec 27.

GregH

27-01-2006 14:27:00

Hi Rastaman,

Thankyou for your advice...however I know I'm going to have trouble getting the cvs stuff...

When I use Tortoise CVS with the :pserver: stuff it says something along the lines of "try using a legal CVS password" (and then breaks a pane of glass to make me feel good).

This forced me into using prebuilt binaries which I suspect are out of date. I think the ones I have are based on 1.04, but I see references to 1.06 in various threads.

I know this question has probably been asked a thousand times, but please where is a (reliable) source for the latest prebuilt binaries (assuming that's what will solve my original Q) ???

The "Sticky" thread concerning Prebuilt Binaries is dated Sep 24, 2005...which pre-dates the update you've referred to, and the binaries I have appear to be later than that...I think I got them from a post by AlbertS.

Cheers,

G.

alberts

27-01-2006 15:39:10

I posted a link to the latest prebuilt binaries in this thread.

I think it would be better to unlock the "sticky" thread about the prebuilt binaries.

GregH

27-01-2006 22:16:43

Hi Rastaman, AlbertS,

Thank you for your advice about obtaining the latest binaries...and I have to agree with you AlbertS that the Prebuilt Binaries sticky thread will do more harm than good if it isn't the latest build. Thanks for providing me with 18-01-2006 version.

This said, unfortunately Rastaman I still cannot locate (using Object Browser) a type/class called AnimationStateSet into which to load the results from Entity.GetAllAnimationStates() ... so there is still no way I can find to interrogate an entity to determine what animations are available.

Any more ideas guys?

Cheers,

G.

rastaman

28-01-2006 00:06:06

it's there i just downloaded and checked.
update your reference, delete it then re-add it.

GregH

28-01-2006 02:14:42

Hi Rastaman,

The IDE copied over the top of the new versions with the older (referenced) versions...so I re-referenced and yes, AnimationStateSet is there. Now I try and get it working. Thanks once agian for your assistance.

Cheers,

G.

GregH

28-01-2006 02:57:33

Hi Folks,

Well I think I've almost figured out how to access the set of animations stored in a mesh file. The following code correctly reports that my Seagull has 5 animations attached. :lol:

Of course the latest snag is using the unusual (at least for VB.Net) method of iteration !!! This is the closest I can figure out based on some advice concerning overlay elements provided by EagleEye... but I crash in the loop. I figure one of you will know the answer immediately, so thanks in advance. :o



Dim MyASS As New AnimationStateSet
Dim MyASSIterator As New AnimationStateIteratorWrap(AnimationStateSet.getCPtr(MyASS).Handle, False)

Dim ThisAnimationState As New AnimationState

MyASS = SceneObjectLib("Seagull01").Entity.GetAllAnimationStates

Debug.WriteLine(MyASS.size.ToString) 'Correctly says 5 (animations)

Do While MyASSIterator.hasMoreElements

'retrieve values here...

ThisAnimationState = MyASSIterator.getNext()

Debug.WriteLine(ThisAnimationState.AnimationName)

Loop



..sorry about the variable names, but that's the way the acronyms panned out.

Cheers,

G.

rastaman

29-01-2006 02:03:25

MyASS.size.ToString) 'Correctly says 5
lol :p

ok the iterator thows an exeption in getNext if there are no more elements. put a try/catch around it.

how does it crash any error message?

GregH

30-01-2006 06:42:49

Hi Rastaman,

VB.Net crashes on the line:



ThisAnimationState = MyASSIterator.getNext()



with the error "Object reference not set to an instance of an object." , which indicates that the getNext method isn't working correctly. Perhaps I have the syntax for obtaining a handle to MyASS incorrect - after all, I'm only guessing how to use the Iterator? I know the actual AnimationStateSet is doing it's job because it has 5 elements.

Putting a Try/Catch around the error just gives me an infinite list of "Object reference not set..." messages, so it's not as if getNext is returning 5 valid objects before it collapses.

Any ideas are welcome, as I wanna get MyASS further down the OGRE road !!!

Cheers,

G.



rastaman

30-01-2006 16:04:49

Hmm... I need to learn to see past MyAss :P

Here's the deal, in Ogre the only place you get an AnimationStateIterator is from SceneManager.getAnimationStateIterator. It iterates though all the states loaded in the scene. Entity.GetAllAnimationStates returns an AnimationStateSet for a specific Entity. But you cannot convert the AnimationStateSet to an AnimationStateIterator.

AnimationStateSet is a wrap of std::map but the swig to C# wrap does not convert over a way to iterate though it. So you need to know the state names to get them. I am working on a new_std_map.i that will have a getByIndex(int index) function witch you could use in a for loop.

Sorry I didn't read all you code at first it was an all around mest up weekend, I didn’t get much of anything done.

rastaman

30-01-2006 16:20:11

Oh and I mistakenly added an ignore for SceneManager.getAnimationStateIterator. I was having problems with the MapIterator in SceneManager.
I will try and get those salved today and update cvs.

GregH

30-01-2006 22:48:51

Hi Rastaman,

Thanks for your thorough and timely reply. The reason I feel it's so important to be able to retrieve the states programmatically is that I really dislike having to use string literals (for any purpose) in my code because the IDE cannot validate them. Using iteration I can at least be sure that the animation states I have loaded will be correct for any given entity.

Having said that though, I will still have to use string literals to specify which sequences to enable at runtime (unless I can figure out a way to make a dynamically created "stringy" enumeration that the IDE can present to me when I want to specify a state - which I don't think is possible because VB.Net enums only support numeric values - hmmm perhaps I could use a lookup table?).

Anyway, my next issue will be getting your new code from the CVS because I haven't been able to use Cygwin or Tortoise properly yet.

I shall eagerly await a message from you when the fix is done.

Thanks once again for all of your help.

Cheers,

G.

rastaman

30-01-2006 23:26:49

try wincvs, it works for me.
wincvs.org

EagleEye

31-01-2006 03:34:03

try wincvs, it works for me.
wincvs.org


I like tortoise.

If you set it up right, you won't have any problem.

EagleEye

31-01-2006 03:35:52

Just so you know Greg, anything that has a prefix of "SWIGTYPE" is a class/struct/object that hasn't been wrapped yet. Don't try to use them. :)

If you need any of them wrapped, post it here.

GregH

31-01-2006 13:45:57

Hi Guys,

It's half-past midnight here and I've managed to use WinCvs (thanks RM) to get *all* of the OgreAddon projects... it took 30 minutes or so, and now I'm now up to MyAss in addons !!

I will now sit on (no, I won't say it) until the iterator Rastaman is fixing becomes available, and then I'll pull the rest of the OGRE world onto my laptop.

Cheers,

G.

GregH

31-01-2006 14:10:56

Hi EagleEye,

Thanks for the heads up on SWIGTYPE ... I was wondering WT* they are used for, and have wasted *many* hours trying not to bother the forum with dumb q's.

If I stumble onto another one of these SWIGTYPE suckers that I think I will need, I'll take up you're invite for help.

Soooo...just waiting on Rastaman for the anim iterator fix, and then I'll stumble into the next abyss (but hey, I've climbed out of much worse before !!!). Now that I've got a CVS downloader working, I think I can increase my independance a tad...

Cheers,

G.

GregH

31-01-2006 14:31:02

Hi Folks,

It just dawned on me to ask this question. Why hasn't anyone else wanted to know what animations a mesh holds? Is it early days for this kind of stuff? Or is there something I'm missing about loading a mesh into a scene and then animating it with retrieved sequences?

Cheers,

G.

EagleEye

31-01-2006 14:40:50

It just dawned on me to ask this question. Why hasn't anyone else wanted to know what animations a mesh holds? Is it early days for this kind of stuff? Or is there something I'm missing about loading a mesh into a scene and then animating it with retrieved sequences?


I think most people know the animations because they create their own meshes... I had to go looking through the ninja.mesh file to find out the names of bones and names of the animations, so it's something I'd want to use too.

edited to add: Also realize... ODN got started sometime last year, like in June or so perhaps? It's very new, and we don't have many people really USING it yet.

GregH

01-02-2006 08:22:15

Hi EagleEye,

Yes...I think obtaining the state names from a mesh is of paramount importance for a whole bunch of reasons (as detailed elsewhere in my earlier posts).

And now you have told me :wink: , I can realise that OgreDotNet is younger than I thought !!! This kinda makes me feel better, as I might not be so far behind the 8ball as I thought...but then again it may mean I'll hit a lot of unresolved issues like the one in this current thread.

Anyway, I know Rastaman is slaving over a hot CPU resolving the iterator issue as we speak :wink:

Cheers,

G.

rastaman

01-02-2006 14:24:38

the fix is in cvs now.

all classes derived from std::map have functions getitemValue(int index) and getitemKey(int index).
so with a for loop you can retrieve each KeyName and Value.

Edit: not iterators, they already had it. classes derived from std::map

GregH

01-02-2006 22:41:12

Hi Rastaman,

Wow !! That's great...and so quickly too !!

I've got CygWin working to retrieve the source - now all I have to do is figure out how to compile and use it. That should take me a week or two given all of the unknowns I'm dealing with...for example what files to build and what's compatible with what etc.

I'm really looking forward to being able to load a mesh and automatically access the animation states using a simple loop. Yay :lol:

Cheers,

G.

GregH

03-02-2006 07:20:27

Hi Folks,

I've compiled the latest CVS edited by Rastaman recently, and can now iterate the animation states for a specific entity's mesh. My debug window now tell's me:

Animation # 0 = BankLeft
Animation # 1 = BankRight
Animation # 2 = Idle
Animation # 3 = LargeFlight
Animation # 4 = SmallFlight

Interestingly, they are in alpha order, not the order I created them in Max 7, but that doesn't matter a hoot !!! Now that I can maintain a dynamically created library of valid anims without having to resort to IteratorWrapper Voodoo Bones, I'm one happy Ozzie !!! :lol:

Thanks Rastaman !!!

Cheers,

G.

GregH

04-04-2006 13:32:37

Hi Folks,

Sorry to reactivate this thread...but some changes have obviously occured to do with retrieving animation states (which I did have working perfectly).

Recent changes in the SDK/OgreDotNet combo seem to have deleted:

AnimationStateSet.Size ...and...

AnimationStateSet.getitemValue()

These are both very important to my project, which uses them in this context:




Dim NewAnimationSet As New AnimationStateSet

NewAnimationSet = NewSceneObject.Entity.GetAllAnimationStates

'We now have zero or more animation states stored in NewAnimationSet.

Dim AnimationCount As Integer = MakeIntFromUInt32(NewAnimationSet.size)

Dim Ptr As Integer

For Ptr = 0 To AnimationCount - 1 'NewAnimationSet is zero-based.

NewSceneObject.AddAnimation(NewAnimationSet.getitemValue(Ptr).AnimationName)

Next Ptr




It may be that there is a new method for determining the number of animations attached to an entity, and then determining the name of each, but I've simply run out of puff trying to migrate from VS 2003 to 2005...any advice would be greatly appreciated.

BTW...these are the last two (obvious) errors standing between me and a running ODN app.

Cheers,

GregH.

rastaman

04-04-2006 14:46:20

this is a core change of Ogre 1.2
It's not stated spcificly but its good to know whats going on in ogre to use ODN DagonNotes
AnimationStateSet is now a class not just a typemap. In it there are 2 functions both return a Iterator.
public AnimationStateIteratorWrap getAnimationStateIterator()
public ConstEnabledAnimationStateIteratorWrap getEnabledAnimationStateIterator()

An Iterator can be used in a While or Do loop. DON'T use getNext and moveNext at the same time. The Iterator classes are like forwardonly recordset.

GregH

04-04-2006 22:58:55

Hi Rastaman,

As I'm a VB.Net programmer, I've never used one of these Iterators that you are describing...could you (or anyone else) provide a short code sample (eg: using the code sample I provided when reporting this new problem)? I expect other folks will want to know how to do it too, as this thread has had 900+ viewings !!!

I will also check out the DagonNotes thing...

Cheers, :)

GregH.

GregH

11-04-2006 05:56:44

Hi Folks,

As Rastaman suggested, there has been a class change that now requires the use of an iterator to access the animations in mesh.

Please visit http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=926
to view my notes on this topic.

Cheers,

GregH.