本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}