Loading Now

Derniers développements

an artist s illustration of artificial intelligence ai this illustration depicts language models which generate text it was created by wes cockx as part of the visualising ai project l

La bibliothèque empty3-library-mp a été mise à jour. Amélioration du rendu par défaut création d’une classe one.empty3.library.Box qui représente un parallélépipède (donc incluant cube, rectangle 3d ).

Un agent IA permettra de créer des exemples de code pour des images et des vidéos.

Voici les premiers résultats de l’agent: (le code généré par l’agent a été légèrement modifié car il comportait encore quelques erreurs)

/*
 *
 *  *
 *  *  * Copyright (c) 2026. Manuel Daniel Dahmen
 *  *  *
 *  *  *
 *  *  *    Copyright 2026 Manuel Daniel Dahmen
 *  *  *
 *  *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *  *    you may not use this file except in compliance with the License.
 *  *  *    You may obtain a copy of the License at
 *  *  *
 *  *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *  *
 *  *  *    Unless required by applicable law or agreed to in writing, software
 *  *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  *    See the License for the specific language governing permissions and
 *  *  *    limitations under the License.
 *  *
 *  *
 *
 *
 *
 *  * Created by $user $date
 *
 *
 */

package one.empty3.testagentcode;

import one.empty3.library.*;
import one.empty3.apps.testobject.TestObjetSub;
import one.empty3.libs.Color;

public class GreenCubeAnimation extends TestObjetSub {
    double startX = -2.5;
    double endX = 2.5;
    private Box cube;
    private double cubeSize = 0.5; // Correspond au quart d'une hauteur d'écran de 2.0 unités

    @Override
    public void ginit() {
        // Initialisation de la scène
        scene = new Scene();

        // Création du cube vert
        cube = new Box(cubeSize, cubeSize, cubeSize);
        cube.texture(new ColorTexture(Color.newCol(0f, 1f, 0f)));

        cube.setOrig(new Point3D(startX, 0d, 0d));

        // Ajout du cube à la scène
        scene.add(cube);

        // Positionnement de la caméra (vue de face)
        Camera camera = new Camera(new Point3D(0d, 0d, 5d), Point3D.O0, Point3D.Y);
        scene.cameraActive(camera);
    }

    @Override
    public void finit() {
        // Calcul de la progression du film (de 0.0 à 1.0)
        double progress = (double) frame() / getMaxFrames();


        // Animation : de gauche (x = -2.5) à droite (x = 2.5)

        double currentX = startX + (endX - startX) * progress;
        currentX = (endX - startX) / getMaxFrames();
        // Mise à jour de la position du cube
        // On définit la position du centre du cube
        cube.setOrig(new Point3D(currentX, 0d, 0d));

    }

    public static void main(String[] args) {
        GreenCubeAnimation animation = new GreenCubeAnimation();
        // Configuration de la résolution et du nombre d'images
        animation.setResolution(800, 600);
        animation.setMaxFrames(100);
        new Thread(animation).start();
    }
}
/*
 *
 *  *
 *  *  * Copyright (c) 2026. Manuel Daniel Dahmen
 *  *  *
 *  *  *
 *  *  *    Copyright 2026 Manuel Daniel Dahmen
 *  *  *
 *  *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *  *    you may not use this file except in compliance with the License.
 *  *  *    You may obtain a copy of the License at
 *  *  *
 *  *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *  *
 *  *  *    Unless required by applicable law or agreed to in writing, software
 *  *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  *    See the License for the specific language governing permissions and
 *  *  *    limitations under the License.
 *  *
 *  *
 *
 *
 *
 *  * Created by $user $date
 *
 *
 */

package one.empty3.testagentcode;

import one.empty3.library.*;

import java.awt.Color;
import java.io.File;
import javax.imageio.ImageIO;

public class SphereBleue {
    public static void main(String[] args) {
        // 1. Création de la scène
        Scene scene = new Scene();

        // 2. Création de la sphère
        // Paramètres : centre (Point3D) et rayon (double)
        Point3D centre = new Point3D(0.0, 0.0, 0.0);
        double rayon = 1.0;
        Sphere sphere = new Sphere(centre, rayon);

        // 3. Application de la couleur bleue
        sphere.texture(new ColorTexture(one.empty3.libs.Color.newCol(0f, 0f, 1f)));

        // Ajout de la sphère à la scène
        scene.add(sphere);

        // 4. Configuration de la caméra
        // On place la caméra pour voir la sphère
        Camera camera = new Camera(new Point3D(0.0, 0.0, 4.0), Point3D.O0, Point3D.Y);
        scene.cameraActive(camera);

        // 5. Rendu avec ZBufferImpl
        int largeur = 800;
        int hauteur = 600;
        ZBufferImpl zBuffer = ZBufferFactory.instance(largeur, hauteur, scene);
        zBuffer.camera(camera);

        // Calcul du rendu
        zBuffer.draw();

        // 6. Enregistrement de l'image
        try {
            File output = new File("sphere_bleue.png");
            ImageIO.write(zBuffer.image().getBi(), "png", output);
            System.out.println("Image de la sphère bleue générée : " + output.getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
/*
 *
 *  *
 *  *  * Copyright (c) 2026. Manuel Daniel Dahmen
 *  *  *
 *  *  *
 *  *  *    Copyright 2026 Manuel Daniel Dahmen
 *  *  *
 *  *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *  *    you may not use this file except in compliance with the License.
 *  *  *    You may obtain a copy of the License at
 *  *  *
 *  *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *  *
 *  *  *    Unless required by applicable law or agreed to in writing, software
 *  *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  *    See the License for the specific language governing permissions and
 *  *  *    limitations under the License.
 *  *
 *  *
 *
 *
 *
 *  * Created by $user $date
 *
 *
 */

package one.empty3.testagentcode;

import one.empty3.library.*;
import one.empty3.libs.Color;

import java.io.File;
import javax.imageio.ImageIO;

public class CubeRougeImage {
    public static void main(String[] args) {
        // 1. Création de la scène
        Scene scene = new Scene();

        // 2. Création d'un cube (Box) de dimensions 1x1x1
        // On centre le cube en utilisant une translation ou en ajustant ses paramètres
        Box cube = new Box(1.0, 1.0, 1.0);

        // 3. Application de la texture rouge
        cube.texture(new ColorTexture(Color.newCol(1f, 0f, 0f)));

        // Ajout du cube à la scène
        scene.add(cube);

        // 4. Configuration de la caméra
        // Positionnée en (2, 2, 2) pour une vue en perspective, regardant l'origine (0, 0, 0)
        Point3D positionCamera = new Point3D(2.0, 2.0, 2.0);
        Point3D pointCible = Point3D.O0;
        Camera camera = new Camera(positionCamera, pointCible);
        scene.cameraActive(camera);

        // 5. Rendu de l'image avec ZBufferImpl
        int largeur = 800;
        int hauteur = 600;
        ZBufferImpl zBuffer = ZBufferFactory.instance(largeur, hauteur, scene);
        zBuffer.camera(camera);

        // Calcul du rendu des objets de la scène
        zBuffer.draw();

        // 6. Enregistrement du résultat dans un fichier image
        try {
            File fichierSortie = new File("cube_rouge.png");
            zBuffer.image().saveFile(fichierSortie);
            System.out.println("Image du cube rouge générée avec succès : " + fichierSortie.getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
/*
 *
 *  *
 *  *  * Copyright (c) 2026. Manuel Daniel Dahmen
 *  *  *
 *  *  *
 *  *  *    Copyright 2026 Manuel Daniel Dahmen
 *  *  *
 *  *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *  *    you may not use this file except in compliance with the License.
 *  *  *    You may obtain a copy of the License at
 *  *  *
 *  *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *  *
 *  *  *    Unless required by applicable law or agreed to in writing, software
 *  *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  *    See the License for the specific language governing permissions and
 *  *  *    limitations under the License.
 *  *
 *  *
 *
 *
 *
 *  * Created by $user $date
 *
 *
 */

package one.empty3.testagentcode;

import one.empty3.Cylinder;
import one.empty3.library.*;
import one.empty3.library.ZBufferImpl;
import one.empty3.libs.Color;
import one.empty3.libs.Image;

import java.io.File;

public class DessinerMouton {

    public static void main(String[] args) {
        Scene scene = new Scene();

        // Couleurs
        Color couleurLaine = Color.newCol(0.9f, 0.9f, 0.9f); // Blanc cassé
        Color couleurPeau = Color.newCol(0.1f, 0.1f, 0.1f);  // Noir/Gris foncé

        // 1. Le corps (une grosse sphère étirée ou plusieurs sphères)
        Sphere corps = new Sphere(new Point3D(0d, 0d, 0d), 1.5);
        corps.texture(new TextureCol(couleurLaine));
        // On l'allonge un peu sur l'axe X pour faire un corps ovale
        corps.setVectX(new Point3D(1.5, 0d, 0d));
        scene.add(corps);

        // 2. La tête
        Sphere tete = new Sphere(new Point3D(1.8, 0.8, 0d), 0.6);
        tete.texture(new TextureCol(couleurPeau));
        scene.add(tete);

        // 3. Les pattes (4 cylindres)
        double hauteurPatte = 1.5;
        double rayonPatte = 0.15;

        Point3D[] positionsPattes = {
                new Point3D(0.8, -1.0, 0.6),
                new Point3D(0.8, -1.0, -0.6),
                new Point3D(-0.8, -1.0, 0.6),
                new Point3D(-0.8, -1.0, -0.6)
        };

        for (Point3D pos : positionsPattes) {
            // Un cylindre de la base vers le bas
            Cylinder patte = new Cylinder(pos, pos.plus(new Point3D(0d, -hauteurPatte, 0d)), rayonPatte);
            patte.texture(new TextureCol(couleurPeau));
            scene.add(patte);
        }

        // 4. Les oreilles (petites sphères)
        Sphere oreilleD = new Sphere(new Point3D(2.0, 1.2, 0.4), 0.15);
        oreilleD.texture(new TextureCol(couleurPeau));
        scene.add(oreilleD);

        Sphere oreilleG = new Sphere(new Point3D(2.0, 1.2, -0.4), 0.15);
        oreilleG.texture(new TextureCol(couleurPeau));
        scene.add(oreilleG);

        // Configuration de la Caméra
        // On se place sur le côté pour voir la forme
        Camera camera = new Camera(new Point3D(6d, 3d, 6d), Point3D.O0, Point3D.Y);
        scene.cameraActive(camera);

        // Rendu
        int width = 1024;
        int height = 768;
        ZBufferImpl zBuffer = ZBufferFactory.instance(width, height);
        zBuffer.scene(scene);
        zBuffer.camera(camera);

        // Optionnel : ajouter une lumière simple
        scene.getLumieres().add(new LumierePonctuelle(new Point3D(10d, 10d, 10d), Color.newCol(1f, 1f, 1f)));
        zBuffer.draw();

        // Sauvegarde
        Image image = zBuffer.image();
        File output = new File("mouton.png");
        if (image.saveFile(output)) {
            System.out.println("L'image du mouton a été sauvegardée : " + output.getAbsolutePath());
        }
    }
}
/*
*
* *
* * * Copyright (c) 2026. Manuel Daniel Dahmen
* * *
* * *
* * * Copyright 2026 Manuel Daniel Dahmen
* * *
* * * Licensed under the Apache License, Version 2.0 (the "License");
* * * you may not use this file except in compliance with the License.
* * * You may obtain a copy of the License at
* * *
* * * http://www.apache.org/licenses/LICENSE-2.0
* * *
* * * Unless required by applicable law or agreed to in writing, software
* * * distributed under the License is distributed on an "AS IS" BASIS,
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * * See the License for the specific language governing permissions and
* * * limitations under the License.
* *
* *
*
*
*
* * Created by $user $date
*
*
*/

package one.empty3.testagentcode;

import one.empty3.Cylinder;
import one.empty3.library.*;
import one.empty3.library.ZBufferImpl;
import one.empty3.libs.Color;
import one.empty3.libs.Image;

import java.io.File;

public class DessinerChevre {

public static void main(String[] args) {
Scene scene = new Scene();

// Couleurs
Color couleurCorps = Color.newCol(0.8f, 0.7f, 0.5f); // Brun clair / Beige
Color couleurCornes = Color.newCol(0.3f, 0.2f, 0.1f); // Brun foncé
Color couleurPeau = Color.newCol(0.1f, 0.1f, 0.1f); // Noir pour les sabots/museau

// 1. Le corps (plus fin que le mouton)
Sphere corps = new Sphere(new Point3D(0d, 0d, 0d), 1.0);
corps.texture(new TextureCol(couleurCorps));
// Allongement du corps
corps.setVectX(new Point3D(1.6, 0d, 0d));
scene.add(corps);

// 2. Le cou (Cylindre oblique)
Point3D baseCou = new Point3D(1.3, 0.3, 0d);
Point3D hautCou = new Point3D(1.8, 1.2, 0d);
Cylinder cou = new Cylinder(baseCou, hautCou, 0.3);
cou.texture(new TextureCol(couleurCorps));
scene.add(cou);

// 3. La tête
Sphere tete = new Sphere(hautCou.plus(new Point3D(0.2, 0.2, 0d)), 0.4);
tete.texture(new TextureCol(couleurCorps));
scene.add(tete);

// 4. Les cornes (deux petits cylindres incurvés vers l'arrière)
Point3D front = hautCou.plus(new Point3D(0.1, 0.4, 0d));

Cylinder corneD = new Cylinder(front.plus(new Point3D(0d, 0d, 0.15)),
front.plus(new Point3D(-0.3, 0.6, 0.2)), 0.08);
corneD.texture(new TextureCol(couleurCornes));
scene.add(corneD);

Cylinder corneG = new Cylinder(front.plus(new Point3D(0d, 0d, -0.15)),
front.plus(new Point3D(-0.3, 0.6, -0.2)), 0.08);
corneG.texture(new TextureCol(couleurCornes));
scene.add(corneG);

// 5. Les pattes (plus fines et longues)
double hauteurPatte = 1.8;
double rayonPatte = 0.1;
Point3D[] posPattes = {
new Point3D(1.0, -0.7, 0.4),
new Point3D(1.0, -0.7, -0.4),
new Point3D(-1.0, -0.7, 0.4),
new Point3D(-1.0, -0.7, -0.4)
};

for (Point3D pos : posPattes) {
Cylinder patte = new Cylinder(pos, pos.plus(new Point3D(0d, -hauteurPatte, 0d)), rayonPatte);
patte.texture(new TextureCol(couleurCorps));
scene.add(patte);

// Sabots
Sphere sabot = new Sphere(pos.plus(new Point3D(0d, -hauteurPatte, 0d)), 0.12);
sabot.texture(new TextureCol(couleurPeau));
scene.add(sabot);
}

// Configuration Caméra
Camera camera = new Camera(new Point3D(5d, 3d, 8d), Point3D.O0, Point3D.Y);
scene.cameraActive(camera);

// Rendu
int width = 1200;
int height = 900;
ZBufferImpl zBuffer = new ZBufferImpl(width, height);
zBuffer.scene(scene);
zBuffer.camera(camera);

// Lumière
scene.getLumieres().add(new LumierePonctuelle(new Point3D(10d, 10d, 10d), Color.newCol(1f, 1f, 1f)));

zBuffer.draw(scene);

// Sauvegarde
Image image = zBuffer.image();
File output = new File("chevre.png");
if (image.saveFile(output)) {
System.out.println("Image de la chèvre générée : " + output.getAbsolutePath());
}
}
}

Laisser un commentaire