public Vector3f vector3f() { return new Vector3f((float)x, (float)y, (float)z); }
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]); } } } }
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 ) ) ); }
@SideOnly( Side.CLIENT ) private static Pair<ItemStack, Matrix4f> getRenderedItem( TileCharger tile ) { Matrix4f transform = new Matrix4f(); transform.translate( new Vector3f( 0.5f, 0.4f, 0.5f ) ); return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform ); }
/** * Negate a vector and place the result in a destination vector. * @param dest The destination vector or null if a new vector is to be created * @return the negated vector */ public Vector3f negate(Vector3f dest) { if (dest == null) dest = new Vector3f(); dest.x = -x; dest.y = -y; dest.z = -z; return dest; }
public CubeBuilder from(float x, float y, float z) { this.from = new Vector3f(x / 16, y / 16, z / 16); return this; }
public CubeBuilder to(float x, float y, float z) { this.to = new Vector3f(x / 16, y / 16, z / 16); return this; }
public Vertex(float x, float y, float z) { this(new Vector3f(x, y, z)); }
public static Vector3f randomCirclePoint(float radius, Random rand) { double u = rand.nextDouble(); double theta = 2 * Math.PI * u; double x = (radius * Math.sin(theta)); double z = (radius * Math.cos(theta)); return new Vector3f((float) x, 0, (float) z); }
public static Vector3f randomSpherePoint(double x0, double y0, double z0, Vec3d radius, Random rand) { double u = rand.nextDouble(); double v = rand.nextDouble(); double theta = 2 * Math.PI * u; double phi = Math.acos(2 * v - 1); double x = x0 + (radius.x * Math.sin(phi) * Math.cos(theta)); double y = y0 + (radius.y * Math.sin(phi) * Math.sin(theta)); double z = z0 + (radius.z * Math.cos(phi)); return new Vector3f((float) x, (float) y, (float) z); }
@SideOnly(Side.CLIENT) public Vector3f vector3f() { return new Vector3f((float)x, (float)y, (float)z); }
@SideOnly(Side.CLIENT) public Vector3f vector3f() { return new Vector3f((float) x, (float) y, (float) z); }
/** * Add a vector to another vector and place the result in a destination * vector. * @param left The LHS vector * @param right The RHS vector * @param dest The destination vector, or null if a new vector is to be created * @return the sum of left and right in dest */ public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { if (dest == null) return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); else { dest.set(left.x + right.x, left.y + right.y, left.z + right.z); return dest; } }
public static Matrix4f createEntityRotateMatrix(Entity entity) { double yaw = Math.toRadians(entity.rotationYaw - 180); double pitch = Math.toRadians(entity.rotationPitch); Matrix4f initial = new Matrix4f(); initial.rotate((float)pitch, new Vector3f(1, 0, 0)); initial.rotate((float)yaw, new Vector3f(0, 1, 0)); return initial; }
private static Vector3f calculateSpherePoint(float x, float y) { Vector3f result = new Vector3f(x, y, 0); float sqrZ = 1 - Vector3f.dot(result, result); if (sqrZ > 0) result.z = (float)Math.sqrt(sqrZ); else result.normalise(); return result; }
/** * Normalise this vector and place the result in another vector. * @param dest The destination vector, or null if a new vector is to be created * @return the normalised vector */ public Vector3f normalise(Vector3f dest) { float l = length(); if (dest == null) dest = new Vector3f(x / l, y / l, z / l); else dest.set(x / l, y / l, z / l); return dest; }
@SideOnly(Side.CLIENT) void spawnParticles(World world) { if (hit != null && world.getTileEntity(hit.getBlockPos()) instanceof TileEntityGravitationalAnomaly) { if (random.nextFloat() < 0.3f) { float r = (float) getBeamColorR(); float g = (float) getBeamColorG(); float b = (float) getBeamColorB(); EnumFacing up = getAboveSide(world.getBlockState(getPos()).getValue(MOBlock.PROPERTY_DIRECTION)).getOpposite(); GravitationalStabilizerBeamParticle particle = new GravitationalStabilizerBeamParticle(world, new Vector3f(getPos().getX() + 0.5f, getPos().getY() + 0.5f, getPos().getZ() + 0.5f), new Vector3f(hit.getBlockPos().getX() + 0.5f, hit.getBlockPos().getY() + 0.5f, hit.getBlockPos().getZ() + 0.5f), new Vector3f(up.getFrontOffsetX(), up.getFrontOffsetY(), up.getFrontOffsetZ()), 1f, 0.3f, 80); particle.setColor(r, g, b, 1); ClientProxy.renderHandler.getRenderParticlesHandler().addEffect(particle, RenderParticlesHandler.Blending.Additive); } } }
public static void rotateFromBlock(Matrix4f mat, IBlockAccess world, BlockPos pos) { if (world != null) { IBlockState blockState = world.getBlockState(pos); EnumFacing rotation = blockState.getValue(MOBlock.PROPERTY_DIRECTION); Vector3f axis = new Vector3f(0, 1, 0); if (rotation == EnumFacing.WEST) { mat.rotate(-(float) (Math.PI / 2), axis); } else if (rotation == EnumFacing.EAST) { mat.rotate((float) (Math.PI / 2), axis); } else if (rotation == EnumFacing.NORTH) { mat.rotate(-(float) (Math.PI), axis); } } }
private void renderAttack(Vector3f dir, float percent) { GlStateManager.pushMatrix(); Vector3f front = new Vector3f(1, 0, 0); Vector3f c = Vector3f.cross(dir, front, null); double omega = Math.acos(Vector3f.dot(dir, front)); GlStateManager.rotate((float) (omega * (180 / Math.PI)), c.x, c.y, c.z); RenderUtils.applyColorWithMultipy(Reference.COLOR_HOLO, 1 * percent); Minecraft.getMinecraft().renderEngine.bindTexture(forcefield_damage_tex); //normal_sphere.renderAll(); GlStateManager.popMatrix(); } }