コード例 #1
0
        private void SetLevelTestValues(Level level)
        {
            var globalLightShadowMapParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0,
                                                                   PixelInternalFormat.DepthComponent16, EngineStatics.globalSettings.ShadowMapRezolution.X, EngineStatics.globalSettings.ShadowMapRezolution.Y,
                                                                   PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat);

            level.DirectionalLight = new DirectionalLightWithShadow(level.Camera, globalLightShadowMapParams, new Vector3(-100, -10, 50), new Vector4(0.4f, 0.4f, 0.4f, 1),
                                                                    new Vector4(0.7f, 0.7f, 0.7f, 1.0f), new Vector4(1, 1, 1, 1));

            var dayPhases = new DayPhases(new Morning(new Vector3(0.3f, 0.3f, 0.3f), new Vector3(0.7f, 0.7f, 0.7f), new Vector3(.7f)),
                                          new DayPhases.Day(new Vector3(0.4f, 0.4f, 0.4f), new Vector3(0.9f, 0.79f, 0.79f), new Vector3(1.0f)),
                                          new Evening(new Vector3(0.3f, 0.3f, 0.3f), new Vector3(0.7f, 0.30f, 0.30f), new Vector3(0.9f)),
                                          new Night(new Vector3(0.09f, 0.09f, 0.09f), new Vector3(0.1f, 0.1f, 0.1f), new Vector3(0.0f)));

            level.DayCycle = new DayLightCycle(level.DirectionalLight,
                                               Math.Max(level.LevelSize.X, level.LevelSize.Y), dayPhases);
            level.DayCycle.SetTime(25);
            level.DayCycle.TimeFlow = 0.001f;

            level.Mist = new MistComponent(0.003f, 1f, new Vector3(0.7f, 0.75f, 0.8f));

            // temporary
            //level.terrain = new Landscape(level.MAP_SIZE, level.MAP_HEIGHT, 3,
            //       ProjectFolders.HeightMapsTexturesPath + "heightmap2.png",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/volcanictundrarocks01.jpg",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/tundra02.jpg",
            //       ProjectFolders.MultitexturesPath + "b.png",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/snow01.jpg",
            //       ProjectFolders.MultitexturesPath + "blendMap.png");

            //level.terrain.SetNormalMapR(ProjectFolders.MultitexturesPath + "NewLandscape/volcanictundrarocks01_n.png");
            //level.terrain.SetNormalMapG(ProjectFolders.MultitexturesPath + "NewLandscape/tundra02_n.png");
            ////level.Map.SetNormalMapBlack(ProjectFolders.MultitexturesPath + "NewLandscape/snow01_n.png");
            //level.terrain.SetNormalMapB(ProjectFolders.NormalMapsPath + "brick_nm_high.png");
            //level.terrain.SetMist(level.Mist);

            string modelPath       = ProjectFolders.ModelsPath + "house00.obj";
            string texturePath     = ProjectFolders.TextureAtlasPath + "houseDiffuse.jpg";
            string normalMapPath   = ProjectFolders.NormalMapsPath + "houseNormal.jpg";
            string specularMapPath = ProjectFolders.SpecularMapsPath + "brick_sm.png";

            StaticEntityArguments staticMeshArg = new StaticEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath,
                                                                            new Vector3(170, 13f + EngineStatics.MAP_HEIGHT, 170), new Vector3(0, 180, 0), new Vector3(20));
            var house1 = EngineObjectCreator.CreateInstance <Building>(staticMeshArg);

            level.StaticMeshCollection.AddToList(house1);

            DeserializeWrapper deserializer = new DeserializeWrapper();

            foreach (var item in level.StaticMeshCollection)
            {
                var inner_wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("house.cl");
                item.SetComponents(inner_wrapper.SerializedComponents);
                item.SetCollisionHeadUnit(CollisionHeadUnitObject);

                item.SetMistComponent(level.Mist);
            }

            modelPath       = ProjectFolders.ModelsPath + "playerCube.obj";
            texturePath     = ProjectFolders.MultitexturesPath + "path.png";
            normalMapPath   = ProjectFolders.NormalMapsPath + "brick_nm_high.png";
            specularMapPath = ProjectFolders.SpecularMapsPath + "brick_sm.png";

            MovableEntityArguments movableMeshArg = new MovableEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath, new Vector3(175, 1200, 170), new Vector3(0, 0, 0), new Vector3(4f));

            modelPath   = ProjectFolders.ModelsPath + "model.dae";
            texturePath = ProjectFolders.MultitexturesPath + "diffuse.png";

            level.SkeletalMesh = new MovableSkeletalMeshEntity(modelPath, texturePath, normalMapPath, specularMapPath, 0.5f, new Vector3(175, 60, 170), new Vector3(-90, 0, 0), new Vector3(1));

            level.Player.AddToWrapper(EngineObjectCreator.CreateInstance <MovableMeshEntity>(movableMeshArg));
            level.Player.GetData().SetMistComponent(level.Mist);

            var wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("2.cl");

            level.Player.GetData().SetComponents(wrapper.SerializedComponents);

            level.Player.GetData().SetCollisionHeadUnit(CollisionHeadUnitObject);
            level.Player.GetData().Speed = 0.6f;

            modelPath   = ProjectFolders.ModelsPath + "playerCube.obj";
            texturePath = ProjectFolders.MultitexturesPath + "b.png";

            movableMeshArg = new MovableEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath, new Vector3(180, 200, 220), new Vector3(0, 0, 0), new Vector3(10));

            var bot = EngineObjectCreator.CreateInstance <MovableMeshEntity>(movableMeshArg);

            bot.SetMistComponent(level.Mist);

            wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("2.cl");
            bot.SetComponents(wrapper.SerializedComponents);
            bot.SetCollisionHeadUnit(CollisionHeadUnitObject);
            level.Bots.AddToList(bot);
            movableMeshArg = null;

            level.Skybox = new SkyboxEntity(
                new string[] { ProjectFolders.SkyboxTexturesPath + "/Day/" + "right.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "left.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "top.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "bottom.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "back.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "front.bmp" },
                new string[] { ProjectFolders.SkyboxTexturesPath + "/Night/" + "right.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "left.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "top.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "bottom.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "back.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "front.png" });
            level.Skybox.setMistComponent(level.Mist);

            level.Water.AddToWrapper(new WaterPlane(ProjectFolders.WaterTexturePath + "DUDV.png", ProjectFolders.WaterTexturePath + "normal.png",
                                                    new Vector3(160, 29, 200), new Vector3(0, 0, 0), new Vector3(200, 1, 200), new WaterQuality(true, true, true), 10));

            level.SunRenderer.AddToWrapper(new SunRenderer(level.DirectionalLight, ProjectFolders.SunTexturePath + "sunC.png",
                                                           ProjectFolders.SunTexturePath + "sunB.png", 150, 130));

            // Set third person target
            ThirdPersonCamera thirdPersonCamera = (level.Camera as ThirdPersonCamera);

            thirdPersonCamera?.SetThirdPersonTarget(level.Player.GetData());

            //ch = new ComputeShader();
            //ch.Init();
        }
コード例 #2
0
 public PlayerController(ThirdPersonCamera camera)
 {
     keyboard     = new KeyboardHandler();
     playerCamera = camera;
 }