public Vector3f vector3f() { return new Vector3f((float)x, (float)y, (float)z); }
public Vector4f vector4f() { return new Vector4f((float)x, (float)y, (float)z, 1); }
private FacingToRotation( Vector3f rot ) { this.rot = rot; this.mat = TRSRTransformation .toVecmath( new org.lwjgl.util.vector.Matrix4f().rotate( (float) Math.toRadians( rot.x ), new org.lwjgl.util.vector.Vector3f( 1, 0, 0 ) ) .rotate( (float) Math.toRadians( rot.y ), new org.lwjgl.util.vector.Vector3f( 0, 1, 0 ) ) .rotate( (float) Math.toRadians( rot.z ), new org.lwjgl.util.vector.Vector3f( 0, 0, 1 ) ) ); }
@Override public ItemTransformVec3f deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = p_deserialize_1_.getAsJsonObject(); Vector3f vector3f = this.parseVector3f(jsonobject, "rotation", ROTATION_DEFAULT); Vector3f vector3f1 = this.parseVector3f(jsonobject, "translation", TRANSLATION_DEFAULT); vector3f1.scale(0.0625F); vector3f1.x = MathHelper.clamp(vector3f1.x, -5.0F, 5.0F); vector3f1.y = MathHelper.clamp(vector3f1.y, -5.0F, 5.0F); vector3f1.z = MathHelper.clamp(vector3f1.z, -5.0F, 5.0F); Vector3f vector3f2 = this.parseVector3f(jsonobject, "scale", SCALE_DEFAULT); vector3f2.x = MathHelper.clamp(vector3f2.x, -4.0F, 4.0F); vector3f2.y = MathHelper.clamp(vector3f2.y, -4.0F, 4.0F); vector3f2.z = MathHelper.clamp(vector3f2.z, -4.0F, 4.0F); return new ItemTransformVec3f(vector3f, vector3f1, vector3f2); }
/** * Translate this matrix and stash the result in another matrix * @param vec The vector to translate by * @param dest The destination matrix or null if a new matrix is to be created * @return the translated matrix */ public Matrix4f translate(Vector2f vec, Matrix4f dest) { return translate(vec, this, dest); }
@Override public void renderTileEntityAt( T te, double x, double y, double z, float partialTicks, int destroyStage ) { Pair<ItemStack, Matrix4f> pair = this.f.apply( te ); if( pair != null && pair.getLeft() != null ) { GlStateManager.pushMatrix(); if( pair.getRight() != null ) { FloatBuffer matrix = BufferUtils.createFloatBuffer( 16 ); pair.getRight().store( matrix ); matrix.flip(); GlStateManager.multMatrix( matrix ); } Minecraft.getMinecraft().getRenderItem().renderItem( pair.getLeft(), TransformType.GROUND ); GlStateManager.popMatrix(); } }
/** * Constructor */ public Vector3f(ReadableVector3f src) { set(src); }
/** * Invert this matrix * @return this if successful, null otherwise */ public Matrix invert() { return invert(this, this); }
/** * Constructor for Matrix2f. The matrix is initialised to the identity. */ public Matrix2f() { setIdentity(); }
/** * Load from another matrix * @param src The source matrix * @return this */ public Matrix2f load(Matrix2f src) { return load(src, this); }
/** * Invert this matrix * @return this if successful, null otherwise */ public Matrix invert() { return invert(this, this); }
/** * Negate this matrix and stash the result in another matrix. * @param dest The destination matrix, or null if a new matrix is to be created * @return the negated matrix */ public Matrix2f negate(Matrix2f dest) { return negate(this, dest); }
/** * Constructor */ public Vector4f(ReadableVector4f src) { set(src); }
/** * Load from another matrix * @param src The source matrix * @return this */ public Matrix3f load(Matrix3f src) { return load(src, this); }
/** * Transpose this matrix and place the result in another matrix * @param dest The destination matrix or null if a new matrix is to be created * @return the transposed matrix */ public Matrix4f transpose(Matrix4f dest) { return transpose(this, dest); }
/** * Transpose this matrix and place the result in another matrix. * @param dest The destination matrix or null if a new matrix is to be created * @return the transposed matrix */ public Matrix2f transpose(Matrix2f dest) { return transpose(this, dest); }
/** * Set this matrix to 0. * @return this */ public Matrix setZero() { return setZero(this); }
private Vector3f parseVector3f(JsonObject jsonObject, String key, Vector3f defaultValue) { if(!jsonObject.has(key)) { return defaultValue; } else { JsonArray jsonarray = JsonUtils.getJsonArray(jsonObject, key); if(jsonarray.size() != 3) { throw new JsonParseException("Expected 3 " + key + " values, found: " + jsonarray.size()); } else { float[] afloat = new float[3]; for(int i = 0; i < afloat.length; ++i) { afloat[i] = JsonUtils.getFloat(jsonarray.get(i), key + "[" + i + "]"); } return new Vector3f(afloat[0], afloat[1], afloat[2]); } } } }