Control specific joints

i've got a ms3d-model containing a few joints. every joint is used to open and close a door inside the model (it's a dungeon). now, i need to open and close every door independently from each other. how can i do it? do i have to make my own controller, how can i achieve this behaviour with the jointcontroller somehow?



to answer the first question that will probably be asked:

no, i can't do that. using an ms3d model for every door would require a level editor of some kind (to place the doors and attach them to walls), and we have none. i agree it would be better, but for now, our level editor is milkshape.

That's shouldn't be too difficult, a JointController just transforms a bunch of meshes using animation data. All you need to do is to find the door mesh within the dungeon's hierarchy and then rotate it or whatever. I did a quick look at JointController and I can say it would be difficult to extract the animation that was created within milkshape, you should probably just do the rotation in-game.

i tried to split a jointcontroller into smaller pieces:

   @NotNull public static JointController[] splitController(@NotNull final JointController p_jc) {
    final JointController[] l_ret = new JointController[p_jc.numJoints];
    for (int l_jointIndex = 0; l_jointIndex < p_jc.numJoints; l_jointIndex++) {
      final JointController l_newJc = l_ret[l_jointIndex] = new JointController(1);
      l_newJc.addJointMesh(p_jc.movingMeshes.get(l_jointIndex));
      for (int j = 0; j < p_jc.movementInfo.size(); j++) {
        final PointInTime l_pit = p_jc.movementInfo.get(j);
        final MyPointInTime l_newPit = new MyPointInTime(l_pit.time);
        l_newPit.setRotation(l_pit.jointRotation[l_jointIndex]);
        l_newPit.setTranslation(l_pit.jointTranslation[l_jointIndex]);
        l_newJc.movementInfo.add(l_newPit);
        l_newJc.FPS = p_jc.FPS;
        l_newJc.skipRate = p_jc.skipRate;
        l_newJc.parentIndex = p_jc.parentIndex;
        l_newJc.setActive(p_jc.isActive());
        l_newJc.setModelUpdate(p_jc.getModelUpdate());
      }
    }
    return l_ret;
  }



if i remove the original controller from a spatial and add all the ones returned by the method above, shouldn't anything be animated as before? for some reason, nothing happens. did i miss something?
this is the code:

final JointController l_orgJc = (JointController) l_spatial.getController(0);
      if (l_orgJc != null) {
        final JointController[] l_childControllers = Utils.splitController(l_orgJc);
        l_spatial.getControllers().clear();
        for (final JointController l_childController : l_childControllers) {
          final String l_name = l_childController.movingMeshes.get(0).getName();
          final NamedIntRange[] l_ranges = parseIntRanges(l_properties, l_name);
          m_controllers.put(l_name, new SimpleJointAnimation(l_childController, l_ranges, l_name));
          if (l_ranges == null) {
            System.out.println("Animation info missing for " + l_name);
          }
          l_spatial.getControllers().add(l_childController);
        }
      }



ignore the parseIntRanges part, i don't use the int range yet. the childcontroller is active like the original controller was. the new controllers update methods get called. everything seems to be fine, but nothing moves...

The original creator of JointController and the other milkshape stuff has long left jME and this forum, leaving behind the rather complex code that is JointController and the related classes. I doubt anybody else has ever invested the time to understand the inner workings of the old skeletal animation system, so you are probably on your own here.

Sorry that this post is no help at all, but maybe it can explain the slow replying.

If I am wrong and there is somebody out there who can help you, I hope this isn't stopping them from doing so!



To add something at least marginally helpful:

The blender->old xml path is still working if you add the old xml/binary classes to your project, and you can export empty nodes with that - so if your level designers are OK with using blender, they could just place an Empty (Node in jME) at the door's hinge and you could then add a door to that Node and rotate it programmatically.

Of course that would be possible for powerups and monsters just the same, which could bring you a step towards your missing level editor after all!

i prefer using model animations for opening and closing doors because it is more flexible. we can do any kind of door with any kind of opening movement like this. i guess this will be a long and hard fight, but time is on my sideā€¦

i made it. if anyone is interested, i'll proudly post the new jointcontrollers code here. it can assign different min and maxtimes for every joint. and it works.

Awesome! Just a shame this requires ms3d format. It still might be considered a possible solution to that other thread, so I took the freedom to link this there.

the controller itself is independent from the milkshape file format.

but, how to make a simple animation of a specific join



which code lines you need to make this??  e. g.: rotate a join of a finger.

do you mean

[ ] control the joint itself

[ ] control the animation of the joint