/** * Computes and returns the scale. * * @return */ public final void getScale(Vector3f scaleToPack) { computeScale(); scaleToPack.setX((float) scale1); scaleToPack.setY((float) scale2); scaleToPack.setZ((float) scale3); }
@Override public boolean setBlockState(BlockPos pos, IBlockState newState, int flags) { if(newState.getBlock() == Blocks.AIR) { renderedBlocks.remove(pos); } else { renderedBlocks.add(pos); } minPos.setX(Math.min(minPos.getX(), pos.getX())); minPos.setY(Math.min(minPos.getY(), pos.getY())); minPos.setZ(Math.min(minPos.getZ(), pos.getZ())); maxPos.setX(Math.max(maxPos.getX(), pos.getX())); maxPos.setY(Math.max(maxPos.getY(), pos.getY())); maxPos.setZ(Math.max(maxPos.getZ(), pos.getZ())); return super.setBlockState(pos, newState, flags); }
/** * Retrieves the normal of this planar region and stores it in the given {@link Vector3f}. * @param normalToPack used to store the normal of this planar region. */ public void getNormal(Vector3f normalToPack) { normalToPack.setX((float) fromLocalToWorldTransform.getM02()); normalToPack.setY((float) fromLocalToWorldTransform.getM12()); normalToPack.setZ((float) fromLocalToWorldTransform.getM22()); }
public Vector3f getSize() { Vector3f result = new Vector3f(); result.setX(maxPos.getX() - minPos.getX()); result.setY(maxPos.getY() - minPos.getY()); result.setZ(maxPos.getZ() - minPos.getZ()); return result; }
float vz = normal.getZ(); normal.setX(rxx * vx + rxy * vy + rxz * vz); normal.setY(ryx * vx + ryy * vy + ryz * vz); normal.setZ(rzx * vx + rzz * vz);
/** * Transform vector by multiplying it by this transform and put result back * into vector. * * @param vector */ public final void transform(Vector3f vector) { double x = mat00 * vector.getX() + mat01 * vector.getY() + mat02 * vector.getZ(); double y = mat10 * vector.getX() + mat11 * vector.getY() + mat12 * vector.getZ(); vector.setZ((float) (mat20 * vector.getX() + mat21 * vector.getY() + mat22 * vector.getZ())); vector.setX((float) x); vector.setY((float) y); }
/** * Multiply a 3x3 matrix by a 3x1 vector. Since result is stored in vector, the matrix must be 3x3. * @param matrix * @param vector */ public static void mult(DenseMatrix64F matrix, Vector3f vector) { if (matrix.numCols != 3 || matrix.numRows != 3) { throw new RuntimeException("Improperly sized matrices."); } float x = vector.getX(); float y = vector.getY(); float z = vector.getZ(); vector.setX((float) (matrix.get(0, 0) * x + matrix.get(0, 1) * y + matrix.get(0, 2) * z)); vector.setY((float) (matrix.get(1, 0) * x + matrix.get(1, 1) * y + matrix.get(1, 2) * z)); vector.setZ((float) (matrix.get(2, 0) * x + matrix.get(2, 1) * y + matrix.get(2, 2) * z)); }
/** * Transform vector by multiplying it by this transform and put result back * into vector. * * @param vector */ public final void transform(Vector3f vectorIn, Vector3f vectorOut) { if (vectorIn != vectorOut) { vectorOut.setX((float) (mat00 * vectorIn.getX() + mat01 * vectorIn.getY() + mat02 * vectorIn.getZ())); vectorOut.setY((float) (mat10 * vectorIn.getX() + mat11 * vectorIn.getY() + mat12 * vectorIn.getZ())); vectorOut.setZ((float) (mat20 * vectorIn.getX() + mat21 * vectorIn.getY() + mat22 * vectorIn.getZ())); } else { transform(vectorIn); } }
normal.setY((float) transform.getM12()); normal.setZ((float) transform.getM22()); vertexNormals[vertexIndex] = normal;