private Matrix4f getTransform(float mouseX, float mouseY) { Preconditions.checkNotNull(dragStart, "Draging not started"); Vector3f current = calculateSpherePoint(mouseX, mouseY); float dot = Vector3f.dot(dragStart, current); if (Math.abs(dot - 1) < 0.0001) return lastTransform; Vector3f axis = Vector3f.cross(dragStart, current, null); try { axis.normalise(); } catch (IllegalStateException e) { // Zero length vector return lastTransform; } float angle = 2 * (float)(Math.acos(dot)); Matrix4f rotation = new Matrix4f(); rotation.rotate(angle, axis); return Matrix4f.mul(rotation, lastTransform, null); }
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(); } }
@SideOnly(Side.CLIENT) public void SpawnReplicateParticles(Entity entity, Vector3f p) { double entityRadius = entity.width; double entityArea = Math.max(entityRadius * entity.height, 0.3); double radiusX = entityRadius + random.nextDouble() * 0.2f; double radiusZ = entityRadius + random.nextDouble() * 0.2f; double time = Math.min((double) (transportTimer) / (double) (getTransportDelay()), 1); double gravity = 0.015f; int age = (int) Math.round(MOMathHelper.easeIn(time, 5, 15, 1)); int count = (int) Math.round(MOMathHelper.easeIn(time, 2, entityArea * 15, 1)); for (int i = 0; i < count; i++) { float speed = random.nextFloat() * 0.05f + 0.15f; float height = p.y + 1 + random.nextFloat() * entity.height; Vector3f origin = new Vector3f(p.x, height, p.z); Vector3f pos = MOMathHelper.randomSpherePoint(origin.x, origin.y, origin.z, new Vec3d(radiusX, 0, radiusZ), random); Vector3f dir = Vector3f.cross(Vector3f.sub(origin, pos, null), new Vector3f(0, 1, 0), null); dir.scale(speed); ReplicatorParticle replicatorParticle = new ReplicatorParticle(this.world, pos.x, pos.y, pos.z, dir.x, dir.y, dir.z); replicatorParticle.setCenter(origin.x, origin.y, origin.z); replicatorParticle.setParticleAge(age); replicatorParticle.setPointGravityScale(gravity); Minecraft.getMinecraft().effectRenderer.addEffect(replicatorParticle); } }
/** * Called to update the entity's position/logic. */ public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.particleAge++ >= this.particleMaxAge) { this.setExpired(); } float percent = (float) this.particleAge / (float) this.particleMaxAge; Vector3f dir = Vector3f.sub(to, from, null); Vector3f spiralDir = Vector3f.cross(dir.normalise(null), up, null); spiralDir.scale((float) Math.sin((particleAge + startTime) * 0.5) * orbitRadius); Vector3f up = new Vector3f(this.up); up.scale((float) Math.cos((particleAge + startTime) * 0.5) * orbitRadius); Vector3f.add(spiralDir, up, spiralDir); dir.scale(percent); Vector3f posOnPath = Vector3f.add(from, dir, null); setPosition(posOnPath.x + spiralDir.x, posOnPath.y + spiralDir.y, posOnPath.z + spiralDir.z); } }
Vector3f destination = new Vector3f((float) hit.hitVec.x, (float) hit.hitVec.y, (float) hit.hitVec.z); Vector3f dir = Vector3f.sub(destination, source, null); Vector3f dirC = Vector3f.cross(dir, new Vector3f(1, 0, 1), null); float distance = dir.length(); dir.normalise(dir); Vector3f front = new Vector3f(0, 0, -1); Vector3f c = Vector3f.cross(dir, front, null); double omega = Math.acos(Vector3f.dot(dir, front)); GlStateManager.enableBlend();
public static void beginDrawinngBlockScreen(double x, double y, double z, EnumFacing side, Color color, TileEntity entity, double offset, float glowAlpha) { GlStateManager.enableBlend(); GlStateManager.disableLighting(); disableLightmap(); Vector3f dir = new Vector3f(side.getDirectionVec().getX(), side.getDirectionVec().getY(), side.getDirectionVec().getZ()); Vector3f front = new Vector3f(0, 0, -1); Vector3f c = Vector3f.cross(front, dir, null); double omega = Math.acos(Vector3f.dot(front, dir)); if (omega == Math.PI) { c.y = 1; } GlStateManager.pushMatrix(); GlStateManager.translate(dir.x * (0.5 + offset), dir.y * (0.5 + offset), dir.z * (0.5 + offset)); GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5); GlStateManager.rotate((float) (omega * (180 / Math.PI)), c.x, c.y, c.z); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.5, -0.5, 0); GlStateManager.blendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); float multiply = (float) (MOMathHelper.noise(entity.getPos().getX(), entity.getWorld().getWorldTime() * 0.01, entity.getPos().getZ()) * 0.5 + 0.5) * glowAlpha; GlStateManager.color(color.getFloatR() * multiply, color.getFloatG() * multiply, color.getFloatB() * multiply); Minecraft.getMinecraft().getTextureManager().bindTexture(TileEntityRendererPatternMonitor.screenTextureGlow); RenderUtils.drawPlane(1); GlStateManager.translate(0, 0, -0.05); GlStateManager.color(color.getFloatR() * 0.05f, color.getFloatG() * 0.05f, color.getFloatB() * 0.05f); Minecraft.getMinecraft().getTextureManager().bindTexture(TileEntityRendererPatternMonitor.screenTextureBack); RenderUtils.drawPlane(1); }