apologies if this is a total noob question but I have already tried to come up
with an solution to this by reading up jme sources and docs/forum and until now have failed to suceed…
I am basically want to get the changed mesh after an animation has run through in part e.g.
“walking” has been performed only for 1s.
In detail I am doing the following:
- loading a blender generated model (ogre exported mesh and skeleton) into jme using asset manager
- triggering an animation on this model and letting it freeze somewhere in between, i.e.
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setSpeed(0.0f); // i do not want the animation to proceed beyond the time set in the following (freeze character/object)
channel.setTime(time); // jump some time into the animation
- trying to access the mesh modified by the skeleton represented at this time frame
i.e. using various approaches, the last one being:
SkeletonControl skc = model.getControl(SkeletonControl.class);
Skeleton sk = control.getSkeleton();
Mesh t = skc.getTargets().cloneForAnim();
resetToBind(t); // borrowed from skeletoncontrol.java
Matrix4f  skm = sk.computeSkinningMatrices();
// expecting t to be the changed mesh
softwareSkinUpdate( t, skm); // borrowed from skeletoncontrol.java
While after executing this code the model is correctly visualized i.e. frozen at the set point in the time
the mesh is either empty or (if accessed directly e.g. model.getMesh()) unchanged.
Is it possible to access this information or am I overlooking something?
TIA for your help:).
I can’t answer the question but I just wanted to ask why you want to do this as there may well be a simpler way to achieve the same end…
thanks for your comment. It seems I found the error.
It seems it was related to cloning the node containing
the mesh and probably accessing the wrong mesh in the end.
I can now retrieve the correctly changed faces representing the current
state of the rendered image -
the only thing which seems a bit strange to me is that
at the end of the vertexbuffer there are several Vector3fs containing only NaNs,
i.e. the vertexbuffer holds 1000 elements of which around 390 are NaN vertices.
However, the remaining non-NaN vertices (located at the beginning of the buffer)
seem to correctly represent the changed model.
To answer your question: the reason as to why I’d like to extract the
interpolated state is that I would like to use JME as a front end to an external simulation engine.
Thence, I intend to let JME estimate the current geometrical state
of an object at a certain time and then export this state to a simulation engine.
The simulator would then take this input and calculate the impact
on a certain physical quantity. Based on the simulation output I would
(in a second step) further like to change the scene while replaying the animation,
i.e. visualizing the simulation results while seeing the original animation. Thus,
“wrapping” the JME around the simulator as a visual and animation interface,
enabling the simulator to approx. the effect of dynamics.
Sounds like an interesting project