Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Kamera initialisieren
            Camera.Init();
            Camera.SetWidthHeightFov(800, 600, 60);

            // Das Objekt laden
            objRaceTrack = new ObjLoaderObject3D("data/objects/testTrack.obj", 1.0f, true);
            objRaceCar   = new ObjLoaderObject3D("data/objects/car2.obj", 1.0f, true);

            // Die Textur laden
            texRaceTrack    = TextureManager.LoadTexture("data/textures/street.png");
            texRaceCar      = TextureManager.LoadTexture("data/textures/single_color.png");
            normalTextureID = TextureManager.LoadTexture("data/textures/brick_normal.png");


            // Materialien initialisieren
            simpleReflectionMaterial       = new SimpleReflectionMaterial();
            simpleTextureMaterial          = new SimpleTextureMaterial();
            wobble1Material                = new Wobble1Material();
            wobble2Material                = new Wobble2Material();
            ambientDiffuseMaterial         = new AmbientDiffuseMaterial();
            ambientDiffuseSpecularMaterial = new AmbientDiffuseSpecularMaterial();
            normalMappingMaterial          = new NormalMappingMaterial();

            // Tiefenpuffer einschalten
            GL.Enable(EnableCap.DepthTest);

            // Face-Culling
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Front);

            // Kameraposition setzen
            // x=Links, y=Hoch, z=Vor ; x=, y=Up, z= ; x=, y=Up, z= ;
            Camera.SetLookAt(new Vector3(0, 4, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0));


            // Licht setzen
            Light.SetDirectionalLight(new Vector3(1, 1, 1), new Vector4(0.5f, 0.5f, 0.5f, 1), new Vector4(1.0f, 1.0f, 1.0f, 0.0f), new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
        }
Exemplo n.º 2
0
        private void CreateCrates()
        {
            Material crateMaterial = new NormalMappingMaterial("Content/Textures/woodCrate_diffuse.png", "Content/Textures/woodCrate_normal_spec.png")
            {
                AmbientColor = Color.White * 0.4f
            };
            int   baseSize    = 5;
            float ySeparation = 1.5f;
            float xSeparation = 1.1f;

            for (int i = 0; i < baseSize; i++)
            {
                for (int j = baseSize - i - 1; j >= 0; j--)
                {
                    float xOffset       = -(baseSize - i - 1) / 2f;
                    var   cratePosition = new Vector3(xSeparation * (j + xOffset), ySeparation * i + 1, 0);
                    // Draw a cube
                    Entity crate = new Entity()
                    {
                        Tag = "Removable"
                    }
                    .AddComponent(new Transform3D()
                    {
                        LocalPosition = cratePosition
                    })
                    .AddComponent(new Model("Content/Models/crate.FBX"))
                    .AddComponent(new BoxCollider()
                    {
                    })
                    .AddComponent(new RigidBody3D()
                    {
                        CollisionGroup = this.sceneGroup
                    })
                    .AddComponent(new MaterialsMap(crateMaterial))
                    .AddComponent(new ModelRenderer());

                    EntityManager.Add(crate);
                }
            }
        }
Exemplo n.º 3
0
        protected override void CreateScene()
        {
            WaveServices.ScreenLayers.SetDiagnosticsActive(true);
            //RenderManager.DebugLines = true;

            RenderManager.BackgroundColor = Color.CornflowerBlue;

            //Create the camera
            FreeCamera camera = new FreeCamera("freeCamera", new Vector3(42.60071f, 10.3373f, -45.83459f), new Vector3(41.77419f, 10.37616f, -45.27303f))
            {
                Speed = 10
            };

            //Add some light!
            PointLight light = new PointLight("light", Vector3.Zero)
            {
                Position = new Vector3(0, 5, 0),
                Attenuation = 750,
                Color = new Color(1, 0.6f, 0.4f),
                IsVisible = true
            };

            EntityManager.Add(light);
            EntityManager.Add(camera);

            Material columnMaterialA = new NormalMappingMaterial("Content/column1.wpk", "Content/column1_normal_spec.wpk") { AmbientColor = Color.White * 0.3f };
            Material columnMaterialB = new NormalMappingMaterial("Content/column2.wpk", "Content/column2_normal_spec.wpk") { AmbientColor = Color.White * 0.3f };

            bool isStatic = true;
            float columnSpacing = 8;
            int nCols = 10;
            int nColumns = 0;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++) { IsStatic = isStatic }
                        .AddComponent(new Transform3D() 
                        { 
                            Position = new Vector3(-j * columnSpacing, 0, (i - 1) * columnSpacing),
                            Rotation = new Vector3(0, (WaveServices.Random.NextInt() % 4) * MathHelper.PiOver4, 0)
                        })
                        .AddComponent(new ModelRenderer())
                        .AddComponent(new Model("Content/mainColumn.wpk"))
                        .AddComponent(new MaterialsMap(columnMaterialB));

                    EntityManager.Add(column);
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++) { IsStatic = isStatic }
                        .AddComponent(new Transform3D() 
                        { 
                            Position = new Vector3(-j * columnSpacing, 0, (i - 4) * columnSpacing),
                            Rotation = new Vector3(0, (WaveServices.Random.NextInt() % 4) * MathHelper.PiOver2, 0)
                        })
                        .AddComponent(new ModelRenderer())
                        .AddComponent(new Model("Content/column.wpk"))
                        .AddComponent(new MaterialsMap(columnMaterialA));

                    EntityManager.Add(column);
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++) { IsStatic = isStatic }
                        .AddComponent(new Transform3D() { Position = new Vector3(-j * columnSpacing, 0, (i + 1) * columnSpacing) })
                        .AddComponent(new ModelRenderer())
                        .AddComponent(new Model("Content/column.wpk"))
                        .AddComponent(new MaterialsMap(columnMaterialA));

                    EntityManager.Add(column);
                }
            }
        }
Exemplo n.º 4
0
        protected override void CreateScene()
        {
            WaveServices.ScreenLayers.SetDiagnosticsActive(true);
            //RenderManager.DebugLines = true;

            RenderManager.BackgroundColor = Color.CornflowerBlue;

            //Create the camera
            FreeCamera camera = new FreeCamera("freeCamera", new Vector3(42.60071f, 10.3373f, -45.83459f), new Vector3(41.77419f, 10.37616f, -45.27303f))
            {
                Speed = 10
            };

            //Add some light!
            PointLight light = new PointLight("light", Vector3.Zero)
            {
                Position    = new Vector3(0, 5, 0),
                Attenuation = 750,
                Color       = new Color(1, 0.6f, 0.4f),
                IsVisible   = true
            };

            EntityManager.Add(light);
            EntityManager.Add(camera);

            Material columnMaterialA = new NormalMappingMaterial("Content/column1.wpk", "Content/column1_normal_spec.wpk")
            {
                AmbientColor = Color.White * 0.3f
            };
            Material columnMaterialB = new NormalMappingMaterial("Content/column2.wpk", "Content/column2_normal_spec.wpk")
            {
                AmbientColor = Color.White * 0.3f
            };

            bool  isStatic      = true;
            float columnSpacing = 8;
            int   nCols         = 10;
            int   nColumns      = 0;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++)
                    {
                        IsStatic = isStatic
                    }
                    .AddComponent(new Transform3D()
                    {
                        Position = new Vector3(-j * columnSpacing, 0, (i - 1) * columnSpacing),
                        Rotation = new Vector3(0, (WaveServices.Random.NextInt() % 4) * MathHelper.PiOver4, 0)
                    })
                    .AddComponent(new ModelRenderer())
                    .AddComponent(new Model("Content/mainColumn.wpk"))
                    .AddComponent(new MaterialsMap(columnMaterialB));

                    EntityManager.Add(column);
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++)
                    {
                        IsStatic = isStatic
                    }
                    .AddComponent(new Transform3D()
                    {
                        Position = new Vector3(-j * columnSpacing, 0, (i - 4) * columnSpacing),
                        Rotation = new Vector3(0, (WaveServices.Random.NextInt() % 4) * MathHelper.PiOver2, 0)
                    })
                    .AddComponent(new ModelRenderer())
                    .AddComponent(new Model("Content/column.wpk"))
                    .AddComponent(new MaterialsMap(columnMaterialA));

                    EntityManager.Add(column);
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Entity column = new Entity("column_" + nColumns++)
                    {
                        IsStatic = isStatic
                    }
                    .AddComponent(new Transform3D()
                    {
                        Position = new Vector3(-j * columnSpacing, 0, (i + 1) * columnSpacing)
                    })
                    .AddComponent(new ModelRenderer())
                    .AddComponent(new Model("Content/column.wpk"))
                    .AddComponent(new MaterialsMap(columnMaterialA));

                    EntityManager.Add(column);
                }
            }
        }
Exemplo n.º 5
0
        private void CreateCrates()
        {
            Material crateMaterial = new NormalMappingMaterial("Content/Textures/woodCrate_diffuse.png", "Content/Textures/woodCrate_normal_spec.png")
            {
                AmbientColor = Color.White * 0.4f
            };
            int baseSize = 5;
            float ySeparation = 1.5f;
            float xSeparation = 1.1f;

            for (int i = 0; i < baseSize; i++)
            {
                for (int j = baseSize - i - 1; j >= 0; j--)
                {
                    float xOffset = -(baseSize - i - 1) / 2f;
                    var cratePosition = new Vector3(xSeparation * (j + xOffset), ySeparation * i + 1, 0);
                    // Draw a cube
                    Entity crate = new Entity() { Tag = "Removable" }
                        .AddComponent(new Transform3D() { LocalPosition = cratePosition })
                        .AddComponent(new Model("Content/Models/crate.FBX"))
                        .AddComponent(new BoxCollider() { })
                        .AddComponent(new RigidBody3D() { CollisionGroup = this.sceneGroup })
                        .AddComponent(new MaterialsMap(crateMaterial))
                        .AddComponent(new ModelRenderer());

                    EntityManager.Add(crate);
                }
            }
        }