public void setSkeleton(Skeleton skeleton) { if(bone != null) boneIndex = skeleton.getBoneIndex(bone); }
/** * Remove any bones without vertices from the boneList, so that every hull * shape will contain at least 1 vertex. */ private void filterBoneList(SkeletonControl skeletonControl) { Mesh[] targets = skeletonControl.getTargets(); Skeleton skel = skeletonControl.getSkeleton(); for (int boneI = 0; boneI < skel.getBoneCount(); boneI++) { String boneName = skel.getBone(boneI).getName(); if (boneList.contains(boneName)) { boolean hasVertices = RagdollUtils.hasVertices(boneI, targets, weightThreshold); if (!hasVertices) { boneList.remove(boneName); } } } }
/** * Generate physics shapes and bone links for the skeleton. * * @param model the spatial with the model's SkeletonControl (not null) */ protected void scanSpatial(Spatial model) { AnimControl animControl = model.getControl(AnimControl.class); Map<Integer, List<Float>> pointsMap = null; if (weightThreshold == -1.0f) { pointsMap = RagdollUtils.buildPointMap(model); } skeleton = animControl.getSkeleton(); skeleton.resetAndUpdate(); for (int i = 0; i < skeleton.getRoots().length; i++) { Bone childBone = skeleton.getRoots()[i]; if (childBone.getParent() == null) { logger.log(Level.FINE, "Found root bone in skeleton {0}", skeleton); boneRecursion(model, childBone, baseRigidBody, 1, pointsMap); } } }
/** * Add a single bone to be influenced by this animation channel. */ public void addBone(Bone bone) { int boneIndex = control.getSkeleton().getBoneIndex(bone); if(affectedBones == null) { affectedBones = new BitSet(control.getSkeleton().getBoneCount()); } affectedBones.set(boneIndex); }
private Bone recreateBoneStructure(Bone sourceRoot) { Bone targetRoot = getBone(sourceRoot.getName()); List<Bone> children = sourceRoot.getChildren(); for (int i = 0; i < children.size(); i++) { Bone sourceChild = children.get(i); // find my version of the child Bone targetChild = getBone(sourceChild.getName()); targetRoot.addChild(targetChild); recreateBoneStructure(sourceChild); } return targetRoot; }
/** * Internal use only. */ @Override protected void controlUpdate(float tpf) { if (skeleton != null) { skeleton.reset(); // reset skeleton to bind pose } TempVars vars = TempVars.get(); for (int i = 0; i < channels.size(); i++) { channels.get(i).update(tpf, vars); } vars.release(); if (skeleton != null) { skeleton.updateWorldVectors(); } }
float time = ((BoneTrack) track).getTimes()[frame]; track.setTime(time, 1, animControl, animChannel, vars); skeleton.updateWorldVectors(); for (Bone rootBone : skeleton.getRoots()) { if (skeleton.getBoneIndex(rootBone) > 0) { this.applyConstraints(rootBone, alteredOmas, applied, frame, new Stack<Bone>()); int boneIndex = skeleton.getBoneIndex(boneContext.getBone()); if (!tracks.containsKey(boneIndex)) { tracks.put(boneIndex, new VirtualTrack(boneContext.getBone().getName(), maxFrame, maxTime)); Bone bone = skeleton.getBone(trackEntry.getKey()); Transform startTransform = boneStartTransforms.get(bone);
Joint[] joints = new Joint[skeleton.getBoneCount()]; for (int i = 0; i < skeleton.getBoneCount(); i++) { Bone b = skeleton.getBone(i); Joint j = joints[i]; if (j == null) { int index = skeleton.getBoneIndex(bone); Joint joint = joints[index]; if (joint == null) { BoneTrack boneTrack = (BoneTrack) track; int index = boneTrack.getTargetBoneIndex(); Bone bone = skeleton.getBone(index); Joint joint = joints[index]; TransformTrack jointTrack = fromBoneTrack(boneTrack, bone, joint);
PMDNode newPMDNode = (PMDNode)super.clone(); newPMDNode.skeleton = new Skeleton(skeleton); for(int i=0;i<skeleton.getBoneCount();i++) { Bone newBone = newPMDNode.skeleton.getBone(i); Bone bone = skeleton.getBone(i); newBone.getLocalPosition().set(bone.getLocalPosition()); newBone.getLocalRotation().set(bone.getLocalRotation()); newPMDNode.skeleton.updateWorldVectors(); newPMDNode.offsetMatrixbuffer = null; newPMDNode.calcOffsetMatrices();
/** * Converts the action into JME bone animation tracks. * * @param skeleton * the skeleton that will be animated * @return the bone tracks for the node */ public BoneTrack[] toTracks(Skeleton skeleton, BlenderContext blenderContext) { List<BoneTrack> tracks = new ArrayList<BoneTrack>(featuresTracks.size()); for (Entry<String, Ipo> entry : featuresTracks.entrySet()) { int boneIndex = skeleton.getBoneIndex(entry.getKey()); BoneContext boneContext = blenderContext.getBoneContext(skeleton.getBone(boneIndex)); tracks.add((BoneTrack) entry.getValue().calculateTrack(boneIndex, boneContext, boneContext.getBone().getBindPosition(), boneContext.getBone().getBindRotation(), boneContext.getBone().getBindScale(), 1, stopFrame, fps, false)); } return tracks.toArray(new BoneTrack[tracks.size()]); }
bone.setBindTransforms(new Vector3f(0, 0, 0), new Quaternion(Quaternion.IDENTITY), new Vector3f(Vector3f.UNIT_XYZ)); Skeleton skeleton = new Skeleton(new Bone[] {bone}); skeleton.setBindingPose(); skeleton.updateWorldVectors(); skeleton.resetAndUpdate(); skeleton.computeSkinningMatrices();
/** * Access the named bone. * * @param name which bone to access * @return the pre-existing instance, or null if not found */ public Bone getBone(String name){ return skeleton.getBone(name); } /**
/** * Ensure that user control is enabled for any bones used by inverse * kinematics and disabled for any other bones. */ public void applyUserControl() { for (Bone bone : skeleton.getRoots()) { RagdollUtils.setUserControl(bone, false); } if (ikTargets.isEmpty()) { setKinematicMode(); } else { Iterator iterator = ikTargets.keySet().iterator(); TempVars vars = TempVars.get(); while (iterator.hasNext()) { Bone bone = (Bone) iterator.next(); while (bone.getParent() != null) { Quaternion tmpRot1 = vars.quat1; Vector3f position = vars.vect1; matchPhysicObjectToBone(boneLinks.get(bone.getName()), position, tmpRot1); bone.setUserControl(true); bone = bone.getParent(); } } vars.release(); } }
/** * Creates a debugger with no length data. The wires will be a connection * between the bones' heads only. The points will show the bones' heads only * and no dotted line of inter bones connection will be visible. * * @param name the name of the debugger's node * @param skeleton the skeleton that will be shown */ public SkeletonDebugger(String name, Skeleton skeleton, boolean guessBonesOrientation) { super(name); this.skeleton = skeleton; skeleton.reset(); skeleton.updateWorldVectors(); Map<Integer, Float> boneLengths = new HashMap<Integer, Float>(); for (Bone bone : skeleton.getRoots()) { computeLength(bone, boneLengths, skeleton); } bones = new SkeletonBone(skeleton, boneLengths, guessBonesOrientation); this.attachChild(bones); interBoneWires = new SkeletonInterBoneWire(skeleton, boneLengths, guessBonesOrientation); Geometry g = new Geometry(name + "_interwires", interBoneWires); g.setBatchHint(BatchHint.Never); this.attachChild(g); }
protected void resetBonePos() { for (int i = 0; i < pmdNode.getSkeleton().getBoneCount(); i++) { Bone bone = pmdNode.getSkeleton().getBone(i); bone.setUserControl(false); } pmdNode.getSkeleton().resetAndUpdate(); for (int i = 0; i < pmdNode.getSkeleton().getBoneCount(); i++) { Bone bone = pmdNode.getSkeleton().getBone(i); bone.setUserControl(true); } }
void calcBonePosition() { for (int i = pmdNode.getSkeleton().getBoneCount() - 1; i >= 0; i--) { int i2 = i; //boneEnabled.length -1 - i; if (boneEnabled[i2] == 1) { Bone bone = pmdNode.getSkeleton().getBone(i); bone.getLocalRotation().loadIdentity(); pmdNode.getSkeleton().updateWorldVectors(); ikControl.updateIKBoneRotation(); for (int i = 0; i < pmdNode.getPmdModel().getBoneList().getBoneCount(); i++) { if (pmdBone.getBoneType() == 5 && boneEnabled[i] == 1) { Bone bone = pmdNode.getSkeleton().getBone(i); Bone targetBone = pmdNode.getSkeleton().getBone(pmdBone.getTargetBone()); bone.getLocalRotation().multLocal(targetBone.getLocalRotation()); bone.updateWorldVectors();
this.skeleton = skeleton; for (Bone bone : skeleton.getRoots()) { this.countConnections(bone); int lineVerticesCount = skeleton.getBoneCount(); if (boneLengths != null) { this.boneLengths = boneLengths; for (Bone bone : skeleton.getRoots()) { this.writeConnections(sib, bone);
public static Skeleton createSkeleton(FbxNode skeletonHolderNode) { if (skeletonHolderNode instanceof FbxLimbNode) { throw new UnsupportedOperationException("Limb nodes cannot be skeleton holders"); } List<Bone> bones = new ArrayList<Bone>(); for (FbxNode child : skeletonHolderNode.getChildren()) { if (child instanceof FbxLimbNode) { createBones(skeletonHolderNode, (FbxLimbNode) child, bones); } } return new Skeleton(bones.toArray(new Bone[0])); }
Skeleton skeleton = new Skeleton(bones); for (Bone bone : skeleton.getRoots()) { BoneWrapper bw = findBoneWrapper(bone); computeBindTransforms(bw, skeleton); applyPose(joints.get(i).getAsInt()); skeleton.updateWorldVectors();
final void reset() { if (skeleton != null) { skeleton.resetAndUpdate(); } }