Hello Guys,
I’m trying to attach Lemur labels to joints / bones . Well not really attach but just place a label with the joint name near the joint.
Problem is that the labels are spread horizontally instead of vertically (I will add a video demonstrating it soon)
Here is the code:
private void showHideJoints(AppModel model, final boolean showJoints) {
String retval = model.getJointsList();
if(retval!=null && retval.length()>0) {
String joints[] = retval.split(",");
for(int i=0;i<joints.length;++i) {
String jointName = joints[i];
Vector3f pos = model.getJointPosition(jointName);
Label l = new Label(jointName);
l.setFontSize(0.5f);
l.setPreferredSize(new Vector3f(20f,1f,0));
l.setLocalTranslation(pos);
model.model.attachChild(l);
}
}
}
And here is the helper method for getting the joint position:
public Vector3f getJointPosition(String jointName) {
if(this.resource.isJ3O()) {
Skeleton sk = findSkeleton(model);
if(sk!=null) {
Bone b = sk.getBone(jointName);
if(b!=null) {
return b.getLocalPosition();
}
}
} else {
Spatial sp = model.getChild(0);
SkinningControl skinningControl = sp.getControl(SkinningControl.class);
if(skinningControl!=null) {
Joint j = skinningControl.getArmature().getJoint(jointName);
if(j!=null) {
return j.getLocalTranslation();
}
}
}
return null;
}
Here is the video:
What do you think?
Thanks!