コード例 #1
0
ファイル: ProjetEleve.cs プロジェクト: VB6Hobbyst7/Moteur-3D
        public static void Start()
        {
            //création de la scène qui va contenir les objets
            Scene mainScene = new Scene();

            //couleurs
            Couleur blanc  = new Couleur(1, 1, 1);
            Couleur rouge  = new Couleur(0.9f, 0, 0);
            Couleur jaune  = new Couleur(1, 1, 0);
            Couleur vert   = new Couleur(0, 1, 0);
            Couleur cyan   = new Couleur(0, 1, 1);
            Couleur bleu   = new Couleur(0, 0, 1);
            Couleur violet = new Couleur(1, 0, 1);
            Couleur gris   = new Couleur(0.5f, 0.5f, 0.5f);
            Couleur noir   = new Couleur(0, 0, 0);

            //========== Lumières ==========
            //lumière ambiante


            //lumières directionnelles
            V3 directionLumièreDirectionnelle;
            V3 positionLumièrePoint;
            LumiereDirectionnelle lumiereDirerectionnelle;
            LumierePoint          lumierePoint;

            LumiereAmbiante LumAmb = new LumiereAmbiante(new Couleur(0.3f, 0.3f, 0.3f));

            mainScene.SetLumAmb(LumAmb);

            directionLumièreDirectionnelle = new V3(0, -1, 0);
            lumiereDirerectionnelle        = new LumiereDirectionnelle(new Couleur(0.5f, 0.5f, 0.5f), directionLumièreDirectionnelle);
            //mainScene.AddLumDir(lumiereDirerectionnelle);

            positionLumièrePoint = new V3(400, 1, 400);
            lumierePoint         = new LumierePoint(new Couleur(0.5f, 0.5f, 0.5f), positionLumièrePoint);
            mainScene.AddLum(lumierePoint);

            positionLumièrePoint = new V3(BitmapEcran.GetWidth() / 2, 0, BitmapEcran.GetHeight() / 2);
            lumierePoint         = new LumierePoint(new Couleur(0.5f, 0.5f, 0.5f), positionLumièrePoint);
            mainScene.AddLum(lumierePoint);



            //directionLumièreDirectionnelle = new V3(-1, -1, -1);
            //lumiereDirerectionnelle = new LumiereDirectionnelle(new Couleur(0,0, 0.7f), directionLumièreDirectionnelle);
            //mainScene.AddLumDir(lumiereDirerectionnelle);

            //========== Matériaux ==========
            Materiel Blanc  = new Materiel(blanc / 1.2f, new Texture("bump38.jpg"), 50, 1);
            Materiel test   = new Materiel(new Texture("test.jpg"), new Texture("test.jpg"), 200, 3);
            Materiel or     = new Materiel(new Texture("gold.jpg"), new Texture("gold_Bump.jpg"), 200, 0.7f);
            Materiel plomb  = new Materiel(new Texture("lead.jpg"), new Texture("lead_bump.jpg"), 50, 1);
            Materiel brique = new Materiel(new Texture("brickwork-texture.jpg"), new Texture("brickwork-bump-map.jpg"), 500, 1);
            Materiel rock   = new Materiel(new Texture("rock.jpg"), new Texture("rock.jpg"), 500, 1);
            Materiel stone  = new Materiel(new Texture("rock.jpg"), new Texture("rock.jpg"), 500, 1);
            Materiel fibre  = new Materiel(new Texture("rock.jpg"), new Texture("rock.jpg"), 500, 1);
            Materiel Blob   = new Materiel(blanc / 1.2f, new Texture("bump.jpg"), 50, 1);


            //========== Objets ==========
            V3        center;
            Sphere    s;
            Rectangle r;

            //Boule Or
            center = new V3(600, 300f, 200);
            s      = new Sphere(center, 50, or);
            mainScene.AddObjet3D(s);

            //Boule Or
            center = new V3(200, 200, 100);
            s      = new Sphere(center, 150, Blob);
            mainScene.AddObjet3D(s);

            //Boule Plomb
            center = new V3(800, 1000, 400);
            s      = new Sphere(center, 100, plomb);
            mainScene.AddObjet3D(s);

            //Boule Brique
            center = new V3(300, 1000, 400);
            s      = new Sphere(center, 150, Blanc);
            mainScene.AddObjet3D(s);

            //Rectangle brique Gauche
            V3 A = new V3(0, 0, 0);
            V3 B = new V3(0, 2000, 0);
            V3 C = new V3(0, 0, 800);

            r = new Rectangle(A, B, C, brique);
            mainScene.AddObjet3D(r);

            //Rectangle brique Droit
            A = new V3(1000, 2000, 0);
            B = new V3(1000, 0, 0);
            C = new V3(1000, 2000, 800);
            r = new Rectangle(A, B, C, brique);
            mainScene.AddObjet3D(r);

            //Rectangle brique Fond
            A = new V3(0, 2000, 0);
            B = new V3(1000, 2000, 0);
            C = new V3(0, 2000, 800);
            r = new Rectangle(A, B, C, brique);
            mainScene.AddObjet3D(r);

            //Rectangle brique Bas
            A = new V3(0, 0, 0);
            B = new V3(1000, 0, 0);
            C = new V3(0, 2000, 0);
            r = new Rectangle(A, B, C, brique);
            mainScene.AddObjet3D(r);

            A = new V3(400, 0, 0);
            B = new V3(190, -50, 0);
            C = new V3(0, 0, 190);
            r = new Rectangle(A, B, C, brique);
            //mainScene.AddObjet3D(r);


            //Affichage de la scène
            mainScene.DrawScene();
        }
コード例 #2
0
        public static Scene Scene1()
        {
            Couleur blanc = new Couleur(1.0f, 1.0f, 1.0f);
            Scene   scene = new Scene(blanc, 0.05f, 50);

            Couleur orangesque = new Couleur(1.0f, 0.78f, 0.59f);
            Couleur bleuesque  = new Couleur(0.78f, 0.59f, 1.0f);
            Couleur rouge      = new Couleur(1.0f, 0.0f, 0.0f);


            Sphere sphere1 = new Sphere("carreau.jpg", "bump38.jpg", new V3(200.0f, 0.0f, 200.0f), 100.0f);

            scene.AddObjet(sphere1);
            Sphere sphere2 = new Sphere("lead.jpg", "bump38.jpg", new V3(350.0f, -150.0f, 350.0f), 50.0f);

            scene.AddObjet(sphere2);
            Sphere sphere3 = new Sphere("brick01.jpg", "bump38.jpg", new V3(350.0f, 700.0f, 120.0f), 50.0f);

            scene.AddObjet(sphere3);


            Quadrilatere quad1 = new Quadrilatere("brick01.jpg", "bump38.jpg", new V3(650.0f, 1000.0f, 100.0f), new V3(750.0f, 10, 100.0f), new V3(650.0f, 1000.0f, 300.0f));

            scene.AddObjet(quad1);


            Quadrilatere sol = new Quadrilatere("wood.jpg", "bump1.jpg", new V3(500.0f, 0.0f, 0.0f), new V3(1000.0f, 500.0f, 0.0f), new V3(0.0f, 500.0f, 0.0f));

            scene.AddObjet(sol);

            Quadrilatere mur = new Quadrilatere(blanc, "bump.jpg", new V3(0.0f, 500.0f, 0.0f), new V3(500.0f, 1000.0f, 0.0f), new V3(0.0f, 500.0f, 1000.0f));

            scene.AddObjet(mur);

            Quadrilatere mur2 = new Quadrilatere(blanc, "bump.jpg", new V3(500.0f, 1000.0f, 0.0f), new V3(1000.0f, 500.0f, 0.0f), new V3(500.0f, 1000.0f, 1000.0f));

            scene.AddObjet(mur2);

            //Quadrilatere quad3 = new Quadrilatere(rouge, "n", new V3(0, 0, 0), new V3(10, 0, 0), new V3(0, 0, 10));
            //scene1.AddObjet(quad3);

            Lumiere key = new LampeDirectionelle(orangesque, 0.48f, new V3(1.0f, -1.0f, 1.0f));

            scene.AddLampe(key);
            Lumiere fill = new LampeDirectionelle(bleuesque, 0.27f, new V3(-1.0f, -1.0f, 1.0f));

            scene.AddLampe(fill);
            Lumiere back = new LampeDirectionelle(blanc, 0.2f, new V3(-1.0f, 1.0f, -1.0f));

            scene.AddLampe(back);

            Lumiere centrale = new LampePonctuelle(blanc, 0.5f, new V3(650.0f, 900.0f, 500.0f), 0.001f);

            scene.AddLampe(centrale);
            centrale = new LampePonctuelle(blanc, 0.7f, new V3(250.0f, 900.0f, 500.0f), 0.001f);
            scene.AddLampe(centrale);



            return(scene);
        }