예제 #1
0
 public EnvironmentEntities(string modelPath, string texturePath, string normalMapPath, string specularMapPath, string[] cubemapEnvMap,
                            Vector3 translation = new Vector3(), Vector3 rotation = new Vector3(), Vector3 scale = new Vector3())
     : base(modelPath, texturePath, normalMapPath, specularMapPath, translation, rotation, scale)
 {
     this.m_envMap = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(cubemapEnvMap[0] + "," + cubemapEnvMap[1] + "," + cubemapEnvMap[2] + "," +
                                                                                                          cubemapEnvMap[3] + "," + cubemapEnvMap[4] + "," + cubemapEnvMap[5]);
 }
예제 #2
0
        private void PostConstructor()
        {
            if (m_bPostConstructor)
            {
                m_shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <SkyboxShader>, string, SkyboxShader>(ProjectFolders.ShadersPath + "skyboxVS.glsl" + "," +
                                                                                                                                 ProjectFolders.ShadersPath + "skyboxFS.glsl");

                float[,] vertices = new float[6 * 6, 3] {
                    { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE },
                    { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE },
                    { -SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE },
                    { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE },
                    { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE },
                    { -SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE },
                    { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE },
                    { SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, SKYBOX_SIZE }, { -SKYBOX_SIZE, SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE },
                    { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { SKYBOX_SIZE, -SKYBOX_SIZE, -SKYBOX_SIZE }, { -SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE },
                    { SKYBOX_SIZE, -SKYBOX_SIZE, SKYBOX_SIZE }
                };

                VertexBufferObjectTwoDimension <float> verticesVBO = new VertexBufferObjectTwoDimension <float>(vertices, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                m_buffer = new VertexArrayObject();
                m_buffer.AddVBO(verticesVBO);
                m_buffer.BindBuffersToVao();

                m_bPostConstructor = !m_bPostConstructor;
            }
        }
예제 #3
0
        public static ITexture CopyTexture(ITexture src)
        {
            ITexture dst = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(src.GetTextureParameters());

            var renderTarget = GL.GenFramebuffer();

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, renderTarget);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, src.GetTextureParameters().TexTarget, dst.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);

            //GL.Disable(EnableCap.DepthTest);
            GL.Viewport(0, 0, src.GetTextureRezolution().X, src.GetTextureRezolution().Y);
            // start copy texture to render target
            copyShader.startProgram();
            src.BindTexture(TextureUnit.Texture0);
            copyShader.SetUniformValues(0);
            var quadBuffer = ScreenQuad.GetScreenQuadBuffer();

            quadBuffer.RenderVAO(PrimitiveType.Triangles);
            copyShader.stopProgram();
            GL.Enable(EnableCap.DepthTest);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            GL.DeleteFramebuffer(renderTarget);

            return(dst);
        }
예제 #4
0
        private void PostConstructor()
        {
            if (this.m_postConstructor)
            {
                float[,] vertices = new float[6, 3] {
                    { -1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, -1.0f }, { 1.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, 1.0f }
                };
                float[,] normals = new float[6, 3] {
                    { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }
                };
                float[,] texCoords = new float[6, 2] {
                    { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, 0 }, { 0, 0 }, { 0, 1 }
                };

                VertexBufferObjectTwoDimension <float> verticesVBO   = new VertexBufferObjectTwoDimension <float>(vertices, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Store);
                VertexBufferObjectTwoDimension <float> normalsVBO    = new VertexBufferObjectTwoDimension <float>(normals, BufferTarget.ArrayBuffer, 1, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                VertexBufferObjectTwoDimension <float> texCoordsVBO  = new VertexBufferObjectTwoDimension <float>(texCoords, BufferTarget.ArrayBuffer, 2, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                VertexBufferObjectTwoDimension <float> tangentsVBO   = new VertexBufferObjectTwoDimension <float>(VectorMath.AdditionalVertexInfoCreator.CreateTangentVertices(vertices, texCoords), BufferTarget.ArrayBuffer, 3, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                VertexBufferObjectTwoDimension <float> bitangentsVBO = new VertexBufferObjectTwoDimension <float>(VectorMath.AdditionalVertexInfoCreator.CreateBitangentVertices(vertices, texCoords), BufferTarget.ArrayBuffer, 4, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);

                m_buffer = new VertexArrayObject();
                m_buffer.AddVBO(verticesVBO, normalsVBO, texCoordsVBO, tangentsVBO, bitangentsVBO);
                m_buffer.BindBuffersToVao();

                m_shader            = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WaterShader>, string, WaterShader>(ProjectFolders.ShadersPath + "waterVS.glsl" + "," + ProjectFolders.ShadersPath + "waterFS.glsl");
                m_stencilPassShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <StencilPassShader>, string, StencilPassShader>(ProjectFolders.ShadersPath + "stencilPassVS.glsl" + "," + ProjectFolders.ShadersPath + "stencilPassFS.glsl");

                this.m_fbo             = new WaterFBO();
                this.m_postConstructor = !this.m_postConstructor;
            }
        }
예제 #5
0
        public WaterPlane(string distortionMap, string normalMap, Vector3 translation, Vector3 rotation, Vector3 scaling,
                          WaterQuality quality, Int32 frustumSquares = 0)
        {
            m_waterDistortionMap = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(distortionMap);
            m_waterNormalMap     = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(normalMap);
            m_frustumSquares     = frustumSquares;

            m_translation = translation;
            m_rotation    = rotation;
            m_scaling     = scaling;
            /*Nominal water coords*/

            m_moveFactor        = 0.0f;
            m_waveSpeed         = 0.1f;
            m_waveStrength      = 0.04f;
            m_transparencyDepth = 10000f;
            /*First pass post constructor*/
            this.m_postConstructor = true;
            this.Quality           = quality;
            m_collisionCheckPoints = null;
            m_modelMatrix          = Matrix4.Identity;
            m_modelMatrix         *= Matrix4.CreateRotationX(MathHelper.DegreesToRadians(m_rotation.X));
            m_modelMatrix         *= Matrix4.CreateRotationY(MathHelper.DegreesToRadians(m_rotation.Y));
            m_modelMatrix         *= Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(m_rotation.Z));
            m_modelMatrix         *= Matrix4.CreateScale(m_scaling);
            m_modelMatrix         *= Matrix4.CreateTranslation(m_translation);
            InitPhysics();
        }
예제 #6
0
        private void InitResources(string texture1, string texture2)
        {
            float[,] vertices = new float[6, 3] {
                { -(SUN_SIZE / 2), SUN_SIZE / 2, 0.0f }, { -(SUN_SIZE / 2), -(SUN_SIZE / 2), 0.0f }, { SUN_SIZE / 2, -(SUN_SIZE / 2), 0.0f }, { SUN_SIZE / 2, -(SUN_SIZE / 2), 0.0f }, { SUN_SIZE / 2, SUN_SIZE / 2, 0.0f }, { -(SUN_SIZE / 2), SUN_SIZE / 2, 0.0f }
            };
            float[,] normals = new float[6, 3] {
                { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }
            };
            float[,] texCoords = new float[6, 2] {
                { 0, 0 }, { 1, 0 }, { 1, 1 }, { 1, 1 }, { 0, 1 }, { 0, 0 }
            };

            VertexBufferObjectTwoDimension <float> verticesVBO  = new VertexBufferObjectTwoDimension <float>(vertices, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
            VertexBufferObjectTwoDimension <float> normalsVBO   = new VertexBufferObjectTwoDimension <float>(normals, BufferTarget.ArrayBuffer, 1, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
            VertexBufferObjectTwoDimension <float> texCoordsVBO = new VertexBufferObjectTwoDimension <float>(texCoords, BufferTarget.ArrayBuffer, 2, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate);

            m_buffer = new VertexArrayObject();
            m_buffer.AddVBO(verticesVBO, normalsVBO, texCoordsVBO);
            m_buffer.BindBuffersToVao();

            m_shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <SunShader>, string, SunShader>(ProjectFolders.ShadersPath + "sunVS.glsl" + "," + ProjectFolders.ShadersPath + "sunFS.glsl");

            m_texture1 = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(texture1);
            m_texture2 = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(texture2);

            m_quadLBZ = new Vector4((-SUN_SIZE / 2), (-SUN_SIZE / 2), 0.0f, 1.0f);
            m_quadRTZ = new Vector4((SUN_SIZE / 2), (SUN_SIZE / 2), 0.0f, 1.0f);
        }
예제 #7
0
        public void Render(Matrix4 viewMatrix, Matrix4 projectionMatrix)
        {
            if (bPostConstructor)
            {
                shader  = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <SkyboxShader>, string, SkyboxShader>(String.Format("{0}{1},{0}{2}", ProjectFolders.ShadersPath, "skyboxVS.glsl", "skyboxFS.glsl"));
                model   = new RawModel(attribs);
                cubemap = ProxyTextureLoader.LoadCubemap(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"
                });


                bPostConstructor = false;
            }

            shader.startProgram();
            cubemap.BindTexture(OpenTK.Graphics.OpenGL.TextureUnit.Texture0);
            shader.SetTransformationMatrices(Matrix4.Identity, viewMatrix, projectionMatrix);
            shader.SetCubemap(0);
            VAOManager.renderBuffers(model.Buffer, OpenTK.Graphics.OpenGL.PrimitiveType.Triangles);
            shader.stopProgram();
        }
예제 #8
0
 private void Init(string[] dayTextures, string[] nightTextures)
 {
     m_moveFactor       = 0.0f;
     m_skyboxDayTexture = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(dayTextures[0] + "," + dayTextures[1] + "," + dayTextures[2] + "," +
                                                                                                               dayTextures[3] + "," + dayTextures[4] + "," + dayTextures[5]);
     m_skyboxNightTexture = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(nightTextures[0] + "," + nightTextures[1] + "," + nightTextures[2] + "," +
                                                                                                                 nightTextures[3] + "," + nightTextures[4] + "," + nightTextures[5]);
     m_bPostConstructor = true;
 }
예제 #9
0
 private void InitResources(string modelPath, string texturePath, string normalMapPath, string specularMapPath)
 {
     m_lightVisibilityMap = new BoolMap();
     m_texture            = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(texturePath);
     m_normalMap          = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(normalMapPath);
     m_specularMap        = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(specularMapPath);
     m_skin = PoolProxy.GetResource <ObtainModelPool, ModelAllocationPolicy, string, Skin>(modelPath);
     InitShader();
 }
예제 #10
0
        protected override void setTextures()
        {
            RadialBlurAppliedTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                                                                                                                       0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                                                                                                                       EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));

            LightShaftsResultTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb,
                                                                                                                                                                       EngineStatics.globalSettings.DomainFramebufferRezolution.X, EngineStatics.globalSettings.DomainFramebufferRezolution.Y, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));
        }
예제 #11
0
 private void postConstructor()
 {
     if (bPostConstructor)
     {
         renderTarget     = new LightShaftFramebufferObject();
         shader           = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <LightShaftShader <SubsequenceType> >, string, LightShaftShader <SubsequenceType> >(ProjectFolders.ShadersPath + "lightShaftsVS.glsl" + "," + ProjectFolders.ShadersPath + "lightShaftsFS.glsl");
         bPostConstructor = false;
     }
 }
        private void PostConstructor()
        {
            if (bPostConstructor)
            {
                renderTarget = new DepthOfFieldFramebufferObject();
                dofShader    = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <DepthOfFieldShader <SubsequenceType> >, string, DepthOfFieldShader <SubsequenceType> >(ProjectFolders.ShadersPath + "depthOfFieldVS.glsl" + "," + ProjectFolders.ShadersPath + "depthOfFieldFS.glsl");

                bPostConstructor = false;
            }
        }
예제 #13
0
        private void PostConstructor()
        {
            if (_postConstructor)
            {
                _buffer = ScreenQuad.GetScreenQuadBuffer();

                _shader          = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <UiFrameShader>, string, UiFrameShader>(ProjectFolders.ShadersPath + "uiVS.glsl," + ProjectFolders.ShadersPath + "uiFS.glsl");
                _postConstructor = false;
            }
        }
예제 #14
0
 private void postConstructor(Landscape terrain = null)
 {
     if (this._postConstructor)
     {
         if (_shader == null)
         {
             _shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <PlantShader>, string, PlantShader>(ProjectFolders.ShadersPath + "plantVertexShader.glsl" + "," + ProjectFolders.ShadersPath + "plantFragmentShader.glsl");
         }
         this._postConstructor = false;
     }
 }
        private bool TryLoadAnimation(string modelPath)
        {
            if (m_skin as AnimatedSkin == null)
            {
                throw new ArgumentException("Mesh that is loaded doesn't support animation.");
            }

            m_animations = PoolProxy.GetResource <ObtainAnimationPool, AnimationAllocationPolicy, string, List <AnimationSequence> >(modelPath);

            return(true);
        }
예제 #16
0
        public SkeletonDummy(string pathToAnimatedMesh)
        {
            m_skeletonShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <SkeletonShader>, string, SkeletonShader>
                                   (String.Format("{0}{1},{0}{2},{0}{3}", ProjectFolders.ShadersPath, "skeletonVS.glsl", "skeletonFS.glsl"));

            m_skeletonVAO = new VertexArrayObject();
            InitBonesVAO();

            m_animations      = PoolProxy.GetResource <ObtainAnimationPool, AnimationAllocationPolicy, string, List <AnimationSequence> >(pathToAnimatedMesh);
            m_animationHolder = new AnimationHolder(m_animations);
            m_animationHolder.SetAnimationByNameNoBlend(m_animations[0].GetName());
        }
예제 #17
0
        protected override void InitShader()
        {
            m_shader        = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <StaticEntityShader>, string, StaticEntityShader>(ProjectFolders.ShadersPath + "buildingVShader.glsl" + "," + ProjectFolders.ShadersPath + "buildingFShader.glsl");
            m_specialShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <SpecialStaticEntityShader>, string, SpecialStaticEntityShader>(ProjectFolders.ShadersPath + "buildingSpecialVShader.glsl" + "," +
                                                                                                                                                              ProjectFolders.ShadersPath + "buildingSpecialFShader.glsl" + "," + ProjectFolders.ShadersPath + "buildingSpecialGShader.glsl");

            m_liteReflectionShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WaterReflectionEntityShader>, string, WaterReflectionEntityShader>(ProjectFolders.ShadersPath + "waterReflectionEntityVS.glsl" + "," +
                                                                                                                                                                         ProjectFolders.ShadersPath + "waterReflectionEntityFS.glsl");

            m_liteRefractionShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WaterRefractionEntityShader>, string, WaterRefractionEntityShader>(ProjectFolders.ShadersPath + "waterRefractionEntityVS.glsl" + "," +
                                                                                                                                                                         ProjectFolders.ShadersPath + "waterRefractionEntityFS.glsl");
        }
예제 #18
0
        private void PostConstructor()
        {
            if (this.m_bPostConstructor)
            {
                _shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <LandscapeShader>, string, LandscapeShader>(string.Format("{0}{1},{0}{2}", ProjectFolders.ShadersPath, "terrainVertexShader.glsl", "terrainFragmentShader.glsl"));
                liteReflectionShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WaterReflectionTerrainShader>, string, WaterReflectionTerrainShader>(string.Format("{0}{1},{0}{2}", ProjectFolders.ShadersPath, "waterReflectionTerrainVS.glsl", "waterReflectionTerrainFS.glsl"));
                liteRefractionShader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WaterRefractionTerrainShader>, string, WaterRefractionTerrainShader>(string.Format("{0}{1},{0}{2}", ProjectFolders.ShadersPath, "waterRefractionTerrainVS.glsl", "waterRefractionTerrainFS.glsl"));

                _buffer = LandscapeBuilder.getTerrainAttributes(this.LandscapeMap, this._normalsSmoothLvl);
                this.m_bPostConstructor = !this.m_bPostConstructor;
            }
        }
예제 #19
0
        protected override void setTextures()
        {
            /*Create 3 textures :
             * 1 - for reflection
             * 2 - for refraction
             * 3 - for depth*/

            ReflectionTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb, (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.X / 1.5), (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 1.5), PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));
            RefractionTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb, (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.X / 1.5), (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 1.5), PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));
            DepthTexture      = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Depth24Stencil8,
                                                                                                                                                                (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.X / 1.5f), (Int32)(EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 1.5f), PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat));
        }
예제 #20
0
        public WorldGrid(float farPlaneDistance)
        {
            m_farPlaneDistance = farPlaneDistance;
            m_shader           = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <WorldGridShader>, string, WorldGridShader>(string.Format("{0}gridVS.glsl,{0}gridFS.glsl", ProjectFolders.ShadersPath));

            m_vao = new VertexArrayObject();
            VertexBufferObjectBase verticesVBO = null;

            GenVertices(ref verticesVBO);
            m_vao.AddVBO(verticesVBO);
            m_vao.BindBuffersToVao();
        }
예제 #21
0
        protected Landscape(SerializationInfo info, StreamingContext context)
        {
            m_bPostConstructor = true;
            MapSize            = info.GetSingle("MapSize");
            MaximumHeight      = info.GetSingle("MaximumHeight");

            string pathTexR        = info.GetString("pathTexR");
            string pathTexG        = info.GetString("pathTexG");
            string pathTexB        = info.GetString("pathTexB");
            string pathTexBlack    = info.GetString("pathTexBlack");
            string pathTexBlendMap = info.GetString("pathTexBlendMap");

            m_heightMapTexPath = info.GetString("m_heightMapTexPath");
            InitTextures(pathTexR, pathTexG, pathTexB, pathTexBlack, pathTexBlendMap);

            // normal map red channel
            bool bNormalR = info.GetBoolean("bNormalR");

            if (bNormalR)
            {
                string pathTexNormalMapR = info.GetString("pathTexNormalMapR");
                _normalMapR = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexNormalMapR);
            }

            // normal map green channel
            bool bNormalG = info.GetBoolean("bNormalR");

            if (bNormalG)
            {
                string pathTexNormalMapG = info.GetString("pathTexNormalMapG");
                _normalMapG = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexNormalMapG);
            }

            // normal map blue channel
            bool bNormalB = info.GetBoolean("bNormalB");

            if (bNormalB)
            {
                string pathTexNormalMapB = info.GetString("pathTexNormalMapB");
                _normalMapB = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexNormalMapB);
            }

            // normal map black channel
            bool bNormalBlack = info.GetBoolean("bNormalR");

            if (bNormalBlack)
            {
                string pathTexNormalMapBlack = info.GetString("pathTexNormalMapBlack");
                _normalMapBlack = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexNormalMapBlack);
            }
        }
예제 #22
0
 private void PostConstructor()
 {
     if (bPostConstructor)
     {
         if ((new ObtainModelPool().GetPool() as ModelPool).GetModelReferenceCount("CollisionBound") == 0)
         {
             AddBoundModelToRoot();
         }
         else
         {
             skin = PoolProxy.GetResource <ObtainModelPool, ModelAllocationPolicy, string, Skin>("CollisionBound");
         }
         bPostConstructor = false;
     }
 }
        private void postConstructor()
        {
            if (_postConstructor)
            {
                this._shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <PointLightDebugShader>, string, PointLightDebugShader>(ProjectFolders.ShadersPath + "lampVS.glsl" + "," + ProjectFolders.ShadersPath + "lampFS.glsl" + "," + ProjectFolders.ShadersPath + "lampGS.glsl");

                float[,] vertices = new float[1, 3];

                VertexBufferObjectTwoDimension <float> verticesVBO = new VertexBufferObjectTwoDimension <float>(vertices, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                _buffer = new VertexArrayObject();
                _buffer.AddVBO(verticesVBO);
                _buffer.BindBuffersToVao();
                _postConstructor = false;
            }
        }
예제 #24
0
        //

        public PlantReadyMaster(IEnumerable <PlantUnit> plants, VBOArrayF modelAttribs, string[] textureSets, WindComponent component)
        {
            SetMemento(plants);
            this._postConstructor = true;
            this._texture         = new List <ITexture>();
            foreach (var item in textureSets)
            {
                _texture.Add(PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(item));
            }
            this._attribs       = modelAttribs;
            this._wind          = component;
            this._grassMaterial = new Material(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                                               new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), 10.0f, 1.0f);
            this._meshCenter = GetCenter();
        }
예제 #25
0
        private void postConstructor(Landscape terrain = null)
        {
            if (this._postConstructor)
            {
                AlignPlantsToTerrain(terrain);
                this._attribs = PlantUserAttributeBuilder.BuildReadyUserAttributeBuffer(_plants, _attribs);
                _buffer       = new VAO(_attribs);

                VAOManager.genVAO(_buffer);
                VAOManager.setBufferData(BufferTarget.ArrayBuffer, _buffer);

                _shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <PlantShader>, string, PlantShader>(ProjectFolders.ShadersPath + "plantVertexShader.glsl" + "," + ProjectFolders.ShadersPath + "plantFragmentShader.glsl");
                this._postConstructor = !this._postConstructor;
            }
        }
        private void InitFramebuffer(Int32 WidthRezolution, Int32 HeightRezolution)
        {
            var ColorTextureParams        = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb, WidthRezolution, HeightRezolution, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);
            var DepthStencilTextureParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Depth24Stencil8, WidthRezolution, HeightRezolution, PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat);

            ColorTexture        = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(ColorTextureParams);
            DepthStencilTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(DepthStencilTextureParams);

            FramebufferDescriptor = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, FramebufferDescriptor);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, ColorTexture.GetTextureDescriptor(), 0);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2D, DepthStencilTexture.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            GL.ReadBuffer(ReadBufferMode.None);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
        protected override void setTextures()
        {
            var verticalBlurRederTargetParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                      0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                      EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            var horizontalBlurRenderTargetParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                         0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                         EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            var depthOfFieldRenderTargetPrams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb,
                                                                      EngineStatics.globalSettings.DomainFramebufferRezolution.X, EngineStatics.globalSettings.DomainFramebufferRezolution.Y, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            VerticalBlurTexture       = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(verticalBlurRederTargetParams);
            HorizontalBlurTexture     = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(horizontalBlurRenderTargetParams);
            DepthOfFieldResultTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(depthOfFieldRenderTargetPrams);
        }
예제 #28
0
 public PlantBuilderMaster(Int32 init_buffer_size, string pathToModel, string[] textureSets, WindComponent component)
 {
     this.INIT_BUFFER_SIZE = init_buffer_size;
     this._plants          = new List <PlantUnit>();
     this._bufferAssembled = false;
     this._postConstructor = true;
     _texture = new List <ITexture>();
     foreach (var item in textureSets)
     {
         _texture.Add(PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(item));
     }
     this._buffer        = AllocateVaoMemory(pathToModel);
     this._wind          = component;
     this._grassMaterial = new Material(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                                        new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), 10.0f, 1.0f);
     this._meshCenter = GetCenter();
 }
예제 #29
0
        protected override void setTextures()
        {
            /* Img 1 - vertical blur stage image;
             * Img 2 - horizontal blur stage image;
             * Img 3 - texture with low rezolution for bright parts of sun;
             * Img 4 - lens flare result texture */

            verticalBlurTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                                                                                                                  0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                                                                                                                  EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));

            horizontalBlurTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                                                                                                                    0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                                                                                                                    EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));

            frameTextureLowRezolution = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear, 0, PixelInternalFormat.Rgb,
                                                                                                                                                                        EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10, EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));

            lensFlareResultTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb,
                                                                                                                                                                     EngineStatics.globalSettings.DomainFramebufferRezolution.X, EngineStatics.globalSettings.DomainFramebufferRezolution.Y, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat));
        }
예제 #30
0
        private void InitTextures(string pathTexR, string pathTexG, string pathTexB, string pathTexBlack, string pathTexBlendMap)
        {
            this._textureR     = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexR);
            this._textureG     = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexG);
            this._textureB     = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexB);
            this._textureBlack = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexBlack);
            this._blendMap     = PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(pathTexBlendMap);

            try
            {
                using (var map = new Bitmap(m_heightMapTexPath))
                {
                    LandscapeMap = new TableGrid(map.Height, MapSize / map.Height);
                    LandscapeBuilder.loadHeightMap(map, this);
                }
            }
            catch (ArgumentException ef)
            {
                Debug.Log.AddToFileStreamLog("Terrain height map file load error : " + ef.Message);
                System.Environment.Exit(0);
            }
        }