コード例 #1
0
        public override void Init()
        {
            StaticSceneObjects.Clear();
            NonStaticSceneObjects.Clear();

            LightPosition      = new TGCVector3(0, 80000, -6 * skyBoxDimensions.X);
            lightBox           = TGCBox.fromSize(TGCVector3.One * 500, Color.Red);
            lightBox.Transform = TGCMatrix.Translation(LightPosition);

            InitFog();
            InitMainMeshes();
            InitHUD();
            LoadMainScene();
            ManageFocus();
            spawnManager = new SpawnManager(this);
            SetCamera();

            //DirectSound.ListenerTracking = Player.Meshes[0]; // Alguno de los meshes del player, cumplen con la interfaz ITransformObject

            LightPosition      = new TGCVector3(0, 8000, -5 * heightMaps[0].XZRadius);
            lightBox           = TGCBox.fromSize(TGCVector3.One * 500, Color.Red);
            lightBox.Transform = TGCMatrix.Translation(LightPosition);

            ScenesQuadTree.create(StaticSceneObjects, new TgcBoundingAxisAlignBox(SueloDelMar.centre - new TGCVector3(SueloDelMar.XZRadius, 3000, SueloDelMar.XZRadius), SueloDelMar.centre + new TGCVector3(SueloDelMar.XZRadius, 5000, SueloDelMar.XZRadius)));
            ScenesQuadTree.createDebugQuadTreeMeshes();

            InitFullQuadVB();
            InitAuxRenderTarget();
            InitGogleViewEffectResources();
            InitSounds();
            InitBubbleEmitter();

            InPrincipalMenu = true;
            FocusInGame     = false;
            MouseEnable();

            AmbientMusic.play(true);
        }
コード例 #2
0
        private void InitializerObjects()
        {
            FogShader = TGCShaders.Instance.LoadEffect(ShadersDir + "Shaders.fx");

            FogShader.SetValue("ColorFog", Color.SteelBlue.ToArgb());
            FogShader.SetValue("StartFogDistance", 2000);
            FogShader.SetValue("EndFogDistance", 10000);
            FogShader.SetValue("globalLightPosition", TGCVector3.TGCVector3ToFloat4Array(LightPosition));

            SetMaterialColors();

            /* Initializer object */
            LightBox    = TGCBox.fromSize(TGCVector3.One * 150, Color.White);
            Skybox      = new Skybox(MediaDir, Camera);
            Water       = new Water(MediaDir, ShadersDir, new TGCVector3(0, 3500, 0));
            Ship        = new Ship(MediaDir);
            ShowScene   = true;
            Terrain     = new Terrain(MediaDir, ShadersDir);
            MeshBuilder = new MeshBuilder(Terrain, Water);
            Shark       = new Shark(MediaDir, Skybox, Terrain, Camera, SoundManager);
            Character   = new Character(Camera, Input, SoundManager);
            Weapon      = new Weapon(MediaDir, Camera);
            Vegetation  = new Vegetation(MediaDir);
            Common      = new Common(MediaDir);
            Fishes      = Common.ListFishes.Select(mesh => new Fish(Skybox, Terrain, mesh)).ToList();
            Bubble      = new Bubble(MediaDir);
            AddWeaponToCharacter();

            /* Location */

            MeshBuilder.LocateMeshesInWorld(meshes: ref Vegetation.ListAlgas, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListCorals, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListOres, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListRock, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListFishes, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Bubble.Bubbles, area: Skybox.CurrentPerimeter);

            Common.LocateObjects();

            /* Add rigidBody to the world */

            PhysicalWorld = new PhysicalWorld();
            PhysicalWorld.AddBodyToTheWorld(Terrain.Body);
            PhysicalWorld.AddBodyToTheWorld(Character.Body);
            PhysicalWorld.AddBodyToTheWorld(Ship.BodyOutdoorShip);
            PhysicalWorld.AddBodyToTheWorld(Ship.BodyIndoorShip);
            PhysicalWorld.AddBodyToTheWorld(Shark.Body);
            Common.ListCorals.ForEach(coral => PhysicalWorld.AddBodyToTheWorld(coral.Body));
            Common.ListOres.ForEach(ore => PhysicalWorld.AddBodyToTheWorld(ore.Body));
            Common.ListRock.ForEach(rock => PhysicalWorld.AddBodyToTheWorld(rock.Body));
            AddRoofRigidBody();

            Bubble.SetShader(FogShader, "FogBubble");
            Skybox.SetShader(FogShader, "Fog");
            Common.SetShader(FogShader, "Fog");
            Shark.SetShader(FogShader, "Fog");
            Vegetation.SetShader(FogShader, "FogVegetation");
            Ship.SetShader(ref FogShader);

            LightBox.Transform = TGCMatrix.Translation(LightPosition);

            var meshes = GetStaticMeshes();

            QuadTree.Camera = Camera;
            QuadTree.create(meshes, Terrain.world.BoundingBox);
        }