diff options
author | Mary <33456283+FourIsTheNumber@users.noreply.github.com> | 2024-07-31 13:13:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 00:13:20 +0700 |
commit | 99b0281dcf4ba451a363f811fdc6b671a239dc71 (patch) | |
tree | 7391763433587d53031b3e86dba37aa473eb332c /src/main/java/gregtech/common/render | |
parent | b4ee66356b06d0fcc75654506ed67aa57755393b (diff) | |
download | GT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.tar.gz GT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.tar.bz2 GT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.zip |
Laser Engraver Multi (#2771)
* Laser engraver boilerplate and structure
* Made a rough, untextured laser renderer
* Laser renderer is kind of functional
* Laser renderer follows curve
* Laser turns on/off when recipe is running
* Sampsa laser
* Color changing boilerplate
* Registered all gt lenses
* Fixed default renderer to white
* NBT reading functional
* Stole SE code to try and get TE working. It does not
* Laser renderer finally functioning with more than 1 laser!
* Moved tick count to TileLaser so lasers don't tick each other
* Implemented laser source hatch
* Structure update + spotless
* Switched to the GT_Values tier list
* Update tooltip and message player about rendering toggle
* Allow fluid input/output
* Attempting to give proper name to laser plate
* Fixed laser plate name
* New laser plate texture
* New casing just dropped
* Allow UMV glass to use any laser source
* Switched laser to a simple line renderer instead of a model
* Fixed hatch texture I missed earlier
* Spotless
* Controller textures
* render: New laser renderer
- Use GL quad rendering instead of line rendering to fix scaling
- Set lightmap coords (Emit bloom glow with shaders)
- Set opacity to 1.0
- Slight cleanup
* Got rid of the old laser model
* Tweaked some numbers on the renderer
* Spotless
* cleanup
* I give up on rotation, I've spent too much time trying to get this to work
* Got block item working I think
* Fixed tooltip for laser and multicanner
* Support bartworks lenses
* Finishing touches
* Removed unneeded assignment
* Allow UXV lasers to do all recipes
* Forgot to call super for nbt data...
* Replace magic numbers
* oops, spotless
* Another magic voltage number
* Rotations and mirror flips
Now with spotless
* fixed west/east
* ok but actually fixed now, mixed up west/east with north/south
* Updated laser source snapping to account for rotation being allowed
* Cleanup rotation axis and remove unecessary nbt
* Re-added nbt but actually load it properly now
* Fix NEI displaying lots of hatches
---------
Co-authored-by: LekKit <50500857+LekKit@users.noreply.github.com>
Co-authored-by: BucketBrigade <apple12a1@hotmail.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/common/render')
-rw-r--r-- | src/main/java/gregtech/common/render/GT_LaserRenderer.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/render/GT_LaserRenderer.java b/src/main/java/gregtech/common/render/GT_LaserRenderer.java new file mode 100644 index 0000000000..1c54a5d58b --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_LaserRenderer.java @@ -0,0 +1,90 @@ +package gregtech.common.render; + +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ClientRegistry; +import gregtech.common.tileentities.render.TileLaser; + +public class GT_LaserRenderer extends TileEntitySpecialRenderer { + + private double zOffset = 0.0; + private double xOffset = 0.0; + + // Relative to block size + final private double lineRadius = 0.03; + + final private float lineOpacity = 0.7F; + + final private float laserSpeed = 0.8F; + + public GT_LaserRenderer() { + ClientRegistry.bindTileEntitySpecialRenderer(TileLaser.class, this); + } + + private void maths(float counter) { + float tc = (0.05F * counter); + zOffset = 0.5 + 0.45 * Math.sin(2 * Math.PI * tc); + xOffset = 0.5 + 0.45 * Math.sin(0.5 * Math.PI * tc); + } + + private void renderFakeLine(TileLaser laser, double x1, double y1, double z1, double x2, double y2, double z2) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(laser.getRed(), laser.getGreen(), laser.getBlue(), lineOpacity); + tessellator.addVertex(x1 - lineRadius, y1, z1); + tessellator.addVertex(x1 + lineRadius, y1, z1); + tessellator.addVertex(x2 + lineRadius, y2, z2); + tessellator.addVertex(x2 - lineRadius, y2, z2); + + tessellator.addVertex(x1, y1, z1 - lineRadius); + tessellator.addVertex(x1, y1, z1 + lineRadius); + tessellator.addVertex(x2, y2, z2 + lineRadius); + tessellator.addVertex(x2, y2, z2 - lineRadius); + tessellator.draw(); + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + final TileLaser ltile = (TileLaser) tile; + + if (ltile.getShouldRender()) { + // Push GL state + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + + // Full brightness on this thing (Emits glow with shaders) + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.f, 240.f); + + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glRotated(ltile.rotationAngle, ltile.rotAxisX, ltile.rotAxisY, ltile.rotAxisZ); + GL11.glTranslated(-x - 0.5, -y - 0.5, -z - 0.5); + + if (ltile.realism) { + renderFakeLine(ltile, x + xOffset, y + 4.0, z + zOffset, x + xOffset, y + 0.5, z + zOffset); + } else { + renderFakeLine(ltile, x + 0.5, y + 4.0, z + 0.5, x + xOffset, y + 0.5, z + zOffset); + } + + // Pop GL state + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + // Movement calculations + maths(ltile.counter); + ltile.counter += laserSpeed; + if (ltile.counter >= 80) { + ltile.counter = 0; + } + } + } +} |