mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-15 09:34:53 +00:00
Initial 1.7 commit
This commit is contained in:
1 parent
34154fc011
commit
ca675b5f31
72 files changed
+2967
-3335
No files matched your search
@@ -1,72 +1,54 @@
|
||||
package codechicken.lib.vec;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Interface for any 3D vector transformation
|
||||
* Abstract supertype for any 3D vector transformation
|
||||
*/
|
||||
public abstract class Transformation
|
||||
{
|
||||
/**
|
||||
* Applies this transformation to a position vector
|
||||
* @param vec The vector to transform
|
||||
*/
|
||||
public abstract void apply(Vector3 vec);
|
||||
|
||||
public abstract class Transformation extends ITransformation<Vector3, Transformation> implements CCRenderState.IVertexOperation
|
||||
{
|
||||
public static final int operationIndex = CCRenderState.registerOperation();
|
||||
|
||||
/**
|
||||
* Applies this transformation to a normal (doesn't translate)
|
||||
* @param normal The normal to transform
|
||||
*/
|
||||
public abstract void applyN(Vector3 normal);
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* @param point The point in OBJECT space to apply this transformation around
|
||||
* @return Wraps this transformation in a translation to point and then back from point
|
||||
*/
|
||||
public Transformation at(Vector3 point)
|
||||
{
|
||||
|
||||
public Transformation at(Vector3 point) {
|
||||
return new TransformationList(new Translation(-point.x, -point.y, -point.z), this, point.translation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a transformation list composed of this transformation followed by t
|
||||
* If this is a TransformationList, the transformation will be appended and this returned
|
||||
*/
|
||||
public TransformationList with(Transformation t)
|
||||
{
|
||||
|
||||
public TransformationList with(Transformation t) {
|
||||
return new TransformationList(this, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simplified transformation that performs this, followed by next. If such a transformation does not exist, returns null
|
||||
*/
|
||||
public Transformation merge(Transformation next)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this transformation is redundant, eg. Scale(1, 1, 1), Translation(0, 0, 0) or Rotation(0, a, b, c)
|
||||
*/
|
||||
public boolean isRedundant()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void glApply();
|
||||
|
||||
public abstract Transformation inverse();
|
||||
|
||||
public TransformationList $plus$plus(Transformation t)
|
||||
{
|
||||
return with(t);
|
||||
@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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user