mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-16 01:54:50 +00:00
Initial Commit
This commit is contained in:
1 parent
397135f687
commit
0f32dd8620
82 files changed
+10693
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package codechicken.lib.lighting;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import codechicken.lib.colour.Colour;
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
import codechicken.lib.render.CCModel;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.IVertexModifier;
|
||||
import codechicken.lib.render.UV;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
|
||||
/**
|
||||
* Faster precomputed version of LightModel that only works for axis planar sides
|
||||
*/
|
||||
public class PlanarLightModel implements IVertexModifier
|
||||
{
|
||||
public ColourRGBA[] colours;
|
||||
|
||||
public PlanarLightModel(int[] colours)
|
||||
{
|
||||
this.colours = new ColourRGBA[6];
|
||||
for(int i = 0; i < 6; i++)
|
||||
this.colours[i] = new ColourRGBA(colours[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyModifiers(CCModel m, Tessellator tess, Vector3 vec, UV uv, Vector3 normal, int i)
|
||||
{
|
||||
ColourRGBA light = colours[CCModel.findSide(normal)];
|
||||
int colour = (m == null || m.colours == null) ? -1 : m.colours[i];
|
||||
Colour res = new ColourRGBA(colour).multiply(light);
|
||||
CCRenderState.vertexColour(res.r&0xFF, res.g&0xFF, res.b&0xFF, res.a&0xFF) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsNormals()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user