Java Code Examples for com.jme3.animation.Skeleton#getBone()
The following examples show how to use
com.jme3.animation.Skeleton#getBone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmatureHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * This method retuns the bone tracks for animation for blender version 2.49 * (and probably several lower versions too). * * @param actionStructure * the structure containing the tracks * @param blenderContext * the blender context * @return a list of tracks for the specified animation * @throws BlenderFileException * an exception is thrown when there are problems with the blend * file */ private BoneTrack[] getTracks249(Structure actionStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException { LOGGER.log(Level.FINE, "Getting tracks!"); IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); int fps = blenderContext.getBlenderKey().getFps(); Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase"); List<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);// bActionChannel List<BoneTrack> tracks = new ArrayList<BoneTrack>(); for (Structure bActionChannel : actionChannels) { String name = bActionChannel.getFieldValue("name").toString(); int boneIndex = this.getBoneIndex(skeleton, name); if (boneIndex >= 0) { Pointer p = (Pointer) bActionChannel.getFieldValue("ipo"); if (!p.isNull()) { Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0); Bone bone = skeleton.getBone(boneIndex); Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext); if (ipo != null) { tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, bone.getLocalRotation(), 0, ipo.getLastFrame(), fps, false)); } } } } return tracks.toArray(new BoneTrack[tracks.size()]); }
Example 2
Source File: AnimationBoneTrackTreeNode.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@NotNull @Override protected String computeName() { final BoneTrack boneTrack = getElement(); final AnimControl control = notNull(getControl()); final Skeleton skeleton = control.getSkeleton(); final Bone bone = skeleton.getBone(boneTrack.getTargetBoneIndex()); return "Bone track : " + bone.getName(); }
Example 3
Source File: ModelPerformer.java From OpenRTS with MIT License | 5 votes |
private void updateBoneCoords(ModelActor actor) { AnimControl ctrl = actor.getViewElements().spatial.getControl(AnimControl.class); if(ctrl == null) { return; } Skeleton sk = ctrl.getSkeleton(); for (int i = 0; i < sk.getBoneCount(); i++) { Bone b = sk.getBone(i); actor.setBone(b.getName(), getBoneWorldPos(actor, i)); } }
Example 4
Source File: PhysicsControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
void initRigidBodyArray() { Skeleton skeleton = pmdNode.getSkeleton(); PMDModel pmdModel = pmdNode.getPmdModel(); rigidBodyArray = new PMDRigidBody[pmdModel.getRigidBodyList().getRigidBodyArray().length]; for (int i = 0; i < pmdModel.getRigidBodyList().getRigidBodyArray().length; i++) { projectkyoto.mmd.file.PMDRigidBody fileRigidBody = pmdModel.getRigidBodyList().getRigidBodyArray()[i]; Bone bone = skeleton.getBone(fileRigidBody.getRelBoneIndex()); PMDRigidBody rb = createRigidBody(fileRigidBody, bone); rigidBodyArray[i] = rb; } }
Example 5
Source File: PMDPhysicsWorld.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void addPMDNode(PMDNode pmdNode) { Skeleton skeleton = pmdNode.getSkeleton(); skeleton.updateWorldVectors(); PMDModel pmdModel = pmdNode.getPmdModel(); PMDRigidBody[] rigidBodyArray = new PMDRigidBody[pmdModel.getRigidBodyList().getRigidBodyArray().length]; rigidBodyMap.put(pmdNode, rigidBodyArray); for (int i = 0; i < pmdModel.getRigidBodyList().getRigidBodyArray().length; i++) { projectkyoto.mmd.file.PMDRigidBody fileRigidBody = pmdModel.getRigidBodyList().getRigidBodyArray()[i]; Bone bone = null; if (fileRigidBody.getRelBoneIndex() != 0xffff) { bone = skeleton.getBone(fileRigidBody.getRelBoneIndex()); } PMDRigidBody rb = createRigidBody(pmdNode, fileRigidBody, bone); rigidBodyArray[i] = rb; // btWorld.addRigidBody(rb, (short) (1 << fileRigidBody.getRigidBodyGroupIndex()), // (short) fileRigidBody.getRigidBodyGroupTarget()); rb.setCollisionGroup(1 << (fileRigidBody.getRigidBodyGroupIndex())); // if (fileRigidBody.getRigidBodyName().contains("スカート")) { // rb.setCollideWithGroups(1 << 7); // } else { rb.setCollideWithGroups(fileRigidBody.getRigidBodyGroupTarget()); // } // rb.setCollideWithGroups(0 ); physicsSpace.addCollisionObject(rb); } SixDofJoint constArray[] = new SixDofJoint[pmdModel.getJointList().getJointCount()]; constraintMap.put(pmdNode, constArray); for (int i = 0; i < constArray.length; i++) { SixDofJoint constraint = createConstraint(pmdNode, rigidBodyArray, pmdModel.getJointList().getJointArray()[i]); constArray[i] = constraint; physicsSpace.add(constraint); } nodeRigidBodyArray = rigidBodyMap.values().toArray(new PMDRigidBody[rigidBodyMap.size()][]); // physicsSpace.update(1 / 60f, 1); }
Example 6
Source File: ArmatureHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * This method retuns the bone tracks for animation for blender version 2.50 * and higher. * * @param actionStructure * the structure containing the tracks * @param blenderContext * the blender context * @return a list of tracks for the specified animation * @throws BlenderFileException * an exception is thrown when there are problems with the blend * file */ private BoneTrack[] getTracks250(Structure actionStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException { LOGGER.log(Level.FINE, "Getting tracks!"); IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); int fps = blenderContext.getBlenderKey().getFps(); Structure groups = (Structure) actionStructure.getFieldValue("groups"); List<Structure> actionGroups = groups.evaluateListBase(blenderContext);// bActionGroup List<BoneTrack> tracks = new ArrayList<BoneTrack>(); for (Structure actionGroup : actionGroups) { String name = actionGroup.getFieldValue("name").toString(); int boneIndex = this.getBoneIndex(skeleton, name); if (boneIndex >= 0) { List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext); BezierCurve[] bezierCurves = new BezierCurve[channels.size()]; int channelCounter = 0; for (Structure c : channels) { int type = ipoHelper.getCurveType(c, blenderContext); Pointer pBezTriple = (Pointer) c.getFieldValue("bezt"); List<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2); } Bone bone = skeleton.getBone(boneIndex); Ipo ipo = new Ipo(bezierCurves, fixUpAxis, blenderContext.getBlenderVersion()); tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, bone.getLocalRotation(), 0, ipo.getLastFrame(), fps, false)); } } return tracks.toArray(new BoneTrack[tracks.size()]); }