[Solved]Mount Points in jME. Not following animation

Hi, thought i'd start a new thread for this, rather than clog up Releases.

I have now come so far that i can see the mounted object inside my app. It doesn't however follow the animation, so i must do something wrong somewhere. Here's how i do it:

  1. I create a new AppAttrNode.
  2. I attach the AppAttrNode to my actor.
  3. I attach the loaded mesh to my AppAttrNode.



    Here's what the mount point looks like in the .xml file:



<com.jme.scene.Node name="Hand_L">
                                            <userData>
                                              <MapEntry key="stringSpatialAppAttrs">
                                                <Savable class="com.jme.util.export.StringStringMap">
                                                  <keys>
                                                    <String_0 value=""/>
                                                  </keys>
                                                  <vals>
                                                    <String_0 value="jme.implClass"/>
                                                  </vals>
                                                </Savable>
                                              </MapEntry>
                                            </userData>
                                            <localTranslation x="-0.032545" y="0.224859" z="-0.065038"/>
                                            <localRotation x="0.835259" y="-0.021555" z="0.549434" w="0.000517"/>
                                          </com.jme.scene.Node>



I have included "com.jme.util.export.*" in my classpath.
What have i missed?

Thanks

Edit: i construct the the AppAttrNode with "new AppAttrNode("Hand_L");"
rickard said:

Hi, thought i'd start a new thread for this, rather than clog up Releases.
...


Good.  Thanks.

It's 2:30 a.m. here and I am all used up.  Please zip up your *.blend, *-jme.xml, and referenced relative resources and post the URL or email me the zip.  I'll investigate tomorrow.

I am too tired to be giving any advice, so don't depend on this, but it looks like you have entered your game property wrong.  It looks like you have the property key as "" and the value as "jme.implClass", where you need the key to be "jme.implClass" and the value to be your absolute impl. class name.  IIRC, jme.* properties are used internally by HottBJ and are therefore filtered out from userData (all non-jme.* game properties get passed as userData).

You were right, the key/value was wrong.



Now it looks much better:


<com.jme.scene.Node name="Hand_R">
                            <localTranslation x="0.016654" y="0.224727" z="-0.066902"/>
                            <localScale x="-0.182551" y="0.998734" z="0.183792"/>
                            <localRotation x="0.999993" y="-0.002316" z="-0.000078" w="0.002787"/>
                          </com.jme.scene.Node>



The attached item shows up, and moves along with the animation.

I have however not figured out how to use the AppAttrNode, so if you have time to explain it a bit more in detail, or supply an example for how to configure it for a mount point, it would be very appreciated.
Currently, i have done a work around that looks like this;

public void attachItem(String attachPoint, Spatial item, boolean mount)
    {
        Node mountPoint = (Node) this.getChild(attachPoint);
        if (mount)
        {
            mountPoint.detachAllChildren();
            mountPoint.attachChild(item);
        }
        else mountPoint.detachChild(item);
        updateGeometricState(0, true);
    }



rickard said:

You were right, the key/value was wrong.
...

I have however not figured out how to use the AppAttrNode, so if you have time to explain it a bit more in detail, or supply an example for how to configure it for a mount point, it would be very appreciated.
Currently, i have done a work around that looks like this;
...


The class JavaDoc comment for AppAttrNode.java accurately explains its purpose.  It just allows you to pass data from Blender to jME along with your exported model.  There is nothing Mountpoint-specific about it.

The general technique of using jme.implClass is the critical part for custom game integration.  Since on the jMonkeyEngine side, the jME Node corresponding to the Armature is the top-level node effecting everything in that Skin & Bones model, I recommend that you set jme.implClass for this Armature Object.  In your Node subclass, you can implement anything you want to, including centralized management of animations, poses, SkinTransferNode assimilations, Mountpoints, and morphing for that model.  Just navigate the scene below himself (the armature Node), making use of Node.descendantMatches() to load all of your instance field values.

Two ways to automate Mountpoints are to use a Blender item naming convention or to pass item names via Game Properties.  The later technique of information passing is demonstrated by AppAttrNode.java.  On the jME side you can figure out which items are Mountables and which Nodes are Mountpoints by using the passed data and Node.descendantMatches() (narrowing by class and/or parts or all of name).  I classify my Mountpoints so that shoes and boots will only get mounted onto feet, and torches and aces will only get mounted onto hands, but that isn't necessary for small-scale games.

Since you have a program that successfully does a mount, you have all of the necessary pieces.  To integrate all of these pieces for you would be to write your game, and I'm not willing to do that.

(I may or may not copy some of what I've written here into the HottBJ Game Integration tutorial).

Thanks for the explanation. I think it's a good idea to get it into the game integration tutorial.

It seems my method does the trick, even though it's not the AppAttrNode path. If i get the hang of it, i'll convert to use it, since it seems to be more convenient in the long run.