Package com.jme3.math

Examples of com.jme3.math.Quaternion


 
  private Geometry createSelectionMarker(){
    float size = 2f;
    Geometry selectionMarker = new Geometry("selection", new Quad(size, size));
    selectionMarker.setLocalTranslation(-0.5f*size, 0.2f, 0.5f*size);
    selectionMarker.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));

      com.jme3.asset.AssetManager am = Singleton.get().getAssetManager().getJmeAssetMan();
      Material mat = new Material(am, "Common/MatDefs/Light/Lighting.j3md");
      Texture sel = am.loadTexture("models/textures/flare4.png");
      sel.setWrap(WrapMode.Repeat);
View Full Code Here


//        com.l2client.asset.Singleton.get().getAssetManager().loadAsset(a,true);
        Spatial s = Singleton.get().getAssetManager().getJmeAssetMan().loadModel("models/troll2/troll.xml.mesh.xml");
//        baseNode = (Node) a.getBaseAsset();
        if(s instanceof Node ){
        baseNode = (Node) s;
        baseNode.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
        baseNode.setName(name);
        }
      }
      if (baseNode != null) {
//        //TODO check if still needed
View Full Code Here

    private AudioRenderer renderer;

    public Listener(){
        location = new Vector3f();
        velocity = new Vector3f();
        rotation = new Quaternion();
    }
View Full Code Here

            if (name.equals(INPUT_MAPPING_CAMERA_POS)) {
                Camera cam = app.getCamera();
                if (cam != null) {
                    Vector3f loc = cam.getLocation();
                    Quaternion rot = cam.getRotation();
                    System.out.println("Camera Position: ("
                            + loc.x + ", " + loc.y + ", " + loc.z + ")");
                    System.out.println("Camera Rotation: " + rot);
                    System.out.println("Camera Direction: " + cam.getDirection());
                    System.out.println("cam.setLocation(new Vector3f("
                            + loc.x + "f, " + loc.y + "f, " + loc.z + "f));");
                    System.out.println("cam.setRotation(new Quaternion(" + rot.getX() + "f, " +rot.getY()+ "f, " + rot.getZ() + "f, " + rot.getW() + "f));");
                 
                }
            } else if (name.equals(INPUT_MAPPING_MEMORY)) {
                BufferUtils.printCurrentDirectMemory(null);
            }
View Full Code Here

        }
    }

    protected void ragDollUpdate(float tpf) {
        TempVars vars = TempVars.get();
        Quaternion tmpRot1 = vars.quat1;
        Quaternion tmpRot2 = vars.quat2;

        for (PhysicsBoneLink link : boneLinks.values()) {

            Vector3f position = vars.vect1;

            //retrieving bone position in physic world space
            Vector3f p = link.rigidBody.getMotionState().getWorldLocation();
            //transforming this position with inverse transforms of the model
            targetModel.getWorldTransform().transformInverseVector(p, position);

            //retrieving bone rotation in physic world space
            Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();

            //multiplying this rotation by the initialWorld rotation of the bone,
            //then transforming it with the inverse world rotation of the model
            tmpRot1.set(q).multLocal(link.initalWorldRotation);
            tmpRot2.set(targetModel.getWorldRotation()).inverseLocal().mult(tmpRot1, tmpRot1);
View Full Code Here

    }

    protected void kinematicUpdate(float tpf) {
        //the ragdoll does not have the controll, so the keyframed animation updates the physic position of the physic bonces
        TempVars vars = TempVars.get();
        Quaternion tmpRot1 = vars.quat1;
        Quaternion tmpRot2 = vars.quat2;
        Vector3f position = vars.vect1;
        for (PhysicsBoneLink link : boneLinks.values()) {
            //if blended control this means, keyframed animation is updating the skeleton,
            //but to allow smooth transition, we blend this transformation with the saved position of the ragdoll
            if (blendedControl) {
                Vector3f position2 = vars.vect2;
                //initializing tmp vars with the start position/rotation of the ragdoll
                position.set(link.startBlendingPos);
                tmpRot1.set(link.startBlendingRot);

                //interpolating between ragdoll position/rotation and keyframed position/rotation
                tmpRot2.set(tmpRot1).nlerp(link.bone.getModelSpaceRotation(), blendStart / blendTime);
                position2.set(position).interpolateLocal(link.bone.getModelSpacePosition(), blendStart / blendTime);
                tmpRot1.set(tmpRot2);
                position.set(position2);

                //updating bones transforms
View Full Code Here

        targetModel = model;
        Node parent = model.getParent();


        Vector3f initPosition = model.getLocalTranslation().clone();
        Quaternion initRotation = model.getLocalRotation().clone();
        initScale = model.getLocalScale().clone();

        model.removeFromParent();
        model.setLocalTranslation(Vector3f.ZERO);
        model.setLocalRotation(Quaternion.IDENTITY);
View Full Code Here

        TempVars vars = TempVars.get();

        for (PhysicsBoneLink link : boneLinks.values()) {
            link.rigidBody.setKinematic(mode == Mode.Kinematic);
            if (mode == Mode.Ragdoll) {
                Quaternion tmpRot1 = vars.quat1;
                Vector3f position = vars.vect1;
                //making sure that the ragdoll is at the correct place.
                matchPhysicObjectToBone(link, position, tmpRot1);
            }
View Full Code Here

            Vector3f p = link.rigidBody.getMotionState().getWorldLocation();
            Vector3f position = vars.vect1;

            targetModel.getWorldTransform().transformInverseVector(p, position);

            Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();
            Quaternion q2 = vars.quat1;
            Quaternion q3 = vars.quat2;

            q2.set(q).multLocal(link.initalWorldRotation).normalizeLocal();
            q3.set(targetModel.getWorldRotation()).inverseLocal().mult(q2, q2);
            q2.normalizeLocal();
            link.startBlendingPos.set(position);
            link.startBlendingRot.set(q2);
            link.rigidBody.setKinematic(true);
        }
View Full Code Here

        super.write(ex);
        OutputCapsule oc = ex.getCapsule(this);
        oc.write(boneList.toArray(new String[boneList.size()]), "boneList", new String[0]);
        oc.write(boneLinks.values().toArray(new PhysicsBoneLink[boneLinks.size()]), "boneLinks", new PhysicsBoneLink[0]);
        oc.write(modelPosition, "modelPosition", new Vector3f());
        oc.write(modelRotation, "modelRotation", new Quaternion());
        oc.write(targetModel, "targetModel", null);
        oc.write(skeleton, "skeleton", null);
//        oc.write(preset, "preset", null);//TODO
        oc.write(initScale, "initScale", null);
        oc.write(mode, "mode", null);
View Full Code Here

TOP

Related Classes of com.jme3.math.Quaternion

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.