make this 2.5d and gameify it, add animations. #define PROCESSINGCOLORSHADER uniform…
- User
make this 2.5d and gameify it, add animations.
#define PROCESSING_COLOR_SHADER
uniform mat4 transform; uniform mat4 texMatrix;
attribute vec4 vertex; attribute vec4 color; attribute vec2 texCoord;
varying vec4 vertColor; varying vec2 vertTexCoord; varying float vAge;
void main() { gl_Position = transform * vertex;
vertColor = color; vertTexCoord = (texMatrix * vec4(texCoord, 1.0, 1.0)).xy; vAge = color.a; }
#ifdef GL_ES precision mediump float; precision mediump int; #endif
uniform float cellAge;
varying vec4 vertColor; varying vec2 vertTexCoord; varying float vAge;
void main() { vec3 youngColor = vec3(1.0, 0.0, 0.0); // Red for young cells vec3 oldColor = vec3(0.0, 0.0, 1.0); // Blue for old cells
vec3 cellColor = mix(youngColor, oldColor, cellAge);
gl_FragColor = vec4(cellColor, 1.0); }
import java.util.concurrent.; import controlP5.;
final int MAX_SIZE = 128; int currentSize = 96; boolean[][][] grid = new boolean[MAX_SIZE][MAX_SIZE][MAX_SIZE]; boolean[][][] nextGrid = new boolean[MAX_SIZE][MAX_SIZE][MAX_SIZE]; int[][][] cellAge = new int[MAX_SIZE][MAX_SIZE][MAX_SIZE];
float rotX, rotY; float zoom = 1.0; // Zoom level int cellSize = 3; boolean paused = false; int framesPerGeneration = 5; int frameCounter = 0;
PShader cellShader; ThreadPoolExecutor executor;
// Rule set int minSurvive = 4; int maxSurvive = 5; int birthCount = 5;
PShape cellShape; ControlP5 cp5; // ControlP5 instance
void setup() { size(1200, 800, P3D); // Increased canvas size
// Initialize ControlP5 cp5 = new ControlP5(this); setupControls();
randomizeGrid();
// Initialize thread pool int processors = Runtime.getRuntime().availableProcessors(); executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(processors);
// Load shader cellShader = loadShader("cellFrag.glsl", "cellVert.glsl");
// Initialize cell age for (int x = 0; x < MAX_SIZE; x++) { for (int y = 0; y < MAX_SIZE; y++) { for (int z = 0; z < MAX_SIZE; z++) { cellAge[x][y][z] = 0; } } }
// Create cell shape for instanced rendering cellShape = createShape(BOX, cellSize); cellShape.setStroke(false); }
void draw() { background(30);
// 3D transformations and rendering pushMatrix(); // Start of 3D scene lights(); translate(width / 2, height / 2, 0); scale(zoom); // Apply zoom translate(0, 0, -currentSize * cellSize / 2); // Adjust Z position based on zoom rotateX(rotX); rotateY(rotY); translate(-currentSize * cellSize / 2, -currentSize * cellSize / 2, -currentSize * cellSize / 2);
// Update grid if (!paused && frameCounter % framesPerGeneration == 0) { updateGrid(); } frameCounter++;
- Assistant