-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of changes to client graphics stuff
- Loading branch information
1 parent
09ebca7
commit 30c8dd1
Showing
10 changed files
with
244 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ext.spongeVersion = '5.0.0-SNAPSHOT' | ||
ext.clientForgeVersion = '2079' | ||
ext.mcpMappings = 'snapshot_20160822' | ||
ext.gradleWrapperVersion = '3.1' | ||
ext.gradleWrapperVersion = '3.2.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world; | ||
|
||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry.Geometry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.ConcurrentModificationException; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public class RenderList extends ArrayList<Geometry> { | ||
|
||
public void sortZ(double x, double y, double z) { | ||
try { | ||
for(Geometry geo : this){ | ||
geo.distance = geo.position.distanceSquared(x, y, z); | ||
} | ||
this.sort((o1, o2) -> o1.distance > o2.distance ? -1 : (o1.distance < o2.distance ? 1 : 0)); | ||
} catch (ConcurrentModificationException ignored) { | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world; | ||
|
||
import com.flowpowered.math.vector.Vector3i; | ||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry.Geometry; | ||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.renderable.Highlight; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.EntityPlayerSP; | ||
import net.minecraftforge.client.event.RenderWorldLastEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import static org.lwjgl.opengl.GL11.*; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public class RenderManager { | ||
|
||
private static RenderManager inst; | ||
|
||
private Minecraft mc; | ||
private RenderList list; | ||
|
||
private RenderManager(Minecraft mc) { | ||
this.mc = mc; | ||
this.list = new RenderList(); | ||
|
||
list.addAll(new Highlight(new Vector3i(0,80,0)).getGeometry()); | ||
} | ||
|
||
public static RenderManager instance() { | ||
if (inst == null) { | ||
inst = new RenderManager(Minecraft.getMinecraft()); | ||
} | ||
return inst; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@SubscribeEvent | ||
public void render(RenderWorldLastEvent event) { | ||
|
||
//System.out.println("TEST"); | ||
EntityPlayerSP player = mc.thePlayer; | ||
float partialTicks = event.getPartialTicks(); | ||
double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; | ||
double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; | ||
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; | ||
list.sortZ(playerX, playerY, playerZ); | ||
|
||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT); | ||
|
||
glDisable(GL_LIGHTING); | ||
glDisable(GL_TEXTURE_2D); | ||
glDisable(GL_ALPHA_TEST); | ||
glEnable(GL_BLEND); | ||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
glDepthMask(false); | ||
//glDisable(GL_DEPTH_TEST); | ||
|
||
glLineWidth(2f); | ||
|
||
for (Geometry geo : list) { | ||
glPushMatrix(); | ||
glTranslated(geo.position.getX(), geo.position.getY(), geo.position.getZ()); | ||
geo.render(); | ||
glPopMatrix(); | ||
} | ||
|
||
glPopAttrib(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/Geometry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry; | ||
|
||
import com.flowpowered.math.vector.Vector3d; | ||
import com.flowpowered.math.vector.Vector3f; | ||
|
||
import java.util.Vector; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public abstract class Geometry { | ||
|
||
public double distance; | ||
public Vector3d position; | ||
public Vector3f color; | ||
public float opacity; | ||
|
||
abstract public void render(); | ||
|
||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/GeometryLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry; | ||
|
||
import com.flowpowered.math.vector.Vector3d; | ||
import com.flowpowered.math.vector.Vector3f; | ||
|
||
import static org.lwjgl.opengl.GL11.*; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public class GeometryLine extends Geometry { | ||
|
||
Vector3d start, end; | ||
Vector3d localStart, localEnd; | ||
|
||
|
||
|
||
public GeometryLine(Vector3d start, Vector3d end, Vector3f color, float opacity) { | ||
this.start = start; | ||
this.end = end; | ||
this.color = color; | ||
this.opacity = opacity; | ||
|
||
this.position = start.add(end).div(2); | ||
this.localStart = start.sub(position); | ||
this.localEnd = end.sub(position); | ||
} | ||
|
||
@Override | ||
public void render() { | ||
glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT | GL_HINT_BIT); | ||
glColor4f(color.getX(), color.getY(), color.getZ(), opacity); | ||
glEnable(GL_LINE_SMOOTH); | ||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); | ||
|
||
glBegin(GL_LINES); | ||
|
||
glVertex3d(localStart.getX(), localStart.getY(), localStart.getZ()); | ||
glVertex3d(localEnd.getX(), localEnd.getY(), localEnd.getZ()); | ||
|
||
glEnd(); | ||
glPopAttrib(); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/renderable/Highlight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world.renderable; | ||
|
||
import com.flowpowered.math.vector.Vector3d; | ||
import com.flowpowered.math.vector.Vector3f; | ||
import com.flowpowered.math.vector.Vector3i; | ||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry.Geometry; | ||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry.GeometryLine; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public class Highlight implements IRenderable { | ||
|
||
private static final double OFFSET = 0.01; | ||
private static final float OPACITY = 0.5f; | ||
|
||
Vector3i pos; | ||
Vector3f color; | ||
|
||
List<Geometry> geometries = new ArrayList<>(); | ||
|
||
public Highlight(Vector3i pos) { | ||
this(pos, Vector3f.ONE); | ||
} | ||
|
||
public Highlight(Vector3i pos, Vector3f color) { | ||
this.pos = pos; | ||
this.color = color; | ||
} | ||
|
||
@Override | ||
public Collection<Geometry> getGeometry() { | ||
if (geometries.isEmpty()) { | ||
final Vector3d posD = pos.toDouble(); | ||
final Vector3d v1 = posD.add(-OFFSET, -OFFSET, -OFFSET); | ||
final Vector3d v2 = posD.add(1 + OFFSET, -OFFSET, -OFFSET); | ||
final Vector3d v3 = posD.add(-OFFSET, 1 + OFFSET, -OFFSET); | ||
final Vector3d v4 = posD.add(-OFFSET, -OFFSET, 1 + OFFSET); | ||
final Vector3d v5 = posD.add(1 + OFFSET, 1 + OFFSET, -OFFSET); | ||
final Vector3d v6 = posD.add(-OFFSET, 1 + OFFSET, 1 + OFFSET); | ||
final Vector3d v7 = posD.add(1 + OFFSET, -OFFSET, 1 + OFFSET); | ||
final Vector3d v8 = posD.add(1 + OFFSET, 1 + OFFSET, 1 + OFFSET); | ||
|
||
geometries.add(new GeometryLine(v1, v2, color, OPACITY)); | ||
geometries.add(new GeometryLine(v1, v3, color, OPACITY)); | ||
geometries.add(new GeometryLine(v1, v4, color, OPACITY)); | ||
geometries.add(new GeometryLine(v2, v5, color, OPACITY)); | ||
geometries.add(new GeometryLine(v2, v7, color, OPACITY)); | ||
geometries.add(new GeometryLine(v3, v5, color, OPACITY)); | ||
geometries.add(new GeometryLine(v3, v6, color, OPACITY)); | ||
geometries.add(new GeometryLine(v4, v6, color, OPACITY)); | ||
geometries.add(new GeometryLine(v4, v7, color, OPACITY)); | ||
geometries.add(new GeometryLine(v5, v8, color, OPACITY)); | ||
geometries.add(new GeometryLine(v6, v8, color, OPACITY)); | ||
geometries.add(new GeometryLine(v7, v8, color, OPACITY)); | ||
} | ||
return geometries; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/renderable/IRenderable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.foxdenstudio.sponge.foxcore.mod.rendernew.world.renderable; | ||
|
||
import net.foxdenstudio.sponge.foxcore.mod.rendernew.world.geometry.Geometry; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Created by Fox on 12/4/2016. | ||
*/ | ||
public interface IRenderable { | ||
|
||
Collection<Geometry> getGeometry(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters