Пример #1
0
        public void init()
        {
            sunLight = new LightSun(new Vector3(0.1f, 0.125f, 0.2f) * 3f, this);
            sunLight.lightAmbient = new Vector3(0.1f, 0.125f, 0.2f) * 0.5f;//new Vector3(0.2f, 0.125f, 0.1f);//new Vector3(0.1f, 0.14f, 0.3f);
            sunLight.PointingDirection = Vector3.Normalize(new Vector3(674, -674, 1024));
            sunFrameBuffer = gameWindow.framebufferCreator.createFrameBuffer("shadowFramebuffer", shadowRes * 2, shadowRes * 2, PixelInternalFormat.Rgba8, false);
            sunInnerFrameBuffer = gameWindow.framebufferCreator.createFrameBuffer("shadowFramebuffer", shadowRes * 2, shadowRes * 2, PixelInternalFormat.Rgba8, false);

            mFilter2d = new Quad2d(this);

            mSkyModel = new Skybox(this, gameWindow);

            mGroundPlane = new GroundPlane(this);
            mGroundPlane.setMaterial("floor.xmf");

            mGroundPlane.setMesh("water_plane.obj");
            mGroundPlane.setMaterial("floor.xmf");

            //need to be fixed -- cant be executed after voxel Manager creation.

            if(Settings.Instance.video.Particles)
                generateParticleSys();

            voxelManager = new VoxelManager(this);

            compositeMod.X = Settings.Instance.video.gamma;

            particleAffectors.Add(new ParticleAffectorWind(new Vector3(1,-0.5f,0) * 0.01f));
            particleAffectors.Add(new ParticleAffectorFriction(0.1f));
            particleAffectors.Add(new ParticleAffectorFloorKiller(waterLevel));
            particleAffectors.Add(new ParticleAffectorLifeTimeKiller(this));

            /*
                waterModel.setTextures(mTextureLoader.fromMixed(new int[]{
                TextureGroup.TYPE_FRAMEBUFFER,
                TextureGroup.TYPE_FROMFILE},
                new string[] {
                    Convert.ToString(waterFramebuffer.ColorTexture),
                    "noise.png"}));
             */

            mGroundPlane.Position = new Vector3(0,waterLevel,0);
            //mGroundPlane.updateModelMatrix();

            Matrix4 translate = Matrix4.CreateTranslation(0, -waterLevel * 2, 0);
            Matrix4 invert = Matrix4.Scale(1, -1, 1);
            Matrix4.Mult(ref translate, ref invert, out mWaterMatrix);
        }
Пример #2
0
        protected override void OnLoad(System.EventArgs e)
        {
            //generate stopwatch
            sw = new Stopwatch();

            //set size of the render
            virtual_size = new Vector2(1920, 1080);

            state = new GameState();

            string versionOpenGL = GL.GetString(StringName.Version);
            log(versionOpenGL);

            // make the Coursor disapear
            Cursor.Hide();

            // center it on the window
            Cursor.Position = new Point(
                (Bounds.Left + Bounds.Right) / 2,
                (Bounds.Top + Bounds.Bottom) / 2);

            // other state
            GL.ClearColor(System.Drawing.Color.Black);
            VSync = VSyncMode.On;
            screenSize = new Vector2(Width, Height);

            // create instances of necessary objects
            textureLoader = new TextureLoader(this);
            framebufferCreator = new FramebufferCreator(this);
            meshLoader = new MeshLoader(this);
            shaderLoader = new ShaderLoader(this);
            materialLoader = new MaterialLoader(this);
            templateLoader = new TemplateLoader(this);

            mScene = new Scene(this);

            // create gameInput
            gameInput = new GameInput(mScene, Keyboard, Mouse);

            // set files for displaying loading screen
            shaderLoader.fromXmlFile("shaders\\composite.xsp");

            shaderLoader.fromTextFile("shaders\\composite.vs", "shaders\\splash_shader.fs");

            meshLoader.fromObj("models\\sprite_plane.obj");

            textureLoader.fromFile("materials\\ultra_engine_back.png",true);
            textureLoader.fromFile("materials\\ultra_engine_back_h.png",true);

            materialLoader.fromXmlFile("materials\\composite.xmf");

            //loading noise manualy so we can disable multisampling
            textureLoader.fromFile("materials\\noise_pixel.png", false);

            // load files for loading screen
            textureLoader.LoadTextures();
            meshLoader.loadMeshes();
            shaderLoader.loadShaders();
            materialLoader.loadMaterials();

            // setup 2d filter (loading screen)
            splashFilter2d = new Quad2d(this);

            // set time to zero
            spawnTime = get_time();
        }
Пример #3
0
        public void init()
        {
            mFilter2d = new Quad2d(this);

            mSkyModel = new Skybox(this, gameWindow);

            mGroundPlane = new GroundPlane(this);
            mGroundPlane.setMaterial("floor.xmf");

            mGroundPlane.setMesh("water_plane.obj");
            mGroundPlane.setMaterial("floor.xmf");

            //need to be fixed -- cant be executed after voxel Manager creation.
            generateParticleSys();

            voxelManager = new VoxelManager(this);

            particleAffectors.Add(new ParticleAffectorWind(new Vector3(1,-0.5f,0) * 0.01f));
            particleAffectors.Add(new ParticleAffectorFriction(0.1f));
            particleAffectors.Add(new ParticleAffectorFloorKiller(waterLevel));
            particleAffectors.Add(new ParticleAffectorLifeTimeKiller(this));

            /*
                waterModel.setTextures(mTextureLoader.fromMixed(new int[]{
                TextureGroup.TYPE_FRAMEBUFFER,
                TextureGroup.TYPE_FROMFILE},
                new string[] {
                    Convert.ToString(waterFramebuffer.ColorTexture),
                    "noise.png"}));
             */

            mGroundPlane.Position = new Vector3(0,waterLevel,0);
            //mGroundPlane.updateModelMatrix();

            Matrix4 translate = Matrix4.CreateTranslation(0, -waterLevel * 2, 0);
            Matrix4 invert = Matrix4.Scale(1, -1, 1);
            Matrix4.Mult(ref translate, ref invert, out mWaterMatrix);
        }