![JAR search and dependency download from the Maven repository](/logo.png)
ext.plantuml.com.ctreber.acearth.shader.ShaderOrtho Maven / Gradle / Ivy
package ext.plantuml.com.ctreber.acearth.shader;
import java.awt.Color;
/**
* Shader for the orthographic projection.
*
* © 2002 Christian Treber, [email protected] (Nov 11, 2002)
* @author Christian Treber, [email protected]
*
*/
public class ShaderOrtho extends Shader
{
private static double[] fXValues;
public Color[] getShadedColors(int pRowNo, int[] pRowTypes)
{
if(pRowNo == 0)
{
fXValues = computeXValues(pRowTypes.length);
}
final double y = fProjection.inverseProjectY(fProjection.inverseFinalizeY(pRowNo));
final double tmp = 1 - (y * y);
final double lYBySunVectorY = y * fLightVector.getY();
final Color[] lColors = new Color[pRowTypes.length];
for(int lColNo = 0; lColNo < pRowTypes.length; lColNo++)
{
double x = fXValues[lColNo];
double z = Math.sqrt(tmp - (x * x));
double lSunValue = (x * fLightVector.getX()) + lYBySunVectorY + (z * fLightVector.getZ());
lColors[lColNo] = getShadedColorForType(pRowTypes[lColNo], lSunValue);
}
return lColors;
}
/**
*
* @return X value for each column in image.
*/
private double[] computeXValues(int pWidth)
{
final double[] lTable = new double[pWidth];
for(int lColNo = 0; lColNo < pWidth; lColNo++)
{
lTable[lColNo] = fProjection.inverseProjectX(fProjection.inverseFinalizeX(lColNo));
}
return lTable;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy