Package com.jme3.animation

Examples of com.jme3.animation.Bone


  @Override
  protected void doTimedControlUpdate(float tpf) {
    if(skeleton != null && spatial != null) {
      Vector3f extents = new Vector3f();
          for (int i = 0; i < skeleton.getBoneCount(); i++){
              Bone bone = skeleton.getBone(i);
              Vector3f bonePos = bone.getModelSpacePosition();
              extents.x = Math.max(extents.x, FastMath.abs(bonePos.getX()));
              extents.y = Math.max(extents.y, FastMath.abs(bonePos.getY()));
              extents.z = Math.max(extents.z, FastMath.abs(bonePos.getZ()));
          }
          BoundingBox b = new BoundingBox(new Vector3f(0f,0f,0f), extents.x, extents.y , extents.z);
View Full Code Here


    public void updateGeometry() {
        VertexBuffer vb = this.getBuffer(Type.Position);
        FloatBuffer posBuf = this.getFloatBuffer(Type.Position);
        posBuf.clear();
        for (int i = 0; i < skeleton.getBoneCount(); ++i) {
            Bone bone = skeleton.getBone(i);
            Vector3f head = bone.getModelSpacePosition();

            posBuf.put(head.getX()).put(head.getY()).put(head.getZ());
            if (boneLengths != null) {
                Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i))));
                posBuf.put(tail.getX()).put(tail.getY()).put(tail.getZ());
            }
        }
        posBuf.flip();
        vb.updateData(posBuf);
View Full Code Here

    public void updateGeometry() {
        VertexBuffer vb = this.getBuffer(Type.Position);
        FloatBuffer posBuf = this.getFloatBuffer(Type.Position);
        posBuf.clear();
        for (int i = 0; i < skeleton.getBoneCount(); ++i) {
            Bone bone = skeleton.getBone(i);
            Vector3f parentTail = bone.getModelSpacePosition().add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i))));

            for (Bone child : bone.getChildren()) {
                Vector3f childHead = child.getModelSpacePosition();
                Vector3f v = childHead.subtract(parentTail);
                float pointDelta = v.length() / POINT_AMOUNT;
                v.normalizeLocal().multLocal(pointDelta);
                Vector3f pointPosition = parentTail.clone();
View Full Code Here

    public void updateGeometry() {
        VertexBuffer vb = this.getBuffer(Type.Position);
        FloatBuffer posBuf = this.getFloatBuffer(Type.Position);
        posBuf.clear();
        for (int i = 0; i < skeleton.getBoneCount(); ++i) {
            Bone bone = skeleton.getBone(i);
            Vector3f head = bone.getModelSpacePosition();

            posBuf.put(head.getX()).put(head.getY()).put(head.getZ());
            if (boneLengths != null) {
                Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i))));
                posBuf.put(tail.getX()).put(tail.getY()).put(tail.getZ());
            }
        }
        posBuf.flip();
        vb.updateData(posBuf);
View Full Code Here

        }

        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);
            }
        }
    }
View Full Code Here

            shapeNode.setUserObject(link);
            parentShape = shapeNode;
        }

        for (Iterator<Bone> it = bone.getChildren().iterator(); it.hasNext();) {
            Bone childBone = it.next();
            boneRecursion(model, childBone, parentShape, reccount + 1, pointsMap);
        }
    }
View Full Code Here

        if (event.getAppliedImpulse() < eventDispatchImpulseThreshold) {
            return;
        }

        boolean hit = false;
        Bone hitBone = null;
        PhysicsCollisionObject hitObject = null;

        //Computing which bone has been hit
        if (objA.getUserObject() instanceof PhysicsBoneLink) {
            PhysicsBoneLink link = (PhysicsBoneLink) objA.getUserObject();
View Full Code Here

            BoneContext[] boneContexts = this.getBones();
            float b = chainLength;
            Quaternion boneWorldRotation = new Quaternion();

            for (int i = 0; i < boneContexts.length; ++i) {
                Bone bone = boneContexts[i].getBone();

                bone.updateWorldVectors();
                Transform boneWorldTransform = constraintHelper.getTransform(boneContexts[i].getArmatureObjectOMA(), bone.getName(), Space.CONSTRAINT_SPACE_WORLD);

                Vector3f head = boneWorldTransform.getTranslation();
                Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneContexts[i].getLength())));

                Vector3f vectorA = tail.subtract(head);
                float a = vectorA.length();
                vectorA.normalizeLocal();

                Vector3f vectorC = targetTransform.getTranslation().subtract(head);
                float c = vectorC.length();
                vectorC.normalizeLocal();

                b -= a;
                float theta = 0;

                if (c >= a + b) {
                    theta = vectorA.angleBetween(vectorC);
                } else if (c <= FastMath.abs(a - b) && i < boneContexts.length - 1) {
                    theta = vectorA.angleBetween(vectorC) - FastMath.HALF_PI;
                } else {
                    theta = vectorA.angleBetween(vectorC) - FastMath.acos(-(b * b - a * a - c * c) / (2 * a * c));
                }
               
                theta *= influence;

                if (theta != 0) {
                    Vector3f vectorR = vectorA.cross(vectorC);
                    boneWorldRotation.fromAngleAxis(theta, vectorR);
                    boneWorldTransform.getRotation().multLocal(boneWorldRotation);
                    constraintHelper.applyTransform(boneContexts[i].getArmatureObjectOMA(), bone.getName(), Space.CONSTRAINT_SPACE_WORLD, boneWorldTransform);
                }

                bone.updateWorldVectors();
                alteredOmas.add(boneContexts[i].getBoneOma());
            }
        }
    }
View Full Code Here

     * @return the bone contexts of all bones that will be used in this constraint computations
     */
    private BoneContext[] getBones() {
        if (bones == null) {
            List<BoneContext> bones = new ArrayList<BoneContext>();
            Bone bone = (Bone) this.getOwner();
            while (bone != null) {
                BoneContext boneContext = blenderContext.getBoneContext(bone);
                bones.add(0, boneContext);
                chainLength += boneContext.getLength();
                if (bonesAffected != 0 && bones.size() >= bonesAffected) {
                    break;
                }
                bone = bone.getParent();
            }
            this.bones = bones.toArray(new BoneContext[bones.size()]);
        }
        return bones;
    }
View Full Code Here

            Node nodeWithAnimationControl = blenderContext.getControlledNode(skeleton);
            animControl = nodeWithAnimationControl.getControl(AnimControl.class);

            boneStartTransforms = new HashMap<Bone, Transform>();
            for (int i = 0; i < skeleton.getBoneCount(); ++i) {
                Bone bone = skeleton.getBone(i);
                boneStartTransforms.put(bone, new Transform(bone.getWorldBindPosition(), bone.getWorldBindRotation(), bone.getWorldBindScale()));
            }
        } else {
            if (rootNode && spatial.getParent() != null) {
                throw new IllegalStateException("Given spatial must be a root node!");
            }
View Full Code Here

TOP

Related Classes of com.jme3.animation.Bone

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.