private void CreateTestScene()
        {
            CallerCube convexHull = new CallerCube();

            convexHull.SetModel("GLTFHULL");
            convexHull.SetScale(2);
            convexHull.SetPosition(0, 1, 0);
            //convexHull.SetColor(0, 1, 0);
            convexHull.IsCollisionObject = true;
            convexHull.Name = "Hull #1";
            AddGameObject(convexHull);

            Immovable convexHull2 = new Immovable();

            convexHull2.SetModel("KWSphere");
            convexHull2.SetScale(1f); //, 2, 1);
            convexHull2.SetPosition(1, 2.5f, 0);
            convexHull2.SetColor(1, 0, 0);
            convexHull2.AddRotationX(45, true);
            convexHull2.AddRotationZ(45, true);
            convexHull2.IsCollisionObject = true;
            convexHull2.Name = "Hull #2";
            AddGameObject(convexHull2);
        }
Example #2
0
        public override void Prepare()
        {
            KWEngine.LoadModelFromFile("Robot", @".\models\UBot\ubot.fbx");
            KWEngine.LoadModelFromFile("Lab", @".\models\labyrinth\walls.obj");
            KWEngine.LoadModelFromFile("Panel", @".\models\spacepanel\scifipanel.obj");
            KWEngine.LoadModelFromFile("Spaceship", @".\models\spaceship\spaceship4.obj");

            KWEngine.BuildTerrainModel("Terrain", @".\textures\heightmap.png", @".\textures\sand_diffuse.dds", 100, 2, 100, 5, 5);

            SetAmbientLight(0, 0.25f, 1f, 0.25f);
            SetCameraPosition(100, 100, 100);
            WorldDistance = 1000;

            Immovable ship = new Immovable();

            ship.SetModel("Spaceship");
            ship.IsCollisionObject = true;
            ship.IsShadowCaster    = true;
            ship.SetPosition(-35, 3.5f, -25);
            ship.SetScale(15);
            ship.AddRotationZ(25, true);
            ship.AddRotationX(40, true);
            AddGameObject(ship);

            Immovable floor = new Immovable();

            floor.SetModel("Terrain");
            floor.IsCollisionObject = true;
            floor.IsShadowCaster    = true;
            floor.SetTexture(@".\textures\sand_normal.dds", TextureType.Normal);
            AddGameObject(floor);

            Immovable wallLeft1 = new Immovable();

            wallLeft1.Name = "WallLeft";
            wallLeft1.SetModel("KWCube");
            wallLeft1.IsCollisionObject = true;
            wallLeft1.IsShadowCaster    = true;
            wallLeft1.SetScale(2, 10, 100);
            wallLeft1.SetPosition(-49, 5, 0);
            AddGameObject(wallLeft1);

            Immovable wallRight = new Immovable();

            wallRight.Name = "WallRight";
            wallRight.SetModel("KWCube");
            wallRight.IsCollisionObject = true;
            wallRight.IsShadowCaster    = true;
            wallRight.SetScale(2, 10, 100);
            wallRight.SetPosition(49, 5, 0);
            AddGameObject(wallRight);

            Immovable wallFront = new Immovable();

            wallFront.Name = "WallFront";
            wallFront.SetModel("KWCube");
            wallFront.IsCollisionObject = true;
            wallFront.IsShadowCaster    = true;
            wallFront.SetScale(100, 10, 2);
            wallFront.SetPosition(0, 5, 49);
            AddGameObject(wallFront);

            Immovable wallBack = new Immovable();

            wallBack.Name = "WallBack";
            wallBack.SetModel("KWCube");
            wallBack.IsCollisionObject = true;
            wallBack.IsShadowCaster    = true;
            wallBack.SetScale(100, 10, 2);
            wallBack.SetPosition(0, 5, -49);
            AddGameObject(wallBack);

            p = new Player();
            p.SetModel("Robot");
            p.Name = "Player";
            p.SetPosition(-5, 0f, -5);
            p.SetScale(4);
            p.AnimationID         = 0;
            p.AnimationPercentage = 0;
            p.IsShadowCaster      = true;
            p.IsCollisionObject   = true;
            p.IsPickable          = true;
            p.TurnTowardsXZ(new Vector3(0, 0, 0));
            //p.SetSpecularOverride(true, 8, 32);
            AddGameObject(p);
            //SetFirstPersonObject(p);

            p._flashlight = new LightObject(LightType.Directional, true);
            p._flashlight.SetColor(1, 0.75f, 0, 5f);
            p._flashlight.SetNearAndFarBounds(1f, 10);
            p._flashlight.SetFOV(150);
            //p._flashlight.SetFOVBiasCoefficient(0.025f);
            AddLightObject(p._flashlight);


            Immovable lab = new Immovable();

            lab.Name = "Labyrinth";
            lab.SetModel("Lab");
            lab.IsCollisionObject = true;
            lab.IsShadowCaster    = true;
            //lab.SetSpecularOverride(true, 0, 2048);
            AddGameObject(lab);

            Panel panel = new Panel();

            panel.Name = "Panel";
            panel.SetModel("Panel");
            panel.SetPosition(10, 0.25f, -5);
            panel.SetScale(3);
            //panel.SetSpecularOverride(true, 2, 1024);
            //panel.SetTextureForMesh(0, @".\models\spacepanel\scifipanel2.png");
            panel.IsShadowCaster    = true;
            panel.IsPickable        = true;
            panel.IsCollisionObject = true;
            AddGameObject(panel);

            /*
             * PanelLight pLight = new PanelLight();
             * pLight.Type = LightType.Directional;
             * pLight.SetColor(1, 1, 1, 1);
             * pLight.SetPosition(10, 5, -5);
             * pLight.SetTarget(10, 0, -5);
             * pLight.SetDistanceMultiplier(5f);
             * AddLightObject(pLight);
             */

            LightObject sun = new LightObject(LightType.Sun, true);

            sun.SetPosition(125, 200, -125);
            sun.SetTarget(0, 0, 0);
            sun.SetFOV(140);
            sun.SetNearAndFarBounds(100, 400);
            sun.SetColor(0, 0.5f, 1.0f, 0.5f);
            AddLightObject(sun);

            HUDObject ho = new HUDObject(HUDObjectType.Text, 24, 24);

            ho.SetText("kwengine.de");
            ho.SetGlow(1, 0, 0, 1);
            ho.SetRotation(0, 0);
            AddHUDObject(ho);

            //DebugShadowLight = sun;

            DebugShowHitboxes           = false;
            DebugShowPerformanceInTitle = PerformanceUnit.FramesPerSecond;
            if (IsFirstPersonMode)
            {
                FOV = 90;
            }
            else
            {
                FOV = 45;
            }
        }