當前位置: 首頁>>代碼示例>>Java>>正文


Java Matrix4f類代碼示例

本文整理匯總了Java中javax.vecmath.Matrix4f的典型用法代碼示例。如果您正苦於以下問題:Java Matrix4f類的具體用法?Java Matrix4f怎麽用?Java Matrix4f使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Matrix4f類屬於javax.vecmath包,在下文中一共展示了Matrix4f類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EntityCrazyCube

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public EntityCrazyCube(World world, Vec3f pos){
		super(world, getModel0(), pos);
		float s=Rand.f()+1;
		scale.set(s, s, s);
		
//		model.getMaterial(2).getDiffuse().set(177/256F, 0, 177/256F, 1);
//		model.getMaterial(1).getDiffuse().set(0x00C7E7);
//		model.getMaterial(1).getAmbient().set(0x00C7E7).a(1);
//		model.getMaterial(0).getDiffuse().set(0x0000FF);
		
		float massKg=0.5F*scale.x*scale.y*scale.z;
		
		if(CAM==null) CAM=this;
		
		getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new SphereShape(scale.x/2), Vec3f.single(0.9F));
//		getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new BoxShape(new Vector3f(scale.x/2, scale.y/2, scale.z/2)), Vec3f.single(0.9F));
		getPhysicsObj().body.setDamping(0.15F, 0.15F);
		getPhysicsObj().hookPos(this.pos);
		getPhysicsObj().hookRot(rot);
	}
 
開發者ID:LapisSea,項目名稱:OpenGL-Bullet-engine,代碼行數:21,代碼來源:EntityCrazyCube.java

示例2: handlePerspective

import javax.vecmath.Matrix4f; //導入依賴的package包/類
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	if (baseSpellPageModel instanceof IPerspectiveAwareModel) {
		Matrix4f matrix4f = ((IPerspectiveAwareModel) baseSpellPageModel).handlePerspective(cameraTransformType)
				.getRight();
		return Pair.of(this, matrix4f);
	}
	ItemCameraTransforms itemCameraTransforms = baseSpellPageModel.getItemCameraTransforms();
	ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
	TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
	Matrix4f mat = null;
	if (tr != null) {
		mat = tr.getMatrix();
	}
	return Pair.of(this, mat);
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:17,代碼來源:ModelSpellPage.java

示例3: handlePerspective

import javax.vecmath.Matrix4f; //導入依賴的package包/類
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	if (baseKnowledgeBookModel instanceof IPerspectiveAwareModel) {
		Matrix4f matrix4f = ((IPerspectiveAwareModel) baseKnowledgeBookModel).handlePerspective(cameraTransformType)
				.getRight();
		return Pair.of(this, matrix4f);
	}
	ItemCameraTransforms itemCameraTransforms = baseKnowledgeBookModel.getItemCameraTransforms();
	ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
	TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
	Matrix4f mat = null;
	if (tr != null) {
		mat = tr.getMatrix();
	}
	return Pair.of(this, mat);
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:17,代碼來源:ModelKnowledgeBook.java

示例4: handlePerspective

import javax.vecmath.Matrix4f; //導入依賴的package包/類
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	if (parentModel instanceof IPerspectiveAwareModel) {
		Matrix4f matrix4f = ((IPerspectiveAwareModel) parentModel).handlePerspective(cameraTransformType)
				.getRight();
		return Pair.of(this, matrix4f);
	}
	ItemCameraTransforms itemCameraTransforms = parentModel.getItemCameraTransforms();
	ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
	TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
	Matrix4f mat = null;
	if (tr != null) {
		mat = tr.getMatrix();
	}
	return Pair.of(this, mat);
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:17,代碼來源:BakedModelKnowledgeBook.java

示例5: getMatrix

import javax.vecmath.Matrix4f; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform)
{
    javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f();
    m.setIdentity();
    m.setTranslation(TRSRTransformation.toVecmath(transform.translation));
    t.setIdentity();
    t.rotY(transform.rotation.y);
    m.mul(t);
    t.setIdentity();
    t.rotX(transform.rotation.x);
    m.mul(t);
    t.setIdentity();
    t.rotZ(transform.rotation.z);
    m.mul(t);
    t.setIdentity();
    t.m00 = transform.scale.x;
    t.m11 = transform.scale.y;
    t.m22 = transform.scale.z;
    m.mul(t);
    return m;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:ForgeHooksClient.java

示例6: parseMatrix

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public static Matrix4f parseMatrix(JsonElement e)
{
    if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e);
    JsonArray m = e.getAsJsonArray();
    if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size());
    Matrix4f ret = new Matrix4f();
    for (int i = 0; i < 3; i++)
    {
        if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i));
        JsonArray r = m.get(i).getAsJsonArray();
        if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size());
        for (int j = 0; j < 4; j++)
        {
            try
            {
                ret.setElement(i, j, r.get(j).getAsNumber().floatValue());
            }
            catch (ClassCastException ex)
            {
                throw new JsonParseException("Matrix element: expected number, got: " + r.get(j));
            }
        }
    }
    return ret;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:ForgeBlockStateV1.java

示例7: mul

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public static Matrix4f mul(Vector3f translation, Quat4f leftRot, Vector3f scale, Quat4f rightRot)
{
    Matrix4f res = new Matrix4f(), t = new Matrix4f();
    res.setIdentity();
    if(leftRot != null)
    {
        t.set(leftRot);
        res.mul(t);
    }
    if(scale != null)
    {
        t.setIdentity();
        t.m00 = scale.x;
        t.m11 = scale.y;
        t.m22 = scale.z;
        res.mul(t);
    }
    if(rightRot != null)
    {
        t.set(rightRot);
        res.mul(t);
    }
    if(translation != null) res.setTranslation(translation);
    return res;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:TRSRTransformation.java

示例8: isInteger

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public static boolean isInteger(Matrix4f matrix)
{
    Matrix4f m = new Matrix4f();
    m.setIdentity();
    m.m30 = m.m31 = m.m32 = 1;
    m.m33 = 0;
    m.mul(matrix, m);
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            float v = m.getElement(i, j) / m.getElement(3, j);
            if(Math.abs(v - Math.round(v)) > 1e-5) return false;
        }
    }
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:18,代碼來源:TRSRTransformation.java

示例9: toLwjgl

import javax.vecmath.Matrix4f; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
public static org.lwjgl.util.vector.Matrix4f toLwjgl(Matrix4f m)
{
    org.lwjgl.util.vector.Matrix4f r = new org.lwjgl.util.vector.Matrix4f();
    r.m00 = m.m00;
    r.m01 = m.m10;
    r.m02 = m.m20;
    r.m03 = m.m30;
    r.m10 = m.m01;
    r.m11 = m.m11;
    r.m12 = m.m21;
    r.m13 = m.m31;
    r.m20 = m.m02;
    r.m21 = m.m12;
    r.m22 = m.m22;
    r.m23 = m.m32;
    r.m30 = m.m03;
    r.m31 = m.m13;
    r.m32 = m.m23;
    r.m33 = m.m33;
    return r;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:TRSRTransformation.java

示例10: getBlockTransforms

import javax.vecmath.Matrix4f; //導入依賴的package包/類
/** Get the default transformations for inside inventories and third person */
    protected static ImmutableMap<TransformType, TRSRTransformation> getBlockTransforms() {
        ImmutableMap.Builder<TransformType, TRSRTransformation> builder = ImmutableMap.builder();

        // Copied from ForgeBlockStateV1
        /*builder.put(TransformType.THIRD_PERSON, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, 1.5f / 16, -2.75f / 16),
                TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), new Vector3f(0.375f, 0.375f, 0.375f), null)));
*/
        // Gui
        {
            Matrix4f rotationMatrix = new Matrix4f();
            rotationMatrix.setIdentity();
            rotationMatrix = rotateTowardsFace(EnumFacing.SOUTH, EnumFacing.EAST);

            Matrix4f result = new Matrix4f();
            result.setIdentity();
            // Multiply by the last matrix transformation FIRST
            result.mul(rotationMatrix);

            TRSRTransformation trsr = new TRSRTransformation(result);

            builder.put(TransformType.GUI, trsr);
        }

        return builder.build();
    }
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:27,代碼來源:Fixed3DBlockModel.java

示例11: makeDomino

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public boolean makeDomino(float mass, Vector3f inertia, Vector3f loc,
        float angle) {
    if (cntCreated >= numDominoes)
        return false;
    int i = cntCreated++;
    dominoOrigTransform[i] = new Transform(new Matrix4f(new Quat4f(0,
            sin(angle) / (float) Math.sqrt(2), 0, 1), loc, 1.0f));
    DefaultMotionState dominoMotion = new DefaultMotionState(
            dominoOrigTransform[i]);
    RigidBodyConstructionInfo dominoRigidBodyCI = new RigidBodyConstructionInfo(
            mass, dominoMotion, dominoShape, inertia);
    domino[i] = new RigidBody(dominoRigidBodyCI);
    domino[i].setRestitution(0.5f);
    world.addRigidBody(domino[i]);
    return true;
}
 
開發者ID:android-workloads,項目名稱:JACWfA,代碼行數:17,代碼來源:Domino.java

示例12: fillEllipsoid

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public void fillEllipsoid(Point3f center, Point3f[] points, int x, int y,
                            int z, int diameter, Matrix3f mToEllipsoidal,
                            double[] coef, Matrix4f mDeriv,
                            int selectedOctant, Point3i[] octantPoints) {
  switch (diameter) {
  case 1:
    plotPixelClipped(argbCurrent, x, y, z);
    return;
  case 0:
    return;
  }
  if (diameter <= (antialiasThisFrame ? Sphere3D.maxSphereDiameter2
      : Sphere3D.maxSphereDiameter))
    sphere3d.render(shadesCurrent, !addAllPixels, diameter, x, y, z,
        mToEllipsoidal, coef, mDeriv, selectedOctant, octantPoints);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:Graphics3D.java

示例13: getXYZFromMatrix

import javax.vecmath.Matrix4f; //導入依賴的package包/類
final static String getXYZFromMatrix(Matrix4f mat, boolean is12ths,
                                     boolean allPositive, boolean halfOrLess) {
  String str = "";
  float[] row = new float[4];
  for (int i = 0; i < 3; i++) {
    mat.getRow(i, row);
    String term = "";
    if (row[0] != 0)
      term += (row[0] < 0 ? "-" : "+") + "x";
    if (row[1] != 0)
      term += (row[1] < 0 ? "-" : "+") + "y";
    if (row[2] != 0)
      term += (row[2] < 0 ? "-" : "+") + "z";
    term += xyzFraction((is12ths ? row[3] : row[3] * 12), allPositive,
        halfOrLess);
    if (term.length() > 0 && term.charAt(0) == '+')
      term = term.substring(1);
    str += "," + term;
  }
  return str.substring(1);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:SymmetryOperation.java

示例14: unescapeMatrix

import javax.vecmath.Matrix4f; //導入依賴的package包/類
public static Object unescapeMatrix(String strMatrix) {
  if (strMatrix == null || strMatrix.length() == 0)
    return strMatrix;
  String str = strMatrix.replace('\n', ' ').trim();
  if (str.lastIndexOf("[[") != 0 || str.indexOf("]]") != str.length() - 2)
    return strMatrix;
  float[] points = new float[16];
  str = str.substring(2, str.length() - 2).replace('[',' ').replace(']',' ').replace(',',' ');
  int[] next = new int[1];
  int nPoints = 0;
  for (; nPoints < 16; nPoints++) {
    points[nPoints] = Parser.parseFloat(str, next);
    if (Float.isNaN(points[nPoints])) {
      break;
    }
  }
  if (!Float.isNaN(Parser.parseFloat(str, next)))
    return strMatrix; // overflow
  if (nPoints == 9)
    return new Matrix3f(points);
  if (nPoints == 16)
    return new Matrix4f(points);
  return strMatrix;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:25,代碼來源:Escape.java

示例15: writeMatrixToArrayColumnMajor4f

import javax.vecmath.Matrix4f; //導入依賴的package包/類
/**
 * Writes the given matrix into the given array, in column-major order.
 * Neither the matrix nor the array may be <code>null</code>. The given
 * array must have a length of at least <code>offset+16</code>.
 * 
 * @param m The matrix
 * @param a The array
 * @param offset The offset where to start writing into the array
 */
private static void writeMatrixToArrayColumnMajor4f(
    Matrix4f m, float a[], int offset)
{
    int i = offset;
    a[i++] = m.m00;
    a[i++] = m.m10;
    a[i++] = m.m20;
    a[i++] = m.m30;
    a[i++] = m.m01;
    a[i++] = m.m11;
    a[i++] = m.m21;
    a[i++] = m.m31;
    a[i++] = m.m02;
    a[i++] = m.m12;
    a[i++] = m.m22;
    a[i++] = m.m32;
    a[i++] = m.m03;
    a[i++] = m.m13;
    a[i++] = m.m23;
    a[i++] = m.m33;
}
 
開發者ID:javagl,項目名稱:JglTF,代碼行數:31,代碼來源:ExternalCameraRendering.java


注:本文中的javax.vecmath.Matrix4f類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。