Package com.jme3.animation

Examples of com.jme3.animation.Skeleton


   
//    String scala = String.valueOf(scale);
    //create name (name+scale)
//    String cName = name + scala;
    //lookup in cache or load it
    Skeleton s = skeletons.get(name);
    if (s == null) {
      Asset a = new Asset(name, name);
      Singleton.get().getAssetManager().loadAsset(a, true);
      s = (Skeleton) a.getBaseAsset();
    }
    if (s != null) {
      skeletons.put(name, s);
      return new Skeleton(s);
    } else {
      return null;
    }
  }
View Full Code Here


    try {
      Savable load = BinaryImporter.getInstance().load(newFile);
     
      if(load instanceof Skeleton)
      {
        Skeleton skel = (Skeleton)load;
        assembler.setSkeleton(skel);
        this.jTextField1.setText(newFile.getPath().substring(0,8)+"..."+newFile.getName());
        String[] names = new String[skel.getBoneCount()];
        for(int i=0;i<skel.getBoneCount();i++){
          names[i]= skel.getBone(i).getName();
        }
        bones.setModel(new DefaultComboBoxModel(names));
        updateJME();
      } else {
View Full Code Here

    HashMap<Asset, String> meshArray = getMeshesWithMaterial(top);
   
    addWeaponSetToMeshMap(top, weapons, meshArray);

    Skeleton skel = getSkeleton(top);

    getAnimations(/*top, */weapons.getAnimSet(), weapons.getDefaultSet());

    Node n = assembleModel(template,meshArray,materials,skel,weapons.getAnimSet(), optimized, hwSkinning);
       
View Full Code Here

              model = GeometryBatchFactory.optimize(model, false);
              //fix for bug in batchfactory removing empty hw buffers
              fixHWModels(model);
            }
           
            Skeleton skel = new Skeleton(skeleton);
          //TODO move this out into AnimationManger
      AnimControl c = new AnimControl(skel);//skeleton, animParts, template
      c.createChannel();
      c.setAnimationProvider(Singleton.get().getAnimManager().getAnimationProvider(animSet));
            model.addControl(new JMEAnimationController(c,animSet));
View Full Code Here

     */
    public void applyTransform(Long oma, String subtargetName, Space space, Transform transform) {
        Spatial feature = (Spatial) blenderContext.getLoadedFeature(oma, LoadedFeatureDataType.LOADED_FEATURE);
        boolean isArmature = blenderContext.getMarkerValue(ObjectHelper.ARMATURE_NODE_MARKER, feature) != null;
        if (isArmature) {
            Skeleton skeleton = blenderContext.getSkeleton(oma);
            BoneContext targetBoneContext = blenderContext.getBoneByName(oma, subtargetName);
            Bone bone = targetBoneContext.getBone();

            if (bone.getParent() == null && (space == Space.CONSTRAINT_SPACE_LOCAL || space == Space.CONSTRAINT_SPACE_PARLOCAL)) {
                space = Space.CONSTRAINT_SPACE_POSE;
            }

            TempVars tempVars = TempVars.get();
            switch (space) {
                case CONSTRAINT_SPACE_LOCAL:
                    assert bone.getParent() != null : "CONSTRAINT_SPACE_LOCAL should be evaluated as CONSTRAINT_SPACE_POSE if the bone has no parent!";
                    bone.setBindTransforms(transform.getTranslation(), transform.getRotation(), transform.getScale());
                    break;
                case CONSTRAINT_SPACE_WORLD: {
                    Matrix4f boneMatrixInWorldSpace = this.toMatrix(transform, tempVars.tempMat4);
                    Matrix4f modelWorldMatrix = this.toMatrix(this.getTransform(targetBoneContext.getSkeletonOwnerOma(), null, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat42);
                    Matrix4f boneMatrixInModelSpace = modelWorldMatrix.invertLocal().multLocal(boneMatrixInWorldSpace);
                    Bone parent = bone.getParent();
                    if (parent != null) {
                        Matrix4f parentMatrixInModelSpace = this.toMatrix(parent.getModelSpacePosition(), parent.getModelSpaceRotation(), parent.getModelSpaceScale(), tempVars.tempMat4);
                        boneMatrixInModelSpace = parentMatrixInModelSpace.invertLocal().multLocal(boneMatrixInModelSpace);
                    }
                    bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector());
                    break;
                }
                case CONSTRAINT_SPACE_POSE: {
                    Matrix4f armatureWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat4);
                    Matrix4f boneMatrixInWorldSpace = armatureWorldMatrix.multLocal(this.toMatrix(transform, tempVars.tempMat42));
                    Matrix4f invertedModelMatrix = this.toMatrix(this.getTransform(targetBoneContext.getSkeletonOwnerOma(), null, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat42).invertLocal();
                    Matrix4f boneMatrixInModelSpace = invertedModelMatrix.multLocal(boneMatrixInWorldSpace);
                    Bone parent = bone.getParent();
                    if (parent != null) {
                        Matrix4f parentMatrixInModelSpace = this.toMatrix(parent.getModelSpacePosition(), parent.getModelSpaceRotation(), parent.getModelSpaceScale(), tempVars.tempMat4);
                        boneMatrixInModelSpace = parentMatrixInModelSpace.invertLocal().multLocal(boneMatrixInModelSpace);
                    }
                    bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector());
                    break;
                }
                case CONSTRAINT_SPACE_PARLOCAL:
                    Matrix4f armatureWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat4);
                    Matrix4f boneMatrixInWorldSpace = armatureWorldMatrix.multLocal(this.toMatrix(transform, tempVars.tempMat42));
                    Matrix4f invertedModelMatrix = this.toMatrix(this.getTransform(targetBoneContext.getSkeletonOwnerOma(), null, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat42).invertLocal();
                    Matrix4f boneMatrixInModelSpace = invertedModelMatrix.multLocal(boneMatrixInWorldSpace);
                    Bone parent = bone.getParent();
                    if (parent != null) {
                        //first add the initial parent matrix to the bone's model matrix
                        BoneContext parentContext = blenderContext.getBoneContext(parent);

                        Matrix4f initialParentMatrixInModelSpace = parentContext.getBoneMatrixInModelSpace();
                        Matrix4f currentParentMatrixInModelSpace = this.toMatrix(parent.getModelSpacePosition(), parent.getModelSpaceRotation(), parent.getModelSpaceScale(), tempVars.tempMat4);
                        //the bone will now move with its parent in model space

                        //now we need to subtract the difference between current parent's model matrix and its initial model matrix
                        boneMatrixInModelSpace = initialParentMatrixInModelSpace.mult(boneMatrixInModelSpace);

                        Matrix4f diffMatrix = initialParentMatrixInModelSpace.mult(currentParentMatrixInModelSpace.invert());
                        boneMatrixInModelSpace.multLocal(diffMatrix);
                        //now the bone will have its position in model space with initial parent's model matrix added
                    }
                    bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector());
                    break;
                default:
                    tempVars.release();
                    throw new IllegalStateException("Invalid space type for target object: " + space.toString());
            }
            tempVars.release();
            skeleton.updateWorldVectors();
        } else {
            switch (space) {
                case CONSTRAINT_SPACE_LOCAL:
                    feature.getLocalTransform().set(transform);
                    break;
View Full Code Here

     * @return the target feature; it is either Node or Bone (vertex group subtarger is not yet supported)
     */
    private Object getTarget() {
        Object target = blenderContext.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE);
        if (subtargetName != null && blenderContext.getMarkerValue(ObjectHelper.ARMATURE_NODE_MARKER, target) != null) {
            Skeleton skeleton = blenderContext.getSkeleton(targetOMA);
            target = skeleton.getBone(subtargetName);
        }
        return target;
    }
View Full Code Here

                for (int i = 0; i < bonebase.size(); ++i) {
                    this.buildBones(armatureObject.getOldMemoryAddress(), bonebase.get(i), null, bonesList, objectStructure.getOldMemoryAddress(), blenderContext);
                }
                bonesList.add(0, new Bone(""));
                Bone[] bones = bonesList.toArray(new Bone[bonesList.size()]);
                skeleton = new Skeleton(bones);
                blenderContext.setSkeleton(armatureObject.getOldMemoryAddress(), skeleton);
                this.objectStructure = objectStructure;
                this.meshStructure = meshStructure;

                // read mesh indexes
View Full Code Here

            for (Map.Entry<Integer, Bone> entry : indexToBone.entrySet()) {
                Bone bone = entry.getValue();
                bones[entry.getKey()] = bone;
            }
            indexToBone.clear();
            skeleton = new Skeleton(bones);
        } else if (qName.equals("animation")) {
            animations.add(animation);
            animation = null;
        } else if (qName.equals("track")) {
            if (track != null) { // if track has keyframes
View Full Code Here

  public static void startApp(){
    app.startCanvas();
    app.enqueue(new Callable<Void>(){
      public Void call(){
        if (app instanceof SimpleApplication){
          SimpleApplication simpleApp = (SimpleApplication) app;
          simpleApp.getFlyByCamera().setDragToRotate(true);
          String assdir =  new File(workspace).getAbsolutePath();
          app.setAssetsPath(assdir);
        }
        return null;
      }
View Full Code Here

     * Attaches Statistics View to guiNode and displays it on the screen
     * above FPS statistics line.
     *
     */
    public void loadStatsView() {
        statsView = new StatsView("Statistics View", assetManager, renderer.getStatistics());
//         move it up so it appears above fps text
        statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0);
        guiNode.attachChild(statsView);
    }
View Full Code Here

TOP

Related Classes of com.jme3.animation.Skeleton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.