Permalink
Browse files

- Shapes now used to in the display of block icons and held blocks

 - Alpha testing now enabled when rendering translucent held blocks
  • Loading branch information...
immortius committed Feb 11, 2012
1 parent f9891c0 commit 986cd37e857ee9d7f3fab8306ec6b2da3ae3f8f1
@@ -2,6 +2,7 @@
<dictionary name="Immortius">
<words>
<w>biome</w>
+ <w>tessellator</w>
</words>
</dictionary>
</component>
View
@@ -0,0 +1,2 @@
+
+*.log*
@@ -22,7 +22,7 @@
import org.terasology.logic.manager.TextureManager;
import org.terasology.model.structures.AABB;
import org.terasology.rendering.primitives.Mesh;
-import org.terasology.rendering.primitives.MeshCollection;
+import org.terasology.rendering.primitives.TessellatorHelper;
import org.terasology.rendering.primitives.Tessellator;
import org.terasology.rendering.world.WorldRenderer;
import org.terasology.utilities.MathHelper;
@@ -57,10 +57,10 @@ public GelatinousCube(WorldRenderer parent) {
_randomSize = (float) MathHelper.clamp((_parent.getWorldProvider().getRandom().randomDouble() + 1.0) / 2.0 + 0.15);
_randomColorId = Math.abs(_parent.getWorldProvider().getRandom().randomInt()) % COLORS.length;
- MeshCollection.addBlockMesh(new Vector4f(COLORS[_randomColorId].x, COLORS[_randomColorId].y, COLORS[_randomColorId].y, 1.0f), 0.8f * _randomSize, 0.8f, 0.6f, 0f, 0f, 0f);
- MeshCollection.addBlockMesh(new Vector4f(COLORS[_randomColorId].x, COLORS[_randomColorId].y, COLORS[_randomColorId].y, 0.6f), 1.0f * _randomSize, 1.0f, 0.8f, 0f, 0f, 0f);
- _mesh = Tessellator.getInstance().generateMesh();
- Tessellator.getInstance().resetAll();
+ Tessellator tessellator = new Tessellator();
+ TessellatorHelper.addBlockMesh(tessellator, new Vector4f(COLORS[_randomColorId].x, COLORS[_randomColorId].y, COLORS[_randomColorId].y, 1.0f), 0.8f * _randomSize, 0.8f, 0.6f, 0f, 0f, 0f);
+ TessellatorHelper.addBlockMesh(tessellator, new Vector4f(COLORS[_randomColorId].x, COLORS[_randomColorId].y, COLORS[_randomColorId].y, 0.6f), 1.0f * _randomSize, 1.0f, 0.8f, 0f, 0f, 0f);
+ _mesh = tessellator.generateMesh();
}
public void update() {
@@ -43,7 +43,7 @@
import org.terasology.rendering.cameras.FirstPersonCamera;
import org.terasology.rendering.physics.BulletPhysicsRenderer;
import org.terasology.rendering.primitives.Mesh;
-import org.terasology.rendering.primitives.MeshCollection;
+import org.terasology.rendering.primitives.TessellatorHelper;
import org.terasology.rendering.primitives.Tessellator;
import org.terasology.rendering.world.WorldRenderer;
import org.terasology.utilities.MathHelper;
@@ -477,9 +477,9 @@ public void renderExtractionOverlay() {
Vector2f texPos = new Vector2f(0.0f, 0.0f);
Vector2f texWidth = new Vector2f(0.0624f, 0.0624f);
- MeshCollection.addBlockMesh(new Vector4f(1, 1, 1, 1), texPos, texWidth, 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
- _overlayMesh = Tessellator.getInstance().generateMesh();
- Tessellator.getInstance().resetAll();
+ Tessellator tessellator = new Tessellator();
+ TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, 1), texPos, texWidth, 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ _overlayMesh = tessellator.generateMesh();
}
glMatrixMode(GL_TEXTURE);
@@ -531,9 +531,9 @@ public void renderHand() {
Vector2f texPos = new Vector2f(40.0f * 0.015625f, 32.0f * 0.03125f);
Vector2f texWidth = new Vector2f(4.0f * 0.015625f, -12.0f * 0.03125f);
- MeshCollection.addBlockMesh(new Vector4f(1, 1, 1, 1), texPos, texWidth, 1.0f, 1.0f, 0.9f, 0.0f, 0.0f, 0.0f);
- _handMesh = Tessellator.getInstance().generateMesh();
- Tessellator.getInstance().resetAll();
+ Tessellator tessellator = new Tessellator();
+ TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, 1), texPos, texWidth, 1.0f, 1.0f, 0.9f, 0.0f, 0.0f, 0.0f);
+ _handMesh = tessellator.generateMesh();
}
_handMesh.render();
@@ -23,7 +23,6 @@
import org.terasology.model.structures.AABB;
import org.terasology.rendering.interfaces.IGameObject;
import org.terasology.rendering.primitives.Mesh;
-import org.terasology.rendering.primitives.MeshCollection;
import org.terasology.rendering.primitives.Tessellator;
import javax.imageio.ImageIO;
@@ -52,6 +51,18 @@
public static final int ATLAS_ELEMENTS_PER_ROW_AND_COLUMN = ATLAS_SIZE_IN_PX / TEXTURE_SIZE_IN_PX;
public static final float TEXTURE_OFFSET = 0.0625f;
public static final float TEXTURE_OFFSET_WIDTH = 0.0624f;
+
+ private static final EnumMap<Side, Float> DIRECTION_LIT_LEVEL = new EnumMap<Side, Float>(Side.class);
+
+ static
+ {
+ DIRECTION_LIT_LEVEL.put(Side.TOP, 0.9f);
+ DIRECTION_LIT_LEVEL.put(Side.BOTTOM, 0.9f);
+ DIRECTION_LIT_LEVEL.put(Side.FRONT, 1.0f);
+ DIRECTION_LIT_LEVEL.put(Side.BACK, 1.0f);
+ DIRECTION_LIT_LEVEL.put(Side.LEFT, 0.75f);
+ DIRECTION_LIT_LEVEL.put(Side.RIGHT, 0.75f);
+ }
/* PROPERTIES */
protected byte _id = 0x0;
@@ -213,16 +224,23 @@ public void render() {
return;
if (_mesh == null) {
- if (getBlockForm() == BLOCK_FORM.BILLBOARD) {
- MeshCollection.addBillboardMesh(this, 1.0f, 1.0f);
- _mesh = Tessellator.getInstance().generateMesh();
- } else {
- MeshCollection.addBlockMesh(this, 1.0f, 1.0f, 0.9f);
- _mesh = Tessellator.getInstance().generateMesh();
-
+ Tessellator tessellator = new Tessellator();
+ tessellator.setColor(new Vector4f(1, 1, 1, 1));
+ if (_centerMesh != null)
+ {
+ tessellator.addMeshPart(_centerMesh);
}
-
- Tessellator.getInstance().resetAll();
+ for (Side dir : Side.values())
+ {
+ BlockMeshPart part = _sideMesh.get(dir);
+ if (part != null)
+ {
+ float lightLevel = DIRECTION_LIT_LEVEL.get(dir);
+ tessellator.setColor(new Vector4f(lightLevel, lightLevel, lightLevel, lightLevel));
+ tessellator.addMeshPart(part);
+ }
+ }
+ _mesh = tessellator.generateMesh();
}
if (getBlockForm() != BLOCK_FORM.BILLBOARD) {
@@ -96,6 +96,10 @@ public boolean renderFirstPersonView() {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.1f);
+ if (activeBlock.isTranslucent())
+ {
+ glEnable(GL11.GL_ALPHA_TEST);
+ }
glPushMatrix();
@@ -108,6 +112,10 @@ public boolean renderFirstPersonView() {
glPopMatrix();
+ if (activeBlock.isTranslucent())
+ {
+ glDisable(GL11.GL_ALPHA_TEST);
+ }
glDisable(GL11.GL_BLEND);
ShaderManager.getInstance().enableShader(null);
@@ -25,6 +25,36 @@ public BlockMeshPart(Vector3f[] vertices, Vector3f[] normals, Vector2f[] texCoor
_texCoords = Arrays.copyOf(texCoords, texCoords.length);
_indices = Arrays.copyOf(indices, indices.length);
}
+
+ public int size()
+ {
+ return _vertices.length;
+ }
+
+ public int indicesSize()
+ {
+ return _indices.length;
+ }
+
+ public Vector3f getVertex(int i)
+ {
+ return _vertices[i];
+ }
+
+ public Vector3f getNormal(int i)
+ {
+ return _normals[i];
+ }
+
+ public Vector2f getTexCoord(int i)
+ {
+ return _texCoords[i];
+ }
+
+ public int getIndex(int i)
+ {
+ return _indices[i];
+ }
public BlockMeshPart mapTexCoords(Vector2f offset, float width)
{
@@ -18,7 +18,7 @@
import org.lwjgl.opengl.Display;
import org.terasology.rendering.gui.framework.UIDisplayElement;
import org.terasology.rendering.primitives.Mesh;
-import org.terasology.rendering.primitives.MeshCollection;
+import org.terasology.rendering.primitives.TessellatorHelper;
import org.terasology.rendering.primitives.Tessellator;
import javax.vecmath.Vector2f;
@@ -36,9 +36,9 @@
public UITransparentOverlay() {
if (_mesh == null) {
- MeshCollection.addGUIQuadMesh(new Vector4f(0.05f, 0.05f, 0.05f, 0.8f), 1.0f, 1.0f);
- _mesh = Tessellator.getInstance().generateMesh();
- Tessellator.getInstance().resetAll();
+ Tessellator tessellator = new Tessellator();
+ TessellatorHelper.addGUIQuadMesh(tessellator, new Vector4f(0.05f, 0.05f, 0.05f, 0.8f), 1.0f, 1.0f);
+ _mesh = tessellator.generateMesh();
}
}
@@ -19,7 +19,7 @@
import org.lwjgl.opengl.GL11;
import org.terasology.logic.manager.TextureManager;
import org.terasology.rendering.primitives.Mesh;
-import org.terasology.rendering.primitives.MeshCollection;
+import org.terasology.rendering.primitives.TessellatorHelper;
import org.terasology.rendering.primitives.Tessellator;
import javax.vecmath.Vector2f;
@@ -44,9 +44,9 @@ public UIGraphicsElement(String textureName) {
_textureName = textureName;
if (_mesh == null) {
- MeshCollection.addGUIQuadMesh(new Vector4f(1f, 1f, 1f, 1f), 1.0f, 1.0f);
- _mesh = Tessellator.getInstance().generateMesh();
- Tessellator.getInstance().resetAll();
+ Tessellator tessellator = new Tessellator();
+ TessellatorHelper.addGUIQuadMesh(tessellator, new Vector4f(1f, 1f, 1f, 1f), 1.0f, 1.0f);
+ _mesh = tessellator.generateMesh();
}
}
Oops, something went wrong.

0 comments on commit 986cd37

Please sign in to comment.