Update/improve the renderer a bit

This commit is contained in:
Ben Spiers 2013-09-28 22:59:49 +01:00
parent a392540570
commit bf92e166b0
3 changed files with 225 additions and 57 deletions

View file

@ -0,0 +1,191 @@
# Blender v2.66 (sub 1) OBJ File: 'wireShine.blend'
# www.blender.org
mtllib wireShine.mtl
g down
v -0.126250 0.000000 0.126250
v 0.126250 0.000000 0.126250
v 0.126250 0.374464 0.126250
v -0.126250 0.374464 0.126250
v -0.126250 0.000000 -0.126250
v 0.126250 0.000000 -0.126250
v 0.126250 0.374464 -0.126250
v -0.126250 0.374464 -0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
vn 1.000000 -0.000000 0.000000
vn -1.000000 0.000000 -0.000000
vn -0.000000 -0.000000 1.000000
vn 0.000000 0.000000 -1.000000
usemtl None
s off
f 6/1/1 7/2/1 3/3/1 2/4/1
f 8/4/2 5/3/2 1/5/2 4/6/2
f 1/1/3 2/7/3 3/8/3 4/2/3
f 8/9/4 7/8/4 6/7/4 5/10/4
g up
v -0.126250 1.000000 -0.126250
v 0.126250 1.000000 -0.126250
v 0.126250 0.626964 -0.126250
v -0.126250 0.626964 -0.126250
v -0.126250 1.000000 0.126250
v 0.126250 1.000000 0.126250
v 0.126250 0.626964 0.126250
v -0.126250 0.626964 0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
usemtl None
s off
f 14/11/1 15/12/1 11/13/1 10/14/1
f 16/14/2 13/13/2 9/15/2 12/16/2
f 9/11/4 10/17/4 11/18/4 12/12/4
f 16/19/3 15/18/3 14/17/3 13/20/3
g west
v 0.500000 0.374464 -0.126250
v 0.500000 0.374464 0.126250
v 0.126250 0.374464 0.126250
v 0.126250 0.374464 -0.126250
v 0.500000 0.626964 -0.126250
v 0.500000 0.626964 0.126250
v 0.126250 0.626964 0.126250
v 0.126250 0.626964 -0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
usemtl None
s off
f 22/21/3 23/22/3 19/23/3 18/24/3
f 24/24/4 21/23/4 17/25/4 20/26/4
f 17/21/5 18/27/5 19/28/5 20/22/5
f 24/29/6 23/28/6 22/27/6 21/30/6
g east
v -0.500000 0.374460 0.126250
v -0.500000 0.374460 -0.126250
v -0.126250 0.374464 -0.126250
v -0.126250 0.374464 0.126250
v -0.500000 0.626960 0.126250
v -0.500000 0.626960 -0.126250
v -0.126250 0.626964 -0.126250
v -0.126250 0.626964 0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
vn 0.000012 -1.000000 0.000000
vn -0.000011 1.000000 -0.000000
usemtl None
s off
f 30/31/4 31/32/4 27/33/4 26/34/4
f 32/34/3 29/33/3 25/35/3 28/36/3
f 25/31/7 26/37/7 27/38/7 28/32/7
f 32/39/8 31/38/8 30/37/8 29/40/8
g north
v -0.126250 0.374464 -0.500000
v 0.126250 0.374464 -0.500000
v 0.126250 0.374464 -0.126250
v -0.126250 0.374464 -0.126250
v -0.126250 0.626964 -0.500000
v 0.126250 0.626964 -0.500000
v 0.126250 0.626964 -0.126250
v -0.126250 0.626964 -0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
usemtl None
s off
f 38/41/1 39/42/1 35/43/1 34/44/1
f 40/44/2 37/43/2 33/45/2 36/46/2
f 33/41/5 34/47/5 35/48/5 36/42/5
f 40/49/6 39/48/6 38/47/6 37/50/6
g south
v 0.126250 0.374464 0.500000
v -0.126250 0.374464 0.500000
v -0.126250 0.374464 0.126250
v 0.126250 0.374464 0.126250
v 0.126250 0.626964 0.500000
v -0.126250 0.626964 0.500000
v -0.126250 0.626964 0.126250
v 0.126250 0.626964 0.126250
vt 0.281250 0.562500
vt 0.281250 0.375000
vt 0.406250 0.375000
vt 0.406250 0.562500
vt 0.531250 0.375000
vt 0.531250 0.562500
vt 0.156250 0.562500
vt 0.156250 0.375000
vt 0.031250 0.375000
vt 0.031250 0.562500
usemtl None
s off
f 46/51/2 47/52/2 43/53/2 42/54/2
f 48/54/1 45/53/1 41/55/1 44/56/1
f 41/51/5 42/57/5 43/58/5 44/52/5
f 48/59/6 47/58/6 46/57/6 45/60/6
g center
v -0.126250 0.374464 0.126250
v -0.126250 0.374464 -0.126250
v 0.126250 0.374464 -0.126250
v 0.126250 0.374464 0.126250
v -0.126250 0.626964 0.126250
v -0.126250 0.626964 -0.126250
v 0.126250 0.626964 -0.126250
v 0.126250 0.626964 0.126250
vt 0.281250 0.843750
vt 0.156250 0.843750
vt 0.156250 0.718750
vt 0.281250 0.718750
vt 0.406250 0.843750
vt 0.406250 0.718750
vt 0.531250 0.718750
vt 0.531250 0.843750
vt 0.031250 0.843750
vt 0.031250 0.718750
vt 0.406250 0.968750
vt 0.281250 0.968750
vt 0.156250 0.968750
usemtl None_Wire
s off
f 53/61/2 54/62/2 50/63/2 49/64/2
f 54/65/4 55/66/4 51/67/4 50/68/4
f 55/62/1 56/69/1 52/70/1 51/63/1
f 56/61/3 53/64/3 49/66/3 52/65/3
f 49/71/5 50/72/5 51/61/5 52/65/5
f 56/62/6 55/61/6 54/72/6 53/73/6

View file

@ -3,9 +3,7 @@ package resonantinduction.render;
import java.nio.FloatBuffer;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
@ -24,28 +22,22 @@ import codechicken.lib.render.TextureUtils;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Translation;
import resonantinduction.ResonantInduction;
import resonantinduction.model.ModelInsulation;
import resonantinduction.model.ModelWire;
import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.multipart.PartWire;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* TODO: Use ISBRH.
*
* @author Calclavia
* @author unpairedbracket
*
*/
@SideOnly(Side.CLIENT)
public class RenderPartWire
{
private static final ResourceLocation WIRE_SHINE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "white.png");
public static final ModelWire WIRE_MODEL = new ModelWire();
public static final ModelInsulation INSULATION_MODEL = new ModelInsulation();
public static final Map<String, CCModel> models;
public static final Map<String, CCModel> shinyModels;
public static Icon wireIcon;
public static Icon insulationIcon;
public static Icon breakIcon;
@ -62,8 +54,15 @@ public class RenderPartWire
c.shrinkUVs(0.0005);
}
shinyModels = CCModel.parseObjModels(new ResourceLocation("resonantinduction", "models/wireShine.obj"), 7, new InvertX());
for (CCModel c : shinyModels.values()) {
c.apply(new Translation(.5, 0, .5));
c.computeLighting(LightModel.standardLightModel);
c.shrinkUVs(0.0005);
}
loadBuffer(location, 0,0,0,1);
loadBuffer(specular, 2,2,2,1);
loadBuffer(specular, 1,1,1,1);
loadBuffer(zero, 0,0,0,0);
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_SPECULAR, specular);
@ -82,9 +81,9 @@ public class RenderPartWire
buffer.flip();
}
public void renderShine(PartWire part, double x, double y, double z, float f)
public void renderShine(PartWire wire, double x, double y, double z, float f)
{
if (part != null)
if (wire != null)
{
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
@ -93,53 +92,22 @@ public class RenderPartWire
GL11.glDisable(GL11.GL_LIGHT0);
GL11.glDisable(GL11.GL_LIGHT1);
GL11.glEnable(GL11.GL_LIGHT3);
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_POSITION, location);
GL11.glTranslatef((float) x+0.5F, (float) y+1.5F, (float) z+0.5F);
GL11.glScalef(1.01F, -1.01F, -1.01F);
GL11.glTranslatef((float) 0.F, (float) -0.01F, (float) 0.F);
GL11.glTranslatef((float) x, (float) y, (float) z);
// Texture file
FMLClientHandler.instance().getClient().renderEngine.bindTexture(WIRE_SHINE);
CCRenderState.changeTexture(WIRE_SHINE);
part.adjacentConnections = null;
TileEntity[] adjacentConnections = part.getAdjacentConnections();
if (adjacentConnections != null)
CCRenderState.startDrawing(7);
renderSideShine(ForgeDirection.UNKNOWN, wire);
byte renderSides = wire.getAllCurrentConnections();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if (adjacentConnections[0] != null)
{
WIRE_MODEL.renderBottom();
}
if (adjacentConnections[1] != null)
{
WIRE_MODEL.renderTop();
}
if (adjacentConnections[2] != null)
{
WIRE_MODEL.renderBack();
}
if (adjacentConnections[3] != null)
{
WIRE_MODEL.renderFront();
}
if (adjacentConnections[4] != null)
{
WIRE_MODEL.renderLeft();
}
if (adjacentConnections[5] != null)
{
WIRE_MODEL.renderRight();
}
if (PartWire.connectionMapContainsSide(renderSides, side))
renderSideShine(side, wire);
}
WIRE_MODEL.renderMiddle();
CCRenderState.draw();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_LIGHT0);
@ -164,11 +132,10 @@ public class RenderPartWire
CCRenderState.useModelColours(true);
CCRenderState.setBrightness(wire.world(), wire.x(), wire.y(), wire.z());
renderSide(ForgeDirection.UNKNOWN, wire);
wire.adjacentConnections = null;
TileEntity[] adjacentTiles = wire.getAdjacentConnections();
byte renderSides = wire.getAllCurrentConnections();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if (adjacentTiles[side.ordinal()] != null)
if (PartWire.connectionMapContainsSide(renderSides, side))
renderSide(side, wire);
}
}
@ -188,11 +155,21 @@ public class RenderPartWire
}
}
public void renderSideShine(ForgeDirection side, PartWire wire)
{
String name = side.name().toLowerCase();
name = name.equals("unknown") ? "center" : name;
Vector3 materialColour = wire.getMaterial().color;
renderPartShine(shinyModels.get(name));
}
public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour colour) {
cc.render(0, cc.verts.length,
Rotation.sideOrientation(0, Rotation.rotationTo(0, 2)).at(codechicken.lib.vec.Vector3.center)
.with(new Translation(x, y, z)), new IconTransformation(icon), new ColourMultiplier(colour));
}
public void renderPartShine(CCModel cc) {
cc.render(null, 0, 0);
}
}