Package com.jme3.math

Examples of com.jme3.math.Quaternion


        spatial.setLocalTranslation(location.add(0, 0, -4));

        Vector3f vectorDifference = new Vector3f(cam.getLocation().subtract(spatial.getWorldTranslation()));
        spatial.setLocalTranslation(vectorDifference.addLocal(spatial.getLocalTranslation()));

        Quaternion worldDiff = new Quaternion(cam.getRotation().subtract(spatial.getWorldRotation()));
        spatial.setLocalRotation(worldDiff.addLocal(spatial.getLocalRotation()));

        if (spatial.getName().equals("gun")) {
            spatial.move(cam.getDirection().mult(3));
            spatial.move(cam.getUp().mult(-0.8f));
            spatial.move(cam.getLeft().mult(-1f));
            spatial.rotate(0.3f, FastMath.PI, 0);

        } else if (spatial.getName().equals("apple")) {
            spatial.move(cam.getDirection().mult(3));
        } else {
            spatial.move(cam.getDirection().mult(2));
            spatial.move(cam.getUp().mult(-1.5f));
            spatial.move(cam.getLeft().mult(-1f));

            spatial.setLocalRotation(spatial.getLocalRotation().mult(new Quaternion().fromAngles(FastMath.PI - 0.3f, 0, -0.2f)));
        }
    }
View Full Code Here


        IdentityComponent e = em.getEntity(com);
        if(e != null)
        {
          Entity ent = e.getEntity();
          ent.setLocalTranslation(com.position.x, com.position.y+com.heightOffset, com.position.z);
          ent.setLocalRotation(new Quaternion().fromAngleNormalAxis(com.heading, Vector3f.UNIT_Y.negate()));
        } else {
          log.severe("Positioning component without identity component found! comp:"+
              c+" at "+ com.position.x+ ", "+(com.position.y+com.heightOffset)+", "+com.position.z);
          //FIXME this is a workaround, investigate why this can happen! was it added twice? should we better use a hasmap for components
          dumpComponents();
View Full Code Here

    l2j.isPlayer  = true;
    em.setPlayerId(ent.getId());
    l2j.l2jEntity = e;

    ent.setLocalTranslation(pos.position);
    ent.setLocalRotation(new Quaternion().fromAngleAxis(e.getHeading(), Vector3f.UNIT_Y));
    ent.attachChild(visible);
   
    //hook up of the terrain swapping @see SimpleTerrainManager
    ent.addControl(new AbstractControl(){
View Full Code Here

    if(e.getCharId() > 0)
      l2j.isPlayer = true;
    l2j.l2jEntity = e;
   
    ent.setLocalTranslation(pos.position);
    ent.setLocalRotation(new Quaternion().fromAngleAxis(e.getHeading(), Vector3f.UNIT_Y));
   
    pos.position.set(e.getX(), e.getY(), e.getZ());
    pos.startPos.set(pos.position);
    pos.goalPos.set(pos.startPos);
    pos.walkSpeed = e.getWalkSpeed();
View Full Code Here

      //this is the same as in GotoClickedInputAction
      Geometry n = new Geometry(IArea.TILE_PREFIX + x + " " + y,q);
      n.setMaterial(material);
      n.setLocalTranslation(x * IArea.TERRAIN_SIZE, 0f,y * IArea.TERRAIN_SIZE);
      ret.patch = n;
      n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    } catch (Exception e) {
      //TODO use logger & error handling on failed load of a tile (in which case is this ok?)
      e.printStackTrace();
    }

View Full Code Here

  }
 
  private void replaceModel() {
    Node n = assembler.getModel();
    // the models are rotated so z is up
    n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
//    // FIXME modelconverter should already have set this one, this is
//    // not the case -> NPE
//    n.setModelBound(new BoundingBox());
//    n.updateModelBound();
//    if (vis != null && vis.getParent() != null) {
View Full Code Here

   * @param template  name of the model template from the partset configuration
   * @return a @see Node below which the 3d model and the animation controller is present
   */
  public static Node getModel3(String template){
    Node n = getModelInternal(JMEAnimationController.class, template, false, false);
    n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    n.updateGeometricState();
   
    return n;
  }
View Full Code Here

   * @param hwSkinning hwSkinning desired or not
   * @return a @see Node below which the 3d model and the animation controller is present
   */
  public static Node getModel4(String template, boolean optimized, boolean hwSkinning){
    Node n = getModelInternal(JMEAnimationController.class, template, optimized, hwSkinning);
    n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    n.updateGeometricState();
   
    return n;
  }
View Full Code Here

          NewCharacterModel v = new NewCharacterModel(clientInfo.getCharHandler().getCharSummary(i));
          v.attachVisuals();
          pos = scene.getChild("pos"+(i+1)).getLocalTranslation().clone();
          pos.y -= 1.0f;
          v.setLocalTranslation(pos);
          v.setLocalRotation(new Quaternion().fromAngleNormalAxis((float) Math.PI, Vector3f.UNIT_Y.negate()));
          Singleton.get().getSceneManager().changeCharNode(v,Action.ADD);
        }       
      }
    } catch (Exception e1) {
      logger.log(Level.SEVERE, "Failed to load select scene file "+SCENES_SELECT, e1);
View Full Code Here

    Geometry face1 = new Geometry("face1", faceShape);
    face1.move(-(patchWidth * selectedSizeVariation) / 2, 0, 0);
    grassPatch.attachChild(face1);

    Geometry face2 = new Geometry("face2", faceShape);
    face2.rotate(new Quaternion().fromAngleAxis(-FastMath.PI / 2,
        new Vector3f(0, 1, 0)));
    face2.move(0, 0, -(patchWidth * selectedSizeVariation) / 2);
    grassPatch.attachChild(face2);

    grassPatch.setCullHint(Spatial.CullHint.Dynamic);
    grassPatch.setQueueBucket(RenderQueue.Bucket.Transparent);

    face1.setMaterial(faceMat);
    face2.setMaterial(faceMat);

    grassPatch.rotate(new Quaternion().fromAngleAxis(
        (((int) (Math.random() * 359)) + 1) * (FastMath.PI / 190),
        new Vector3f(0, 1, 0)));
    grassPatch.setLocalTranslation(location);

    return grassPatch;
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.