SyntaxHighlighter

Tuesday 18 June 2013

Day 7: Animated Models, multiple model sets

Animated models

It turned out to be nigh on impossible to get freely downloaded models to exhibit their inbuilt animations with XNA.

Having models move about or rotate or grow/shrink by using the scene graph was a simple matter, but importing an animated model that XNA accepts and then making it animate was a different breed of problem entirely! Firstly it only recognizes .fbx and .x models at all, and secondly it wants pretty specific data included in the models - a skinning data tag, skeleton information and meshes with skinning information, and all of this needs to be XNA compatible. From the free model repositories available online (TurboSquid etc) none of their .fbx animated models worked.

12 Markers, more models

At the moment there are 12 built in marker arrays that ALVAR will happily accept, but of course it would be beneficial to have a lot more than 12 models available for the AR demonstration.

Toby suggested the idea of having sets of 12 models that could be switched out for other sets of models on the fly, all activated by a GUI system. After some investigation, I found that this idea works fine.

Nodes on the scene graph can be enabled or disabled at will. I realised this due to a functionality built in to the current AR program where pressing the space bar disables all models (so all you see are marker cards that don't produce any AR media). After studying the code I found it uses a simple call to accomplish this:
scene.RootNode.Enabled = false;

Sure enough, any node can be enabled or disabled, so revision one of the attempt to enable multiple model sets is as follows: during the addDemo methods, attach multiple demos to the same MarkerNode, but only have one demo activated at one time. The rest should be disabled. Then when the program is running switch between which demo is active, for each MarkerNode. The following diagram illustrates the concept:
How to use multiple sets of demos for each Marker Node

So to implement the model set switching code I added a few new variables. Firstly every addDemo method uses a placer TransformNode that does nothing but act as a dummy node to enable or disable the entire demo. All nodes that describe a demo are children of this placer node and this placer node connects to the corresponding MarkerNode.

These placer nodes are held in arrays modelSet1Nodes and modelSet2Nodes etc (each hold placer nodes for a set of models, that we will switch between). Now enabling one set is as simple as iterating and disabling the nodes in the arrays of sets we don't want, and enabling all nodes in the array of the set we do want.

Right, now to populate this stuff with models! Stay tuned.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.