Examples of Matrix4f


Examples of cc.plural.math.Matrix4f

public class RenderComponent extends Component {
   
    Matrix4f modelMatrix;

    public RenderComponent() {
        modelMatrix = new Matrix4f();
    }
View Full Code Here

Examples of com.flansmod.common.vector.Matrix4f

        {
          //Now Lerp by wheelSpringStrength and work out the new positions   
          float newLength = currentWheelLength + dLength * type.wheelSpringStrength;
          Vector3f rotateAround = Vector3f.cross(targetWheelPos, currentWheelPos, null);
         
          Matrix4f mat = new Matrix4f();
          mat.m00 = currentWheelPos.x;
          mat.m10 = currentWheelPos.y;
          mat.m20 = currentWheelPos.z;
          mat.rotate(dAngle * type.wheelSpringStrength, rotateAround);
         
          axes.rotateGlobal(-dAngle * type.wheelSpringStrength, rotateAround);
                   
          Vector3f newWheelPos = new Vector3f(mat.m00, mat.m10, mat.m20);
          newWheelPos.normalise().scale(newLength);
View Full Code Here

Examples of com.jme.math.Matrix4f

     */
    @InternalAPI
    public Matrix4f getCameraModelViewMatrix (Matrix4f ret) {
  synchronized (cameraLock) {
      if (ret == null) {
    return new Matrix4f(cameraModelViewMatrix);
      }
      ret.set(cameraModelViewMatrix);
      return ret;
  }
    }
View Full Code Here

Examples of com.jme.math.Matrix4f

     */
    @InternalAPI
    public Matrix4f getCameraModelViewMatrixInverse (Matrix4f ret) {
  synchronized (cameraLock) {
      if (cameraModelViewMatrixInverse == null) {
    cameraModelViewMatrixInverse = cameraModelViewMatrix.invert(new Matrix4f());
      }
      if (ret == null) {
    return new Matrix4f(cameraModelViewMatrixInverse);
      }
      ret.set(cameraModelViewMatrixInverse);
      return ret;
  }
    }
View Full Code Here

Examples of com.jme.math.Matrix4f

  Vector3f thisWorld = ((InputManager3D)InputManager3D.getInputManager()).
      getCamera().getWorldCoordinates(scrPos, 0f);
  logger.fine("thisWorld = " + thisWorld);

  // The calculations need to take place in eye space. Get the necessary matrices.
  Matrix4f camMatrix = InputPicker3D.getInputPicker().getCameraModelViewMatrix(null);
  Matrix4f camInverse = InputPicker3D.getInputPicker().getCameraModelViewMatrixInverse(null);
  logger.finest("camInverse = " + camInverse);

  // Transform vectors from world space into eye space
  Vector3f dragEye = new Vector3f();
  Vector3f dragStartEye = new Vector3f();
  Vector3f pressEye = new Vector3f();
  Vector3f eyeEye = new Vector3f();
  Vector3f thisEye = new Vector3f();
  camInverse.mult(dragWorld, dragEye);
  camInverse.mult(dragStartWorld, dragStartEye);
  camInverse.mult(pressWorld, pressEye);
  // TODO: perf: only really need to recalc eyeEye on camera change
  camInverse.mult(eyeWorld, eyeEye);
  camInverse.mult(thisWorld, thisEye);

  // The displacement vector of this event from the center of the drag plane
  Vector3f dragVectorEye = new Vector3f(
            (dragEye.x - pressEye.x) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),
      (pressEye.y - dragEye.y) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),
View Full Code Here

Examples of com.jme.math.Matrix4f

   
    /**
     * Compute and return the View Platform Transform3D give the users position, direction and up
     */
    public static Matrix4f computeViewPlatformTransform(Vector3f userPosition, Vector3f direction, Vector3f up) {       
        Matrix4f mat = new Matrix4f();
        Vector3f axisX = new Vector3f();
        Vector3f axisY = new Vector3f();
        Vector3f axisZ = new Vector3f(direction);
        axisZ.negate();
        axisZ.normalize();
View Full Code Here

Examples of com.jme3.math.Matrix4f

        cachedWorldMat.loadIdentity();
        cachedWorldMat.setRotationQuaternion(worldTransform.getRotation());
        cachedWorldMat.setTranslation(worldTransform.getTranslation());

        TempVars vars = TempVars.get();
        Matrix4f scaleMat = vars.tempMat4;
        scaleMat.loadIdentity();
        scaleMat.scale(worldTransform.getScale());
        cachedWorldMat.multLocal(scaleMat);
        vars.release();
    }
View Full Code Here

Examples of com.thecrouchmode.vector.Matrix4f

    catch(IOException e){
      e.printStackTrace();
    }
    //Texture.unbind();
   
    Matrix4f projection = Matrix4f.perspective((float)Math.PI/8, 4f/3, 0.1f, 10000f);
   
    //projection = Matrix4f.orthographic(1.33f, -1.33f, 1, -1, 0.1f, 100f);
    //projection = projection.multiply(Matrix4f.oblique((float)Math.PI/4, (float)Math.PI/8));
   
    System.out.println(projection);
   
    Matrix4f scale = Matrix4f.scale(1);
    Matrix4f translation = Matrix4f.translation(0,0,0);
    Matrix4f rotation = Matrix4f.identity;
    //Matrix4f model = translation.multiply(scale);
    Quaternion zrotation = new Quaternion(-Math.PI/360, new Vector3f(0,1,2));
    Quaternion rotQ = zrotation;
   
    float ztrans = 0;
    float xtrans = 0;
   
    Vector3f camForw = Vector3f.zUnit;
    Vector3f camSide = Vector3f.xUnit.scale(-1);
   
    double value = 0;
   
    time = System.currentTimeMillis();
    int fpsMod = 0;
   
    Light light = Light.builder()
        .intensity(255/1, 255/2, 255/3)
        .pos(1, 1, 1).build();
    shader.setUniform("lightPos", light.pos.xyz());
    shader.setUniform("lightIntensity", light.intensity);
   
    Matrix4f view = Matrix4f.view(
        new Vector3f(0, 0, -5),
        camForw,
        Vector3f.cross(camSide, camForw));
   
    float camX = 0;
    float camZ = 0;
   
    Vector3f trans = new Vector3f(1, 0.5, -4);
   
    while(true){
      try{
        if(Display.isCloseRequested()){
          Display.destroy();
          Keyboard.destroy();
          //cleanup
          break;
        }
        else{
         
          Keyboard.poll();
          //Mouse.poll();
          //System.out.println("Mouse: " +Mouse.getDX());

          //view = Matrix4f.product(Matrix4f.rotation(Mouse.getDX()/(1000*Math.PI), Vector3f.yUnit), view);
          //view = Matrix4f.product(Matrix4f.rotation(-Mouse.getDY()/(1000*Math.PI), Vector3f.xUnit), view);
         
         

         
          while(Keyboard.next()){
            int keyNo = Keyboard.getEventKey();
            char character = Keyboard.getEventCharacter();
            boolean down = Keyboard.getEventKeyState();
           
            //System.out.print("Key " + keyNo + "(" + character +") ");
           
            float moveSpeed = 0.1f;
            if(keyNo == 17 && down){
              xtrans += moveSpeed;
            }
            if(keyNo == 30 && down){
              ztrans -= moveSpeed;
            }
            if(keyNo == 31 && down){
              xtrans -= moveSpeed;
            }
            if(keyNo == 32 && down){
              ztrans += moveSpeed;
            }
           
            if(keyNo == 17 && !down){
              xtrans -= moveSpeed;
            }
            if(keyNo == 30 && !down){
              ztrans += moveSpeed;
            }
            if(keyNo == 31 && !down){
              xtrans += moveSpeed;
            }
            if(keyNo == 32 && !down){
              ztrans -= moveSpeed;
            }
          }
         
          trans = Vector3f.sum(
              trans,
              camForw.xz().unit().scale(xtrans),
              camSide.xz().unit().scale(ztrans));
         
//          Matrix4f camRot = Quaternion.product(
//                  new Quaternion(Mouse.getDY()/(600*Math.PI), camSide),
//                  new Quaternion(-Mouse.getDX()/(600*Math.PI), Vector3f.yUnit)).normalize().rotationMatrix();
         
          Matrix4f camRot = Quaternion.product(
              new Quaternion(-Mouse.getDX()/(600*Math.PI), Vector3f.yUnit),
              new Quaternion(Mouse.getDY()/(600*Math.PI), camSide)).normalize().rotationMatrix();
         
          view = Matrix4f.product();
          camForw = camRot.multiply(camForw, 1).xyz();
          camSide = camRot.multiply(camSide, 1).xyz();
         
          view = Matrix4f.view(
              trans,
              camForw,
              Vector3f.cross(camSide, camForw));
         
          value = value+0.01
         
          Renderer.clear();


//          light.pos = new Vector4f(
//              1+3*(float)Math.sin(-2*value),
//              1+1*(float)Math.cos(-2*value),
//              1f,//,
//              1.0f);
         
          light.pos = new Vector4f(trans, 1.0f);

         
          shader.use();
         
          shader.setUniform("lightPos", light.pos.xyz());
          shader.setUniform("lightInt", light.intensity);
          shader.setUniform("flip", 0);
         
          //rotQ = rotQ.multiply(zrotation);//.normalize();
          rotation = rotQ.rotationMatrix();
         
          translation = Matrix4f.translation(0, 0, 0);
          Matrix4f m = Matrix4f.product(translation, rotation, scale, dragon.normalization);
          Matrix4f vp = Matrix4f.product(projection, view);
          shader.setUniform("M", m);
          shader.setUniform("VP", vp)
          shader.setUniform("kAmbient", dragon.ambient);
          shader.setUniform("kDiffuse", dragon.diffuse);
          shader.setUniform("kSpecular", dragon.specular);
View Full Code Here

Examples of javax.vecmath.Matrix4f

        dy = -dy;
      }
          drotX.rotX(dy * 2 * (float)Math.PI);
      drotY.rotY(dx * 2 * (float)Math.PI);

      Matrix4f transform = new Matrix4f(rot);
      transform.mul(drotX);
      transform.mul(drotY);
      Matrix4f tmp = new Matrix4f(rot);
      tmp.invert();
      transform.mul(tmp);

      DirectionalLight light = scene.getLights()[lightRotationMode];
      Vector3f direction = new Vector3f();
      light.getDirection(direction);
      transform.transform(direction);
      light.setDirection(direction);
      // this calls detach/attach => more flicker
      //scene.showLightVector(direction.x,direction.y,direction.z);
     
      // update pos, don't move view
          pos2DX = newX;
          pos2DY = newY;
          peerWindow.repaint();
          return;
    }

    // rotate all lights together with view
    if (scene!=null) {
     
      float dx=(float)(newX-pos2DX)/wsize;
      float dy=(float)(newY-pos2DY)/wsize;
      if (inverse) {
        dx = -dx;
        dy = -dy;
      }
          drotX.rotX(dy * 2 * (float)Math.PI);
      drotY.rotY(dx * 2 * (float)Math.PI);
     
      Matrix4f transform = new Matrix4f(rot);
      transform.mul(drotX);
      transform.mul(drotY);
      Matrix4f tmp = new Matrix4f(rot);
      tmp.invert();
      transform.mul(tmp);

      DirectionalLight[] lights = scene.getLights();
      Vector3f direction = new Vector3f();
      for (int i=0; i<lights.length; ++i) {
View Full Code Here

Examples of javax.vecmath.Matrix4f

    float dy = (float)(newY-pos2DY)/wsize;
    pos2DX = newX;
    pos2DY = newY;
    AxisAngle4f aa = new AxisAngle4f(view, (dx-dy) * (float)Math.PI);
   
    Matrix4f mat = new Matrix4f();
    mat.setIdentity();
    mat.setRotation(aa);
    mat.mul(rot);
    rot = mat;
    applyTransform();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.