/** * ============================================================================ * Modul: DTIM-ZEC Isometric 3D Voxel Studio & Text-Animation Engine * Datei: DTIM_ZEC_DOOM_RAYCASTER.pde * Framework: DTIM-ZEC MODULAR PHYSICS FRAMEWORK (DAMTP ACADEMIC STANDARD) * Copyright: (c) 2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI) * Lizenz: MIT License * Plattform: Processing 4.5.6 (Linux x64) & Processing.js (processing.min.js) * Steuerung: [Linksklick] Voxel malen | [Rechtsklick / Alt+Klick] Farbe aufnehmen (Pipette) * [Q / E] Isometrische 3D-Ansicht um 90° drehen | [W / S] Schicht (Level Z) wechseln * [Leertaste] Play/Pause | [H] Sehhilfe (Standard / Farbenblind / Max-Kontrast) * ============================================================================ */ // ============================================================================ // MODUL 1: SYSTEMKONSTANTEN & ZUSTANDSSPEICHER (PROCESSING.JS-SICHER) // ============================================================================ final int MAX_FRAMES = 16; final int MAX_GRID_SIZE = 20; final int EMPTY_VOXEL = 0; final String ANIM_FILENAME = "dtim_zec_3d_animation.txt"; VoxelAnimationProject project; IsoRendererEngine isoEngine; StudioControlUI studioUI; // Aktuelle Zeichenfarbe & Slider-Zustand int rc = 179; int gc = 25; int bc = 56; int sc = 86; // 4-Stufen Klick-Historie pro Kanal (aus VEXO Core Engine übernommen) int[] trailR = { 179, -1, -1, -1 }; int[] trailG = { 25, -1, -1, -1 }; int[] trailB = { 56, -1, -1, -1 }; int[] trailBW = { 86, -1, -1, -1 }; // 8-Slot Farb-Palette final int MAX_PALETTE = 8; color[] paletteHistory = new color[MAX_PALETTE]; int paletteCount = 0; // Werkzeug- & Ansichts-Modi int toolMode = 0; // 0 = Pinsel, 1 = Radierer, 2 = Pipette int isoRotation = 0; // 0..3 (0°, 90°, 180°, 270° Drehung der 3D-Bühne) int a11yMode = 0; // 0 = Standard (Schwarz/Blutrot/Nachtblau), 1 = Farbenblind, 2 = Max-Kontrast boolean show3DView = true; boolean showGrid = true; boolean showGhost = true; // Zeigt Schicht Z-1 transparent als Bauhilfe boolean showTextBox = false; // Zeigt den menschenlesbaren Klartext-Code direkt im Fenster boolean isPlaying = false; int playTickCounter = 0; int playStepFrames = 14; // Geschwindigkeit der Animation String statusBanner = "Bereit · Klartext-Format: dtim_zec_3d_animation.txt"; int statusFlash = 0; String[] exportedScriptLines = new String[0]; void setup() { // Feste Ganzzahlen ohne P2D/P3D für 100% Kompatibilität mit processing.min.js size(1160, 740); noSmooth(); frameRate(60); initDefaultPalette(); project = new VoxelAnimationProject(MAX_FRAMES, MAX_GRID_SIZE); isoEngine = new IsoRendererEngine(); studioUI = new StudioControlUI(); // Falls bereits eine externe Animationsdatei existiert, laden; sonst 2-Frame-Startszene erzeugen if (!project.loadFromTextFile(ANIM_FILENAME)) { project.seedStarterAnimation(); } exportedScriptLines = project.serializeToText(); } void initDefaultPalette() { paletteHistory[0] = color(179, 25, 56); // DTIM Blutrot paletteHistory[1] = color(36, 84, 175); // Nachtblau paletteHistory[2] = color(230, 235, 245); // Silbergrau paletteHistory[3] = color(245, 185, 45); // Gold-Resonanz paletteHistory[4] = color(30, 175, 130); // Quanten-Smaragd paletteHistory[5] = color(145, 70, 210); // Spektral-Violett paletteHistory[6] = color(85, 98, 122); // Schiefer paletteHistory[7] = color(20, 24, 34); // Tiefschwarz paletteCount = 8; } void draw() { // Animations-Playback if (isPlaying) { playTickCounter++; if (playTickCounter >= playStepFrames) { playTickCounter = 0; project.activeFrame++; if (project.activeFrame >= project.usedFrames) { project.activeFrame = 0; } } } // Hintergrund je nach Barrierefreiheits-Modus if (a11yMode == 2) background(0); else background(6, 8, 13); // 1. Obere Werkzeugleiste studioUI.drawTopToolbar(); // 2. Linker Bereich: 2D-Schicht-Editor (Ebene Z) studioUI.draw2DLayerEditor(project); // 3. Rechter Bereich: Isometrische 3D-Ansicht oder Klartext-Script-Inspektor if (showTextBox) { studioUI.drawScriptInspector(exportedScriptLines); } else if (show3DView) { isoEngine.drawIsometricScene(project, isoRotation, showGrid, a11yMode); } else { studioUI.drawDisabled3DPlaceholder(); } // 4. Untere Farb- & Slider-Steuerung studioUI.drawBottomColorDeck(); // 5. Kontinuierliches Zeichnen im 2D-Raster bei gedrückter Maustaste if (mousePressed && !showTextBox) { handleGridPainting(); } } void handleGridPainting() { int gridLeft = 16; int gridTop = 46; int gridSizePx = 520; if (mouseX >= gridLeft && mouseX < gridLeft + gridSizePx && mouseY >= gridTop && mouseY < gridTop + gridSizePx) { float cellPx = float(gridSizePx) / float(project.gridSize); int gx = constrain(floor((mouseX - gridLeft) / cellPx), 0, project.gridSize - 1); int gy = constrain(floor((mouseY - gridTop) / cellPx), 0, project.gridSize - 1); boolean isPickAction = (mouseButton == RIGHT) || (toolMode == 2) || (keyPressed && keyCode == ALT); boolean isEraseAction = (toolMode == 1); if (isPickAction) { int existing = project.getVoxel(project.activeFrame, gx, gy, project.activeLayer); if (existing != EMPTY_VOXEL) { setCurrentColor((existing >> 16) & 0xFF, (existing >> 8) & 0xFF, existing & 0xFF); setStatus("Farbe aus Voxel (" + gx + "," + gy + "," + project.activeLayer + ") übernommen"); } } else if (isEraseAction) { project.setVoxel(project.activeFrame, gx, gy, project.activeLayer, EMPTY_VOXEL); } else if (mouseButton == LEFT) { int packed = packRGB(rc, gc, bc); project.setVoxel(project.activeFrame, gx, gy, project.activeLayer, packed); addColorToPalette(color(rc, gc, bc)); } } } void mousePressed() { // 1. Klicks in der oberen Werkzeugleiste (y: 0..36) if (mouseY >= 0 && mouseY <= 36) { studioUI.handleTopBarClick(mouseX, mouseY, mouseButton); return; } // 2. Klicks im unteren Farb- & Slider-Deck (y: 580..740) if (mouseY >= 580) { studioUI.handleColorDeckClick(mouseX, mouseY, mouseButton); return; } // 3. Klick im 2D-Zeichenraster if (!showTextBox) { handleGridPainting(); } } void keyPressed() { if (key == 'q' || key == 'Q') { isoRotation = (isoRotation + 3) % 4; setStatus("3D-Ansicht gedreht: " + (isoRotation * 90) + "°"); } if (key == 'e' || key == 'E') { isoRotation = (isoRotation + 1) % 4; setStatus("3D-Ansicht gedreht: " + (isoRotation * 90) + "°"); } if (key == 'w' || key == 'W') { project.activeLayer = min(project.gridSize - 1, project.activeLayer + 1); } if (key == 's' || key == 'S') { project.activeLayer = max(0, project.activeLayer - 1); } if (key == 'a' || key == 'A') { project.activeFrame = max(0, project.activeFrame - 1); } if (key == 'd' || key == 'D') { project.activeFrame = min(project.usedFrames - 1, project.activeFrame + 1); } if (key == ' ') { isPlaying = !isPlaying; setStatus(isPlaying ? "Animation läuft (" + project.usedFrames + " Frames)" : "Animation pausiert"); } if (key == 'h' || key == 'H') { a11yMode = (a11yMode + 1) % 3; String mName = (a11yMode == 0) ? "Standard" : ((a11yMode == 1) ? "Farbenblind (Blau/Gold)" : "Max-Kontrast"); setStatus("Sehhilfe-Modus: " + mName); } if (key == 't' || key == 'T') { exportedScriptLines = project.serializeToText(); showTextBox = !showTextBox; } } // ============================================================================ // HILFSFUNKTIONEN FÜR FARBEN & STATUS // ============================================================================ int packRGB(int r, int g, int b) { // Bit 24 gesetzt markiert aktiven Voxel (auch reines Schwarz 0,0,0 bleibt dadurch sichtbar!) return (1 << 24) | ((constrain(r, 0, 255) & 0xFF) << 16) | ((constrain(g, 0, 255) & 0xFF) << 8) | (constrain(b, 0, 255) & 0xFF); } void setCurrentColor(int r, int g, int b) { rc = constrain(r, 0, 255); gc = constrain(g, 0, 255); bc = constrain(b, 0, 255); sc = (rc + gc + bc) / 3; pushTrail(trailR, rc); pushTrail(trailG, gc); pushTrail(trailB, bc); pushTrail(trailBW, sc); } void pushTrail(int[] arr, int val) { val = constrain(val, 0, 255); if (arr[0] != val) { arr[3] = arr[2]; arr[2] = arr[1]; arr[1] = arr[0]; arr[0] = val; } } void addColorToPalette(color c) { for (int i = 0; i < paletteCount; i++) { if (paletteHistory[i] == c) { for (int j = i; j > 0; j--) { paletteHistory[j] = paletteHistory[j - 1]; } paletteHistory[0] = c; return; } } for (int i = MAX_PALETTE - 1; i > 0; i--) { paletteHistory[i] = paletteHistory[i - 1]; } paletteHistory[0] = c; if (paletteCount < MAX_PALETTE) paletteCount++; } void setStatus(String msg) { statusBanner = msg; statusFlash = 45; } // ============================================================================ // MODUL 2: VOXEL-PROJEKT & MENSCHENLESBARER KLARTEXT-SERIALIZER // ============================================================================ class VoxelAnimationProject { int maxFrames; int maxSize; int gridSize; int usedFrames; int activeFrame; int activeLayer; int[][][][] voxels; // [frame][x][y][z] VoxelAnimationProject(int mFrames, int mSize) { maxFrames = mFrames; maxSize = mSize; gridSize = 14; usedFrames = 2; activeFrame = 0; activeLayer = 0; voxels = new int[maxFrames][maxSize][maxSize][maxSize]; clearAll(); } void clearAll() { for (int f = 0; f < maxFrames; f++) { clearFrame(f); } } void clearFrame(int f) { if (f < 0 || f >= maxFrames) return; for (int x = 0; x < maxSize; x++) { for (int y = 0; y < maxSize; y++) { for (int z = 0; z < maxSize; z++) { voxels[f][x][y][z] = EMPTY_VOXEL; } } } } void clearLayer(int f, int z) { if (f < 0 || f >= maxFrames || z < 0 || z >= maxSize) return; for (int x = 0; x < maxSize; x++) { for (int y = 0; y < maxSize; y++) { voxels[f][x][y][z] = EMPTY_VOXEL; } } } int getVoxel(int f, int x, int y, int z) { if (f < 0 || f >= maxFrames || x < 0 || x >= gridSize || y < 0 || y >= gridSize || z < 0 || z >= gridSize) { return EMPTY_VOXEL; } return voxels[f][x][y][z]; } void setVoxel(int f, int x, int y, int z, int packedCol) { if (f < 0 || f >= maxFrames || x < 0 || x >= gridSize || y < 0 || y >= gridSize || z < 0 || z >= gridSize) { return; } voxels[f][x][y][z] = packedCol; } void fillBox(int f, int x1, int y1, int z1, int x2, int y2, int z2, int packedCol) { int minX = max(0, min(x1, x2)); int maxX = min(gridSize - 1, max(x1, x2)); int minY = max(0, min(y1, y2)); int maxY = min(gridSize - 1, max(y1, y2)); int minZ = max(0, min(z1, z2)); int maxZ = min(gridSize - 1, max(z1, z2)); for (int z = minZ; z <= maxZ; z++) { for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { voxels[f][x][y][z] = packedCol; } } } } void cloneCurrentFrameToNext() { if (usedFrames >= maxFrames) { setStatus("Maximale Frame-Anzahl (" + maxFrames + ") erreicht"); return; } int src = activeFrame; int dst = usedFrames; for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { for (int z = 0; z < gridSize; z++) { voxels[dst][x][y][z] = voxels[src][x][y][z]; } } } usedFrames++; activeFrame = dst; setStatus("Frame " + (src + 1) + " nach Frame " + (dst + 1) + " dupliziert"); } // Start-Animation (2 Frames) als direktes Beispiel des Klartext-Formats void seedStarterAnimation() { clearAll(); gridSize = 14; usedFrames = 2; String[] defaultScript = { "# DTIM-ZEC 3D ISOMETRIC ANIMATION (MIT License)", "GRID 14", "FPS 5", "FRAME 1", "BOX 3 3 0 10 10 0 28 61 117", "BOX 5 5 1 8 8 1 125 22 46", "VOXEL 6 6 2 179 25 56", "VOXEL 7 7 2 179 25 56", "VOXEL 6 7 3 235 240 250", "FRAME 2", "BOX 3 3 0 10 10 0 28 61 117", "BOX 5 5 1 8 8 1 179 25 56", "VOXEL 6 7 2 179 25 56", "VOXEL 7 6 2 179 25 56", "VOXEL 6 6 3 255 215 70", "VOXEL 7 7 4 235 240 250" }; parseTextLines(defaultScript); activeFrame = 0; activeLayer = 0; } // Exportiert die komplette 3D-Animation in ein ultra-klares, editierbares Textformat String[] serializeToText() { ArrayList lines = new ArrayList(); lines.add("# ============================================================================"); lines.add("# DTIM-ZEC 3D ISOMETRIC VOXEL ANIMATION (MIT License)"); lines.add("# Jeder einfache Texteditor kann diese Datei direkt bearbeiten:"); lines.add("# GRID -> Rastergroesse (z.B. 14)"); lines.add("# FPS -> Abspielgeschwindigkeit"); lines.add("# FRAME <1..16> -> Startet einen neuen Animations-Frame"); lines.add("# VOXEL -> Setzt einen 3D-Wuerfel"); lines.add("# BOX -> Fuellt einen 3D-Quader"); lines.add("# ============================================================================"); lines.add("GRID " + gridSize); lines.add("FPS " + max(1, round(60.0 / float(playStepFrames)))); for (int f = 0; f < usedFrames; f++) { lines.add(""); lines.add("FRAME " + (f + 1)); for (int z = 0; z < gridSize; z++) { for (int y = 0; y < gridSize; y++) { for (int x = 0; x < gridSize; x++) { int val = voxels[f][x][y][z]; if (val != EMPTY_VOXEL) { int r = (val >> 16) & 0xFF; int g = (val >> 8) & 0xFF; int b = val & 0xFF; lines.add("VOXEL " + x + " " + y + " " + z + " " + r + " " + g + " " + b); } } } } } String[] result = new String[lines.size()]; for (int i = 0; i < lines.size(); i++) { result[i] = lines.get(i); } return result; } // Parst eine vom Menschen oder Programm geschriebene Klartext-Datei void parseTextLines(String[] rawLines) { clearAll(); int currentF = 0; int highestF = 0; for (int i = 0; i < rawLines.length; i++) { String line = trim(rawLines[i]); if (line.length() == 0 || line.startsWith("#") || line.startsWith("//")) { continue; } String[] tok = splitTokens(line, " \t,;"); if (tok == null || tok.length < 2) continue; String cmd = tok[0].toUpperCase(); if (cmd.equals("GRID")) { gridSize = constrain(int(tok[1]), 4, maxSize); } else if (cmd.equals("FPS")) { int fpsVal = constrain(int(tok[1]), 1, 30); playStepFrames = max(2, round(60.0 / float(fpsVal))); } else if (cmd.equals("FRAME")) { currentF = constrain(int(tok[1]) - 1, 0, maxFrames - 1); highestF = max(highestF, currentF); } else if (cmd.equals("VOXEL") && tok.length >= 7) { int vx = int(tok[1]); int vy = int(tok[2]); int vz = int(tok[3]); int vr = int(tok[4]); int vg = int(tok[5]); int vb = int(tok[6]); setVoxel(currentF, vx, vy, vz, packRGB(vr, vg, vb)); } else if (cmd.equals("BOX") && tok.length >= 10) { fillBox( currentF, int(tok[1]), int(tok[2]), int(tok[3]), int(tok[4]), int(tok[5]), int(tok[6]), packRGB(int(tok[7]), int(tok[8]), int(tok[9])) ); } } usedFrames = max(1, highestF + 1); activeFrame = 0; activeLayer = constrain(activeLayer, 0, gridSize - 1); } boolean saveToTextFile(String filename) { String[] lines = serializeToText(); exportedScriptLines = lines; try { saveStrings(filename, lines); return true; } catch (Exception e) { return false; } } boolean loadFromTextFile(String filename) { try { String[] loaded = loadStrings(filename); if (loaded != null && loaded.length > 0) { parseTextLines(loaded); exportedScriptLines = loaded; return true; } } catch (Exception e) { // Fallback auf Startszene, falls keine Datei vorhanden } return false; } } // ============================================================================ // MODUL 3: ISOMETRISCHE SOLID-3D-ENGINE MIT SCHATTIERUNG & 4-WEGE-ROTATION // ============================================================================ class IsoRendererEngine { void drawIsometricScene(VoxelAnimationProject proj, int rot, boolean drawFloorGrid, int a11y) { int panelX = 552; int panelY = 46; int panelW = 592; int panelH = 520; // 3D-Bühnenrahmen stroke(a11y == 2 ? color(255) : color(59, 110, 194)); fill(a11y == 2 ? color(0) : color(11, 14, 22)); rect(panelX, panelY, panelW, panelH, 6); // Kopfbalken der 3D-Ansicht noStroke(); fill(a11y == 2 ? color(0) : (a11y == 1 ? color(8, 47, 73) : color(13, 33, 71))); rect(panelX + 1, panelY + 1, panelW - 2, 28, 5); fill(255); textSize(13); textAlign(LEFT, CENTER); text("3D ISOMETRIE (Solide Würfel) · Frame " + (proj.activeFrame + 1) + "/" + proj.usedFrames + " · Winkel: " + (rot * 90) + "° [Q/E]", panelX + 12, panelY + 15); int N = proj.gridSize; float tileHalfW = min(15.0, 235.0 / float(N)); float tileHalfH = tileHalfW * 0.5; float cubeH = tileHalfW * 1.05; float originX = panelX + panelW * 0.5; float originY = panelY + 165 + (N * 2.5); // Boden-Hilfsgitter (Ebene Z = 0) if (drawFloorGrid) { stroke(a11y == 2 ? color(110) : color(48, 64, 96)); strokeWeight(1); for (int i = 0; i <= N; i++) { float ax1 = originX + (0 - i) * tileHalfW; float ay1 = originY + (0 + i) * tileHalfH; float ax2 = originX + (N - i) * tileHalfW; float ay2 = originY + (N + i) * tileHalfH; line(ax1, ay1, ax2, ay2); float bx1 = originX + (i - 0) * tileHalfW; float by1 = originY + (i + 0) * tileHalfH; float bx2 = originX + (i - N) * tileHalfW; float by2 = originY + (i + N) * tileHalfH; line(bx1, by1, bx2, by2); } // Aktive Arbeitsebene Z als feiner Referenzrahmen hervorheben float lzOffset = proj.activeLayer * cubeH; stroke(a11y == 2 ? color(255, 255, 0) : (a11y == 1 ? color(251, 191, 36) : color(179, 25, 56))); noFill(); beginShape(); vertex(originX, originY - lzOffset); vertex(originX + N * tileHalfW, originY + N * tileHalfH - lzOffset); vertex(originX, originY + 2 * N * tileHalfH - lzOffset); vertex(originX - N * tileHalfW, originY + N * tileHalfH - lzOffset); endShape(CLOSE); } // Painter's Algorithmus (von unten nach oben, hinten nach vorne) mit 90°-Rotation for (int z = 0; z < N; z++) { for (int py = 0; py < N; py++) { for (int px = 0; px < N; px++) { int vx = px; int vy = py; if (rot == 1) { vx = py; vy = N - 1 - px; } else if (rot == 2) { vx = N - 1 - px; vy = N - 1 - py; } else if (rot == 3) { vx = N - 1 - py; vy = px; } int packed = proj.getVoxel(proj.activeFrame, vx, vy, z); if (packed != EMPTY_VOXEL) { int cr = (packed >> 16) & 0xFF; int cg = (packed >> 8) & 0xFF; int cb = packed & 0xFF; float sx = originX + (px - py) * tileHalfW; float sy = originY + (px + py) * tileHalfH - (z * cubeH); drawShadedIsoCube(sx, sy, tileHalfW, tileHalfH, cubeH, cr, cg, cb, a11y); } } } } } void drawShadedIsoCube(float sx, float sy, float hw, float hh, float ch, int r, int g, int b, int a11y) { int edgeCol = (a11y == 2) ? color(255) : color(12, 16, 26, 150); stroke(edgeCol); strokeWeight(1); // 1. Oberseite (100% Helligkeit) fill(r, g, b); beginShape(); vertex(sx, sy); vertex(sx + hw, sy + hh); vertex(sx, sy + 2 * hh); vertex(sx - hw, sy + hh); endShape(CLOSE); // 2. Linke Seite (76% Licht) fill(int(r * 0.76), int(g * 0.76), int(b * 0.76)); beginShape(); vertex(sx - hw, sy + hh); vertex(sx, sy + 2 * hh); vertex(sx, sy + 2 * hh + ch); vertex(sx - hw, sy + hh + ch); endShape(CLOSE); // 3. Rechte Seite (54% Licht) fill(int(r * 0.54), int(g * 0.54), int(b * 0.54)); beginShape(); vertex(sx, sy + 2 * hh); vertex(sx + hw, sy + hh); vertex(sx + hw, sy + hh + ch); vertex(sx, sy + 2 * hh + ch); endShape(CLOSE); } } // ============================================================================ // MODUL 4: STUDIO-OBERFLÄCHE, 2D-SCHICHTEDITOR & KLARTEXT-INSPEKTOR // ============================================================================ class StudioControlUI { void drawTopToolbar() { noStroke(); if (a11yMode == 2) fill(0); else if (a11yMode == 1) fill(11, 18, 32); else fill(14, 17, 26); rect(0, 0, width, 38); stroke(a11yMode == 2 ? color(255) : (a11yMode == 1 ? color(251, 191, 36) : color(179, 25, 56))); line(0, 38, width, 38); // Buttons: Speichern, Laden, Frame, Clone, Play, Layer Z, GridSize, Text-Code, Sehhilfe drawButton(10, 6, 86, 26, "Speichern", statusFlash > 0 ? color(20, 110, 60) : color(122, 16, 38)); drawButton(102, 6, 68, 26, "Laden", color(22, 54, 112)); drawButton(178, 6, 108, 26, "Frame: " + (project.activeFrame + 1) + "/" + project.usedFrames, color(24, 30, 46)); drawButton(292, 6, 84, 26, "+Clone Fr", color(22, 54, 112)); drawButton(382, 6, 66, 26, isPlaying ? "Stop" : "Play", isPlaying ? color(20, 120, 65) : color(24, 30, 46)); drawButton(456, 6, 102, 26, "Schicht Z: " + project.activeLayer, color(122, 16, 38)); drawButton(564, 6, 92, 26, "Raster: " + project.gridSize, color(24, 30, 46)); drawButton(662, 6, 82, 26, "Leeren", color(24, 30, 46)); drawButton(750, 6, 96, 26, showGrid ? "Gitter: AN" : "Gitter: AUS", showGrid ? color(22, 54, 112) : color(24, 30, 46)); drawButton(852, 6, 112, 26, showTextBox ? "3D-Ansicht" : "Text-Script [T]", showTextBox ? color(122, 16, 38) : color(22, 54, 112)); drawButton(970, 6, 180, 26, a11yMode == 0 ? "Sehhilfe: Standard" : (a11yMode == 1 ? "Farbenblind" : "Max-Kontrast"), color(32, 38, 56)); if (statusFlash > 0) statusFlash--; } void drawButton(int bx, int by, int bw, int bh, String label, color bgCol) { if (a11yMode == 2) { fill(0); stroke(255, 255, 0); } else { fill(bgCol); stroke(100, 125, 175); } rect(bx, by, bw, bh, 4); fill(a11yMode == 2 ? color(255, 255, 0) : color(255)); textSize(12); textAlign(CENTER, CENTER); text(label, bx + bw * 0.5, by + bh * 0.5); } void draw2DLayerEditor(VoxelAnimationProject proj) { int gridLeft = 16; int gridTop = 46; int gridSizePx = 520; stroke(a11yMode == 2 ? color(255) : color(179, 25, 56)); fill(a11yMode == 2 ? color(0) : color(14, 17, 26)); rect(gridLeft - 1, gridTop - 1, gridSizePx + 2, gridSizePx + 2); int N = proj.gridSize; float cellPx = float(gridSizePx) / float(N); for (int y = 0; y < N; y++) { for (int x = 0; x < N; x++) { float cx = gridLeft + x * cellPx; float cy = gridTop + y * cellPx; int curVal = proj.getVoxel(proj.activeFrame, x, y, proj.activeLayer); if (curVal != EMPTY_VOXEL) { fill((curVal >> 16) & 0xFF, (curVal >> 8) & 0xFF, curVal & 0xFF); } else { // Leeres Feld: zeigt optional eine schwache Vorschau der darunterliegenden Schicht (Z - 1) int belowVal = (showGhost && proj.activeLayer > 0) ? proj.getVoxel(proj.activeFrame, x, y, proj.activeLayer - 1) : EMPTY_VOXEL; if (belowVal != EMPTY_VOXEL) { int br = ((belowVal >> 16) & 0xFF) / 4; int bg = ((belowVal >> 8) & 0xFF) / 4; int bb = (belowVal & 0xFF) / 4; fill(16 + br, 20 + bg, 32 + bb); } else { fill(a11yMode == 2 ? color(10) : color(18, 22, 34)); } } stroke(a11yMode == 2 ? color(90) : color(42, 52, 74)); rect(cx, cy, cellPx, cellPx); } } } void drawScriptInspector(String[] lines) { int panelX = 552; int panelY = 46; int panelW = 592; int panelH = 520; stroke(a11yMode == 2 ? color(255, 255, 0) : color(179, 25, 56)); fill(5, 7, 12); rect(panelX, panelY, panelW, panelH, 6); noStroke(); fill(a11yMode == 2 ? color(0) : color(76, 9, 23)); rect(panelX + 1, panelY + 1, panelW - 2, 28, 5); fill(255); textSize(12); textAlign(LEFT, CENTER); text("KLARTEXT-ANIMATIONSFORMAT (" + ANIM_FILENAME + ") — Direkt in jedem Editor schreibbar:", panelX + 10, panelY + 15); fill(230, 238, 250); textSize(12); textAlign(LEFT, TOP); int maxVisible = min(lines.length, 29); for (int i = 0; i < maxVisible; i++) { text(lines[i], panelX + 12, panelY + 38 + i * 16); } if (lines.length > maxVisible) { fill(251, 191, 36); text("... (" + (lines.length - maxVisible) + " weitere Zeilen in " + ANIM_FILENAME + ")", panelX + 12, panelY + 38 + maxVisible * 16); } } void drawDisabled3DPlaceholder() { stroke(60); fill(12, 15, 22); rect(552, 46, 592, 520, 6); fill(200); textAlign(CENTER, CENTER); text("3D-Ansicht pausiert", 848, 306); } void drawBottomColorDeck() { int topY = 580; noStroke(); fill(a11yMode == 2 ? color(0) : color(11, 14, 22)); rect(16, topY, 1128, 148, 6); stroke(a11yMode == 2 ? color(255) : color(44, 52, 74)); noFill(); rect(16, topY, 1128, 148, 6); // 1. RGB & Helligkeits-Slider (x: 30..285) for (int i = 0; i <= 255; i++) { stroke(i, 0, 0); line(30 + i, topY + 16, 30 + i, topY + 32); stroke(0, i, 0); line(30 + i, topY + 42, 30 + i, topY + 58); stroke(0, 0, i); line(30 + i, topY + 68, 30 + i, topY + 84); stroke(i); line(30 + i, topY + 114, 30 + i, topY + 130); } // 4-Stufen Klick-Trails anzeigen for (int i = 0; i < 4; i++) { float alpha = 255 - i * 60; strokeWeight(2); if (trailR[i] != -1) { stroke(255, 80, 80, alpha); line(30 + trailR[i], topY + 14, 30 + trailR[i], topY + 34); } if (trailG[i] != -1) { stroke(80, 255, 80, alpha); line(30 + trailG[i], topY + 40, 30 + trailG[i], topY + 60); } if (trailB[i] != -1) { stroke(100, 170, 255, alpha); line(30 + trailB[i], topY + 66, 30 + trailB[i], topY + 86); } if (trailBW[i] != -1) { stroke(255, 220, 80, alpha); line(30 + trailBW[i], topY + 112, 30 + trailBW[i], topY + 132); } } strokeWeight(1); // Aktuelle Farbvorschau & Werte fill(rc, gc, bc); stroke(255); rect(30, topY + 91, 256, 16, 3); fill(255); textSize(13); textAlign(LEFT, CENTER); text("R: " + rc + " [+/-]", 298, topY + 24); text("G: " + gc + " [+/-]", 298, topY + 50); text("B: " + bc + " [+/-]", 298, topY + 76); text("Hell: " + sc, 298, topY + 122); // 2. 8-Slot Farb-Historie (x: 410..850) fill(230, 238, 250); text("Farb-Palette (Klick wählt):", 415, topY + 22); for (int i = 0; i < MAX_PALETTE; i++) { float hx = 415 + i * 52; float hy = topY + 40; fill(paletteHistory[i]); stroke(i == 0 ? color(255, 215, 0) : color(140)); strokeWeight(i == 0 ? 2 : 1); rect(hx, hy, 44, 44, 5); } strokeWeight(1); // 3. Werkzeug-Umschalter (Pinsel / Radierer / Pipette) & Statuszeile drawButton(415, topY + 96, 110, 32, "Pinsel", toolMode == 0 ? color(122, 16, 38) : color(24, 30, 46)); drawButton(533, topY + 96, 110, 32, "Radierer", toolMode == 1 ? color(122, 16, 38) : color(24, 30, 46)); drawButton(651, topY + 96, 110, 32, "Pipette", toolMode == 2 ? color(122, 16, 38) : color(24, 30, 46)); fill(a11yMode == 2 ? color(255, 255, 0) : color(205, 218, 240)); textSize(12); textAlign(LEFT, CENTER); text(statusBanner, 855, topY + 35); text("Tasten: [W/S] Schicht Z | [A/D] Frame | [Q/E] 3D-Drehung | [Space] Play", 855, topY + 65); text("Export-Format: FRAME / VOXEL x y z r g b / BOX (MIT License)", 855, topY + 95); } void handleTopBarClick(int mx, int my, int btn) { // Speichern if (mx >= 10 && mx <= 96) { boolean ok = project.saveToTextFile(ANIM_FILENAME); setStatus(ok ? "Gespeichert: " + ANIM_FILENAME : "Script aktualisiert (Text-Script [T] zum Kopieren)"); return; } // Laden if (mx >= 102 && mx <= 170) { boolean ok = project.loadFromTextFile(ANIM_FILENAME); setStatus(ok ? "Geladen: " + ANIM_FILENAME : "Keine lokale Datei gefunden — Startszene aktiv"); return; } // Frame wechseln (Links = vorwärts, Rechts = zurück) if (mx >= 178 && mx <= 286) { if (btn == RIGHT) project.activeFrame = (project.activeFrame + project.usedFrames - 1) % project.usedFrames; else project.activeFrame = (project.activeFrame + 1) % project.usedFrames; return; } // +Clone Frame if (mx >= 292 && mx <= 376) { project.cloneCurrentFrameToNext(); return; } // Play / Stop if (mx >= 382 && mx <= 448) { isPlaying = !isPlaying; return; } // Schicht Z (Links = hoch, Rechts = runter) if (mx >= 456 && mx <= 558) { if (btn == RIGHT) project.activeLayer = max(0, project.activeLayer - 1); else project.activeLayer = (project.activeLayer + 1) % project.gridSize; return; } // Rastergröße (Links = größer, Rechts = kleiner) if (mx >= 564 && mx <= 656) { if (btn == RIGHT) project.gridSize = max(6, project.gridSize - 2); else project.gridSize = (project.gridSize >= 20) ? 8 : project.gridSize + 2; project.activeLayer = min(project.activeLayer, project.gridSize - 1); setStatus("Rastergröße: " + project.gridSize + "×" + project.gridSize + "×" + project.gridSize); return; } // Leeren (Links = aktuelle Schicht Z, Rechts = ganzer Frame) if (mx >= 662 && mx <= 744) { if (btn == RIGHT) { project.clearFrame(project.activeFrame); setStatus("Frame " + (project.activeFrame + 1) + " komplett geleert"); } else { project.clearLayer(project.activeFrame, project.activeLayer); setStatus("Schicht Z=" + project.activeLayer + " geleert"); } return; } // Gitter AN/AUS if (mx >= 750 && mx <= 846) { showGrid = !showGrid; return; } // Text-Script Inspektor [T] if (mx >= 852 && mx <= 964) { exportedScriptLines = project.serializeToText(); showTextBox = !showTextBox; return; } // Sehhilfe-Umschalter if (mx >= 970 && mx <= 1150) { a11yMode = (a11yMode + 1) % 3; return; } } void handleColorDeckClick(int mx, int my, int btn) { int topY = 580; // Slider-Klicks (x: 30..285) if (mx >= 30 && mx <= 285) { int val = constrain(mx - 30, 0, 255); if (my >= topY + 14 && my <= topY + 34) { setCurrentColor(val, gc, bc); return; } if (my >= topY + 40 && my <= topY + 60) { setCurrentColor(rc, val, bc); return; } if (my >= topY + 66 && my <= topY + 86) { setCurrentColor(rc, gc, val); return; } if (my >= topY + 112 && my <= topY + 132) { int shift = val - sc; setCurrentColor(rc + shift, gc + shift, bc + shift); return; } } // Feinabstimmung +/- neben R/G/B (x: 295..390) if (mx >= 295 && mx <= 390) { int step = (btn == RIGHT) ? -1 : 1; if (my >= topY + 14 && my <= topY + 34) { setCurrentColor(rc + step, gc, bc); return; } if (my >= topY + 40 && my <= topY + 60) { setCurrentColor(rc, gc + step, bc); return; } if (my >= topY + 66 && my <= topY + 86) { setCurrentColor(rc, gc, bc + step); return; } } // 8er Farb-Palette (x: 415..830, y: topY+40..topY+84) if (my >= topY + 40 && my <= topY + 84 && mx >= 415 && mx <= 415 + MAX_PALETTE * 52) { int idx = floor((mx - 415) / 52.0); if (idx >= 0 && idx < MAX_PALETTE) { color c = paletteHistory[idx]; setCurrentColor((int)red(c), (int)green(c), (int)blue(c)); return; } } // Werkzeug-Buttons (Pinsel / Radierer / Pipette) if (my >= topY + 96 && my <= topY + 128) { if (mx >= 415 && mx <= 525) { toolMode = 0; return; } if (mx >= 533 && mx <= 643) { toolMode = 1; return; } if (mx >= 651 && mx <= 761) { toolMode = 2; return; } } } }