use of com.infinityraider.agricraft.api.v1.genetics.IAgriGene in project AgriCraft by AgriCraft.
the class AgriGenomeRenderer method drawHelix.
protected void drawHelix(List<IAgriGenePair<?>> genePairs, int active, float radius, float phase, float dHeight, float dAngle, int points, IRenderTypeBuffer buffer, Matrix4f matrix, boolean dominant, float alpha, boolean color) {
float x_1 = radius * MathHelper.cos(-phase);
float y_1 = dHeight * points;
float z_1 = radius * MathHelper.sin(-phase);
for (int i = 0; i < points; i++) {
// Determine color and width
int index = i / POINTS_PER_GENE;
int partial = i % POINTS_PER_GENE;
IAgriGene<?> gene = genePairs.get(index).getGene();
Vector3f colorVec = this.getColor(gene, index == active, dominant, color);
float r = colorVec.getX();
float g = colorVec.getY();
float b = colorVec.getZ();
float w = this.getLineWidth(index == active);
if (partial < POINTS_PER_GENE / 2) {
int prevIndex = (index - 1) < 0 ? index : index - 1;
IAgriGene<?> prevGene = genePairs.get(prevIndex).getGene();
Vector3f prevColor = this.getColor(prevGene, prevIndex == active, dominant, color);
float prevWidth = this.getLineWidth(prevIndex == active);
float f = (partial + ((POINTS_PER_GENE + 0.0F) / 2)) / POINTS_PER_GENE;
r = MathHelper.lerp(f, prevColor.getX(), r);
g = MathHelper.lerp(f, prevColor.getY(), g);
b = MathHelper.lerp(f, prevColor.getZ(), b);
w = MathHelper.lerp(f, prevWidth, w);
} else if (partial > POINTS_PER_GENE / 2) {
int nextIndex = (index + 1) >= genePairs.size() ? index : index + 1;
IAgriGene<?> nextGene = genePairs.get(nextIndex).getGene();
Vector3f nextColor = this.getColor(nextGene, nextIndex == active, dominant, color);
float nextWidth = this.getLineWidth(nextIndex == active);
float f = (partial - ((POINTS_PER_GENE + 0.0F) / 2)) / POINTS_PER_GENE;
r = MathHelper.lerp(f, r, nextColor.getX());
g = MathHelper.lerp(f, g, nextColor.getY());
b = MathHelper.lerp(f, b, nextColor.getZ());
w = MathHelper.lerp(f, w, nextWidth);
}
// Determine coordinates
float x_2 = radius * MathHelper.cos(-((1 + i) * dAngle + phase));
float y_2 = dHeight * (points - i);
float z_2 = radius * MathHelper.sin(-((1 + i) * dAngle + phase));
// Add vertices for line segment
this.addVertex(buffer, matrix, x_1, y_1, z_1, r, g, b, alpha, w);
this.addVertex(buffer, matrix, x_2, y_2, z_2, r, g, b, alpha, w);
// Update previous coordinates
x_1 = x_2;
y_1 = y_2;
z_1 = z_2;
}
}