Package javax.vecmath

Examples of javax.vecmath.Matrix4f


    for (int i=0; i<clippedVertices.length; i++) clippedVertices[i] = new Vector4f();
    for (int i=0; i<clippedColors.length; i++) clippedColors[i] = new Color3f();
   
    viewMatrix.setIdentity();
   
    for (int i=0; i<viewMatStack.length; i++) viewMatStack[i] = new Matrix4f();
    for (int i=0; i<lights.length; i++) lights[i] = new Light();
    for (int i=0; i<lightResult.length; i++) lightResult[i] = new Vector3f();
  }
View Full Code Here


/*     */     }
/*     */   }
/*     */
/*     */   static void projectPoints(Triangulator triRef, int i1, int i2, Vector3f n3)
/*     */   {
/* 146 */     Matrix4f matrix = new Matrix4f();
/* 147 */     Point3f vtx = new Point3f();
/*     */
/* 154 */     Vector3f n1 = new Vector3f();
/* 155 */     Vector3f n2 = new Vector3f();
/*     */
/* 160 */     if ((Math.abs(n3.x) > 0.1D) || (Math.abs(n3.y) > 0.1D)) {
/* 161 */       n1.x = (-n3.y);
/* 162 */       n1.y = n3.x;
/* 163 */       n1.z = 0.0F;
/*     */     }
/*     */     else {
/* 166 */       n1.x = n3.z;
/* 167 */       n1.z = (-n3.x);
/* 168 */       n1.y = 0.0F;
/*     */     }
/* 170 */     double d = Basic.lengthL2(n1);
/* 171 */     Basic.divScalar(d, n1);
/* 172 */     Basic.vectorProduct(n1, n3, n2);
/* 173 */     d = Basic.lengthL2(n2);
/* 174 */     Basic.divScalar(d, n2);
/*     */
/* 179 */     matrix.m00 = n1.x;
/* 180 */     matrix.m01 = n1.y;
/* 181 */     matrix.m02 = n1.z;
/* 182 */     matrix.m03 = 0.0F;
/* 183 */     matrix.m10 = n2.x;
/* 184 */     matrix.m11 = n2.y;
/* 185 */     matrix.m12 = n2.z;
/* 186 */     matrix.m13 = 0.0F;
/* 187 */     matrix.m20 = n3.x;
/* 188 */     matrix.m21 = n3.y;
/* 189 */     matrix.m22 = n3.z;
/* 190 */     matrix.m23 = 0.0F;
/* 191 */     matrix.m30 = 0.0F;
/* 192 */     matrix.m31 = 0.0F;
/* 193 */     matrix.m32 = 0.0F;
/* 194 */     matrix.m33 = 1.0F;
/*     */
/* 201 */     triRef.initPnts(20);
/* 202 */     for (int i = i1; i < i2; i++) {
/* 203 */       int ind = triRef.loops[i];
/* 204 */       int ind1 = ind;
/* 205 */       int j1 = triRef.fetchData(ind1);
/* 206 */       matrix.transform(triRef.vertices[j1], vtx);
/* 207 */       j1 = triRef.storePoint(vtx.x, vtx.y);
/* 208 */       triRef.updateIndex(ind1, j1);
/* 209 */       ind1 = triRef.fetchNextData(ind1);
/* 210 */       j1 = triRef.fetchData(ind1);
/* 211 */       while (ind1 != ind) {
/* 212 */         matrix.transform(triRef.vertices[j1], vtx);
/* 213 */         j1 = triRef.storePoint(vtx.x, vtx.y);
/* 214 */         triRef.updateIndex(ind1, j1);
/* 215 */         ind1 = triRef.fetchNextData(ind1);
/* 216 */         j1 = triRef.fetchData(ind1);
/*     */       }
View Full Code Here

  public void popTransform() {
    if (transformStack.isEmpty()) {
      throw new RuntimeException("No transformation left to pop from transform stack!");
    }
    endPrimitivesKeepImage();
    Matrix4f m = transformStack.remove(transformStack.size() - 1);
    modelTransform.set(m);
    matrices.free(m);
    applyTransform(viewTransform, modelTransform);
  }
View Full Code Here

    matrices.free(m);
    applyTransform(viewTransform, modelTransform);
  }

  public void pushTransform() {
    Matrix4f m = matrices.get();
    m.set(modelTransform);
    transformStack.add(m);
  }
View Full Code Here

  public void popTransform() {
    if (transformStack.isEmpty()) {
      throw new RuntimeException("No transformation left to pop from transform stack!");
    }
    endPrimitivesKeepImage();
    Matrix4f m = transformStack.remove(transformStack.size() - 1);
    modelTransform.set(m);
    matrices.free(m);
    applyTransform(viewTransform, modelTransform);
  }
View Full Code Here

    matrices.free(m);
    applyTransform(viewTransform, modelTransform);
  }

  public void pushTransform() {
    Matrix4f m = matrices.get();
    m.set(modelTransform);
    transformStack.add(m);
  }
View Full Code Here

    public static Matrix4f createViewMatrix(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) {
        return createViewMatrix(new Vector3f(eyeX, eyeY, eyeZ), new Vector3f(centerX, centerY, centerZ), new Vector3f(upX, upY, upZ));
    }

    public static Matrix4f createViewMatrix(Vector3f eye, Vector3f center, Vector3f up) {
        Matrix4f m = new Matrix4f();

        Vector3f f = new Vector3f();
        f.sub(center, eye);

        f.normalize();
        up.normalize();

        Vector3f s = new Vector3f();
        s.cross(f, up);
        s.normalize();

        Vector3f u = new Vector3f();
        u.cross(s, f);
        u.normalize();

        m.m00 = s.x;
        m.m10 = s.y;
        m.m20 = s.z;
        m.m30 = 0;
        m.m01 = u.x;
        m.m11 = u.y;
        m.m21 = u.z;
        m.m31 = 0;
        m.m02 = -f.x;
        m.m12 = -f.y;
        m.m22 = -f.z;
        m.m32 = 0;
        m.m03 = 0;
        m.m13 = 0;
        m.m23 = 0;
        m.m33 = 1;

        m.m30 = -eye.x;
        m.m31 = -eye.y;
        m.m32 = -eye.z;

        m.transpose();

        return m;
    }
View Full Code Here

        return m;
    }

    public static Matrix4f createOrthogonalProjectionMatrix(float left, float right, float top, float bottom, float near, float far) {
        Matrix4f m = new Matrix4f();

        float lateral = right - left;
        float vertical = top - bottom;
        float forward = far - near;
        float tx = -(right + left) / (right - left);
        float ty = -(top + bottom) / (top - bottom);
        float tz = -(far + near) / (far - near);

        m.m00 = 2.0f / lateral;
        m.m10 = 0.0f;
        m.m20 = 0.0f;
        m.m30 = tx;
        m.m01 = 0.0f;
        m.m11 = 2.0f / vertical;
        m.m21 = 0.0f;
        m.m31 = ty;
        m.m02 = 0.0f;
        m.m12 = 0.0f;
        m.m22 = -2.0f / forward;
        m.m32 = tz;
        m.m03 = 0.0f;
        m.m13 = 0.0f;
        m.m23 = 0.0f;
        m.m33 = 1.0f;

        m.transpose();

        return m;
    }
View Full Code Here

        return m;
    }

    public static Matrix4f createPerspectiveProjectionMatrix(float fovY, float aspectRatio, float zNear, float zFar) {
        Matrix4f m = new Matrix4f();

        float f = 1.0f / (float) Math.tan(fovY * 0.5f);

        m.m00 = f / aspectRatio;
        m.m10 = 0;
        m.m20 = 0;
        m.m30 = 0;
        m.m01 = 0;
        m.m11 = f;
        m.m21 = 0;
        m.m31 = 0;
        m.m02 = 0;
        m.m12 = 0;
        m.m22 = (zFar + zNear) / (zNear - zFar);
        m.m32 = (2 * zFar * zNear) / (zNear - zFar);
        m.m03 = 0;
        m.m13 = 0;
        m.m23 = -1;
        m.m33 = 0;

        m.transpose();

        return m;
    }
View Full Code Here

        return m;
    }

    public static Matrix4f calcViewProjectionMatrix(Matrix4f vm, Matrix4f p) {
        Matrix4f result = new Matrix4f();
        result.mul(p, vm);
        return result;
    }
View Full Code Here

TOP

Related Classes of javax.vecmath.Matrix4f

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.