Fixed wire render colors

This commit is contained in:
Calclavia 2014-09-21 15:52:54 +08:00
parent 99ecd7e40e
commit f335723d1d
3 changed files with 10 additions and 7 deletions

View file

@ -21,4 +21,8 @@ object ResonantUtil
* Gets the color hex code from the color's ID
*/
def getColorHex(id: Int): Int = dyeColors(id)
def convertRGBtoRGBA(color: Int): Int = color << 8 | (255 & 0xFF)
}

View file

@ -89,10 +89,11 @@ object RenderFlatWire
def render(wire: PartFlatWire, pos: Vector3)
{
val colorCode = ResonantUtil.getColorHex(wire.getColor)
val operation = if (colorCode == -1) ColourMultiplier.instance(0xFFFFFF) else new ColourMultiplier(colorCode)
//If it is insulated, render the insulation color. Otherwise, render the material color.
val colorCode = if(wire.insulated) ResonantUtil.convertRGBtoRGBA(ResonantUtil.getColorHex(wire.getColor)) else ResonantUtil.convertRGBtoRGBA(wire.material.color)
val model = getOrGenerateModel(modelKey(wire))
model.render(new Translation(pos), new IconTransformation(wire.getIcon), operation)
model.render(new Translation(pos), new IconTransformation(wire.getIcon), new ColourMultiplier(colorCode))
}
def renderInv(thickness: Int, t: Transformation, icon: IIcon)

View file

@ -51,10 +51,10 @@ object RenderFramedWire
var name: String = side.name.toLowerCase
name = if (name == "unknown") "center" else name
renderPart(wireIcon, models(name), wire.x, wire.y, wire.z, RGBColorToRGBA(wire.material.color))
renderPart(wireIcon, models(name), wire.x, wire.y, wire.z, ResonantUtil.convertRGBtoRGBA(wire.material.color))
if (wire.insulated)
renderPart(insulationIcon, models(name + "Insulation"), wire.x, wire.y, wire.z, RGBColorToRGBA(ResonantUtil.getColorHex(wire.getColor)))
renderPart(insulationIcon, models(name + "Insulation"), wire.x, wire.y, wire.z, ResonantUtil.convertRGBtoRGBA(ResonantUtil.getColorHex(wire.getColor)))
}
def renderPart(icon: IIcon, cc: CCModel, x: Double, y: Double, z: Double, color: Int)
@ -62,6 +62,4 @@ object RenderFramedWire
val transform = Rotation.sideOrientation(0, Rotation.rotationTo(0, 2)).at(codechicken.lib.vec.Vector3.center).`with`(new Translation(x, y, z))
cc.render(0, cc.verts.length, transform, new IconTransformation(icon), new ColourMultiplier(color))
}
def RGBColorToRGBA(color: Int): Int = color << 8 | (255 & 0xFF)
}