Files
CodeChickenCore/codechicken/lib/vec/Transformation.java
T

54 lines
1.6 KiB
Java
Raw Normal View History

2013-07-16 17:58:02 +10:00
package codechicken.lib.vec;
2014-04-07 14:02:47 +10:00
import codechicken.lib.render.CCRenderState;
2013-07-16 17:58:02 +10:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
2014-04-07 14:02:47 +10:00
* Abstract supertype for any 3D vector transformation
2013-07-16 17:58:02 +10:00
*/
2014-04-07 14:02:47 +10:00
public abstract class Transformation extends ITransformation<Vector3, Transformation> implements CCRenderState.IVertexOperation
{
public static final int operationIndex = CCRenderState.registerOperation();
2013-07-16 17:58:02 +10:00
/**
* Applies this transformation to a normal (doesn't translate)
* @param normal The normal to transform
*/
public abstract void applyN(Vector3 normal);
2014-04-07 14:02:47 +10:00
2013-07-16 17:58:02 +10:00
/**
* Applies this transformation to a matrix as a multiplication on the right hand side.
* @param mat The matrix to combine this transformation with
*/
public abstract void apply(Matrix4 mat);
2014-04-07 14:02:47 +10:00
public Transformation at(Vector3 point) {
2013-08-29 11:10:33 +10:00
return new TransformationList(new Translation(-point.x, -point.y, -point.z), this, point.translation());
2013-07-16 17:58:02 +10:00
}
2014-04-07 14:02:47 +10:00
public TransformationList with(Transformation t) {
2013-07-16 17:58:02 +10:00
return new TransformationList(this, t);
}
2014-04-07 14:02:47 +10:00
2013-07-16 17:58:02 +10:00
@SideOnly(Side.CLIENT)
public abstract void glApply();
2014-04-07 14:02:47 +10:00
@Override
public boolean load() {
CCRenderState.pipeline.addRequirement(CCRenderState.normalAttrib.operationID());
return !isRedundant();
}
@Override
public void operate() {
apply(CCRenderState.vert.vec);
if(CCRenderState.normalAttrib.active)
applyN(CCRenderState.normal);
}
@Override
public int operationID() {
return operationIndex;
}
2013-07-16 17:58:02 +10:00
}