Exemple #1
0
        static ScreenQuad()
        {
            /*Screen fill quad*/
            float[,] vertices = new float[6, 3] {
                { -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, -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, OpenTK.Graphics.OpenGL.BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
            VertexBufferObjectTwoDimension <float> texCoordsVBO = new VertexBufferObjectTwoDimension <float>(texCoords, OpenTK.Graphics.OpenGL.BufferTarget.ArrayBuffer, 1, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate);

            quadBuffer = new VertexArrayObject();

            quadBuffer.AddVBO(verticesVBO, texCoordsVBO);
            quadBuffer.BindBuffersToVao();
        }
        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;
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
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);
        }
Exemple #5
0
        private VertexArrayObject AllocateVaoMemory(string path)
        {
            VertexArrayObject vao = null;

            using (AssimpModelLoader loader = new AssimpModelLoader(path))
            {
                MeshVertexData meshData = loader.GetMeshData();
                VertexBufferObjectTwoDimension <float> verticesVBO  = new VertexBufferObjectTwoDimension <float>(meshData.Verts, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                VertexBufferObjectTwoDimension <float> normalsVBO   = new VertexBufferObjectTwoDimension <float>(meshData.N_Verts, BufferTarget.ArrayBuffer, 1, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                VertexBufferObjectTwoDimension <float> texCoordsVBO = new VertexBufferObjectTwoDimension <float>(meshData.T_Verts, BufferTarget.ArrayBuffer, 2, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate);

                var transformationVboTuples = PlantUserAttributeBuilder.GetInstacedTransformationBuffer(_plants, INIT_BUFFER_SIZE);
                var windVBO    = PlantUserAttributeBuilder.GetInstancedWindBuffer(_plants, INIT_BUFFER_SIZE);
                var samplerVBO = PlantUserAttributeBuilder.GetInstanceSamplerBuffer(_plants, INIT_BUFFER_SIZE);

                vao = new VertexArrayObject();
                vao.AddVBO(verticesVBO, normalsVBO, texCoordsVBO,
                           transformationVboTuples.Item1.Item1, transformationVboTuples.Item1.Item2, transformationVboTuples.Item2.Item1, transformationVboTuples.Item2.Item2,
                           windVBO, samplerVBO);

                vao.BindBuffersToVao();
            }

            return(vao);
        }
Exemple #6
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();
        }
        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;
            }
        }
        private void AddBoundModelToRoot()
        {
            Vector3 LBNCoordinates = Bound.GetLocalSpaceMin();
            Vector3 RTFCoordinates = Bound.GetLocalSpaceMax();

            float[,] renderCoordinates = new float[24, 3];

            renderCoordinates[0, 0] = LBNCoordinates.X; renderCoordinates[0, 1] = LBNCoordinates.Y; renderCoordinates[0, 2] = LBNCoordinates.Z;
            renderCoordinates[1, 0] = RTFCoordinates.X; renderCoordinates[1, 1] = LBNCoordinates.Y; renderCoordinates[1, 2] = LBNCoordinates.Z;
            renderCoordinates[2, 0] = RTFCoordinates.X; renderCoordinates[2, 1] = RTFCoordinates.Y; renderCoordinates[2, 2] = LBNCoordinates.Z;
            renderCoordinates[3, 0] = LBNCoordinates.X; renderCoordinates[3, 1] = RTFCoordinates.Y; renderCoordinates[3, 2] = LBNCoordinates.Z;

            renderCoordinates[4, 0] = RTFCoordinates.X; renderCoordinates[4, 1] = LBNCoordinates.Y; renderCoordinates[4, 2] = LBNCoordinates.Z;
            renderCoordinates[5, 0] = RTFCoordinates.X; renderCoordinates[5, 1] = LBNCoordinates.Y; renderCoordinates[5, 2] = RTFCoordinates.Z;
            renderCoordinates[6, 0] = RTFCoordinates.X; renderCoordinates[6, 1] = RTFCoordinates.Y; renderCoordinates[6, 2] = RTFCoordinates.Z;
            renderCoordinates[7, 0] = RTFCoordinates.X; renderCoordinates[7, 1] = RTFCoordinates.Y; renderCoordinates[7, 2] = LBNCoordinates.Z;

            renderCoordinates[8, 0]  = RTFCoordinates.X; renderCoordinates[8, 1] = LBNCoordinates.Y; renderCoordinates[8, 2] = RTFCoordinates.Z;
            renderCoordinates[9, 0]  = LBNCoordinates.X; renderCoordinates[9, 1] = LBNCoordinates.Y; renderCoordinates[9, 2] = RTFCoordinates.Z;
            renderCoordinates[10, 0] = LBNCoordinates.X; renderCoordinates[10, 1] = RTFCoordinates.Y; renderCoordinates[10, 2] = RTFCoordinates.Z;
            renderCoordinates[11, 0] = RTFCoordinates.X; renderCoordinates[11, 1] = RTFCoordinates.Y; renderCoordinates[11, 2] = RTFCoordinates.Z;

            renderCoordinates[12, 0] = LBNCoordinates.X; renderCoordinates[12, 1] = LBNCoordinates.Y; renderCoordinates[12, 2] = RTFCoordinates.Z;
            renderCoordinates[13, 0] = LBNCoordinates.X; renderCoordinates[13, 1] = LBNCoordinates.Y; renderCoordinates[13, 2] = LBNCoordinates.Z;
            renderCoordinates[14, 0] = LBNCoordinates.X; renderCoordinates[14, 1] = RTFCoordinates.Y; renderCoordinates[14, 2] = LBNCoordinates.Z;
            renderCoordinates[15, 0] = LBNCoordinates.X; renderCoordinates[15, 1] = RTFCoordinates.Y; renderCoordinates[15, 2] = RTFCoordinates.Z;

            renderCoordinates[16, 0] = LBNCoordinates.X; renderCoordinates[16, 1] = LBNCoordinates.Y; renderCoordinates[16, 2] = LBNCoordinates.Z;
            renderCoordinates[17, 0] = RTFCoordinates.X; renderCoordinates[17, 1] = LBNCoordinates.Y; renderCoordinates[17, 2] = LBNCoordinates.Z;
            renderCoordinates[18, 0] = RTFCoordinates.X; renderCoordinates[18, 1] = LBNCoordinates.Y; renderCoordinates[18, 2] = RTFCoordinates.Z;
            renderCoordinates[19, 0] = LBNCoordinates.X; renderCoordinates[19, 1] = LBNCoordinates.Y; renderCoordinates[19, 2] = RTFCoordinates.Z;

            renderCoordinates[20, 0] = LBNCoordinates.X; renderCoordinates[20, 1] = RTFCoordinates.Y; renderCoordinates[20, 2] = LBNCoordinates.Z;
            renderCoordinates[21, 0] = RTFCoordinates.X; renderCoordinates[21, 1] = RTFCoordinates.Y; renderCoordinates[21, 2] = LBNCoordinates.Z;
            renderCoordinates[22, 0] = RTFCoordinates.X; renderCoordinates[22, 1] = RTFCoordinates.Y; renderCoordinates[22, 2] = RTFCoordinates.Z;
            renderCoordinates[23, 0] = LBNCoordinates.X; renderCoordinates[23, 1] = RTFCoordinates.Y; renderCoordinates[23, 2] = RTFCoordinates.Z;

            var vao = new VertexArrayObject();

            var verticesVBO = new VertexBufferObjectTwoDimension <float>(renderCoordinates, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Store);

            vao.AddVBO(verticesVBO);
            vao.BindBuffersToVao();

            skin = new Skin(vao);
            PoolCollector.GetInstance().s_ModelPool.AddModelToRoot(skin, "CollisionBound");
        }
        private void InitBonesVAO()
        {
            Int32 bonesCount = m_animationHolder.GetCurrentSequence().GetBonesCount();

            VertexBufferObjectTwoDimension <float> verticesVBO = new VertexBufferObjectTwoDimension <float>(new float[bonesCount, 3], BufferTarget.ArrayBuffer,
                                                                                                            0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);

            Int32[] boneIndices = new Int32[bonesCount];
            for (Int32 i = 0; i < bonesCount; i++)
            {
                boneIndices[i] = i;
            }

            VertexBufferObjectOneDimension <Int32> boneIndicesVBO = new VertexBufferObjectOneDimension <Int32>(boneIndices, BufferTarget.ArrayBuffer,
                                                                                                               1, VertexBufferObjectBase.DataCarryFlag.Invalidate);

            m_skeletonVAO.AddVBO(verticesVBO, boneIndicesVBO);
            m_skeletonVAO.BindBuffersToVao();
        }
        static public VertexArrayObject getTerrainAttributes(TableGrid LandscapeMap, Int32 normalSmoothLvl)
        {
            Int32 VERTEX_COUNT = LandscapeMap.TableSize - 1;
            float x, z;

            float[,] vertices  = new float[(VERTEX_COUNT * VERTEX_COUNT) * 6, 3];
            float[,] texCoords = new float[(VERTEX_COUNT * VERTEX_COUNT) * 6, 2];
            float[,] normals   = new float[(VERTEX_COUNT * VERTEX_COUNT) * 6, 3];
            Int32   vertexPointer = 0;
            Vector3 tempNormal;

            Vector3[,] normalMatrix = new Vector3[LandscapeMap.TableSize, LandscapeMap.TableSize];

            for (Int32 i = 0; i < LandscapeMap.TableSize - 1; i++)
            {
                for (Int32 j = 0; j < LandscapeMap.TableSize - 1; j++)
                {
                    x = i * (float)LandscapeMap.GridStep;
                    z = j * (float)LandscapeMap.GridStep;

                    vertices[vertexPointer, 0] = x;
                    vertices[vertexPointer, 1] = LandscapeMap.Table[i, j];
                    vertices[vertexPointer, 2] = z;
                    tempNormal = VectorMathOperations.GetNormalToPlane(new Vector3[3] {
                        new Vector3(x, LandscapeMap.Table[i, j], z),
                        new Vector3(x, LandscapeMap.Table[i, j + 1], z + (float)LandscapeMap.GridStep),
                        new Vector3(x + (float)LandscapeMap.GridStep, LandscapeMap.Table[i + 1, j], z)
                    });
                    normalMatrix[i, j] = tempNormal;
                    //tempNormal = getLandscapeNormal(i, j);
                    normals[vertexPointer, 0]   = tempNormal.X;
                    normals[vertexPointer, 1]   = tempNormal.Y;
                    normals[vertexPointer, 2]   = tempNormal.Z;
                    texCoords[vertexPointer, 0] = vertices[vertexPointer, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer, 1] = vertices[vertexPointer, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertices[vertexPointer + 1, 0] = x;
                    vertices[vertexPointer + 1, 1] = LandscapeMap.Table[i, j + 1];
                    vertices[vertexPointer + 1, 2] = z + (float)LandscapeMap.GridStep;
                    tempNormal = VectorMathOperations.GetNormalToPlane(new Vector3[3] {
                        new Vector3(x, LandscapeMap.Table[i, j + 1], z + (float)LandscapeMap.GridStep),
                        new Vector3(x + (float)LandscapeMap.GridStep, LandscapeMap.Table[i + 1, j], z),
                        new Vector3(x, LandscapeMap.Table[i, j], z)
                    });
                    normalMatrix[i, j + 1] = tempNormal;
                    //tempNormal = getLandscapeNormal(i, j + 1);
                    normals[vertexPointer + 1, 0]   = tempNormal.X;
                    normals[vertexPointer + 1, 1]   = tempNormal.Y;
                    normals[vertexPointer + 1, 2]   = tempNormal.Z;
                    texCoords[vertexPointer + 1, 0] = vertices[vertexPointer + 1, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer + 1, 1] = vertices[vertexPointer + 1, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertices[vertexPointer + 2, 0] = x + (float)LandscapeMap.GridStep;
                    vertices[vertexPointer + 2, 1] = LandscapeMap.Table[i + 1, j];
                    vertices[vertexPointer + 2, 2] = z;
                    tempNormal = VectorMathOperations.GetNormalToPlane(new Vector3[3] {
                        new Vector3(x + (float)LandscapeMap.GridStep, LandscapeMap.Table[i + 1, j], z),
                        new Vector3(x, LandscapeMap.Table[i, j], z),
                        new Vector3(x, LandscapeMap.Table[i, j + 1], z + (float)LandscapeMap.GridStep)
                    });
                    normalMatrix[i + 1, j] = tempNormal;
                    //tempNormal = getLandscapeNormal(i + 1, j);
                    normals[vertexPointer + 2, 0]   = tempNormal.X;
                    normals[vertexPointer + 2, 1]   = tempNormal.Y;
                    normals[vertexPointer + 2, 2]   = tempNormal.Z;
                    texCoords[vertexPointer + 2, 0] = vertices[vertexPointer + 2, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer + 2, 1] = vertices[vertexPointer + 2, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertices[vertexPointer + 3, 0]  = x + (float)LandscapeMap.GridStep;
                    vertices[vertexPointer + 3, 1]  = LandscapeMap.Table[i + 1, j];
                    vertices[vertexPointer + 3, 2]  = z;
                    normals[vertexPointer + 3, 0]   = normals[vertexPointer + 2, 0];
                    normals[vertexPointer + 3, 1]   = normals[vertexPointer + 2, 1];
                    normals[vertexPointer + 3, 2]   = normals[vertexPointer + 2, 2];
                    texCoords[vertexPointer + 3, 0] = vertices[vertexPointer + 3, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer + 3, 1] = vertices[vertexPointer + 3, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertices[vertexPointer + 4, 0]  = x;
                    vertices[vertexPointer + 4, 1]  = LandscapeMap.Table[i, j + 1];
                    vertices[vertexPointer + 4, 2]  = z + (float)LandscapeMap.GridStep;
                    normals[vertexPointer + 4, 0]   = normals[vertexPointer + 1, 0];
                    normals[vertexPointer + 4, 1]   = normals[vertexPointer + 1, 1];
                    normals[vertexPointer + 4, 2]   = normals[vertexPointer + 1, 2];
                    texCoords[vertexPointer + 4, 0] = vertices[vertexPointer + 4, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer + 4, 1] = vertices[vertexPointer + 4, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertices[vertexPointer + 5, 0] = x + (float)LandscapeMap.GridStep;
                    vertices[vertexPointer + 5, 1] = LandscapeMap.Table[i + 1, j + 1];
                    vertices[vertexPointer + 5, 2] = z + (float)LandscapeMap.GridStep;
                    tempNormal = VectorMathOperations.GetNormalToPlane(new Vector3[3] {
                        new Vector3(x + (float)LandscapeMap.GridStep, LandscapeMap.Table[i + 1, j + 1], z + (float)LandscapeMap.GridStep),
                        new Vector3(x + (float)LandscapeMap.GridStep, LandscapeMap.Table[i + 1, j], z),
                        new Vector3(x, LandscapeMap.Table[i, j + 1], z + (float)LandscapeMap.GridStep)
                    });
                    normalMatrix[i + 1, j + 1] = tempNormal;
                    //tempNormal = getLandscapeNormal(i + 1, j + 1);
                    normals[vertexPointer + 5, 0]   = tempNormal.X;
                    normals[vertexPointer + 5, 1]   = tempNormal.Y;
                    normals[vertexPointer + 5, 2]   = tempNormal.Z;
                    texCoords[vertexPointer + 5, 0] = vertices[vertexPointer + 5, 0] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    texCoords[vertexPointer + 5, 1] = vertices[vertexPointer + 5, 2] / (float)(LandscapeMap.GridStep * LandscapeMap.TableSize);
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    vertexPointer += 6;
                }
            }
            // Making smooth normals
            vertexPointer = 0;
            for (Int32 i = 0; i < LandscapeMap.TableSize - 1; i++)
            {
                for (Int32 j = 0; j < LandscapeMap.TableSize - 1; j++)
                {
                    tempNormal = getLandscapeSmoothNormal(LandscapeMap, normalMatrix, i, j, normalSmoothLvl);
                    normals[vertexPointer, 0] = tempNormal.X;
                    normals[vertexPointer, 1] = tempNormal.Y;
                    normals[vertexPointer, 2] = tempNormal.Z;
                    tempNormal = getLandscapeSmoothNormal(LandscapeMap, normalMatrix, i, j + 1, normalSmoothLvl);
                    normals[vertexPointer + 1, 0] = tempNormal.X;
                    normals[vertexPointer + 1, 1] = tempNormal.Y;
                    normals[vertexPointer + 1, 2] = tempNormal.Z;
                    tempNormal = getLandscapeSmoothNormal(LandscapeMap, normalMatrix, i + 1, j, normalSmoothLvl);
                    normals[vertexPointer + 2, 0] = tempNormal.X;
                    normals[vertexPointer + 2, 1] = tempNormal.Y;
                    normals[vertexPointer + 2, 2] = tempNormal.Z;
                    normals[vertexPointer + 3, 0] = normals[vertexPointer + 2, 0];
                    normals[vertexPointer + 3, 1] = normals[vertexPointer + 2, 1];
                    normals[vertexPointer + 3, 2] = normals[vertexPointer + 2, 2];
                    normals[vertexPointer + 4, 0] = normals[vertexPointer + 1, 0];
                    normals[vertexPointer + 4, 1] = normals[vertexPointer + 1, 1];
                    normals[vertexPointer + 4, 2] = normals[vertexPointer + 1, 2];
                    tempNormal = getLandscapeSmoothNormal(LandscapeMap, normalMatrix, i + 1, j + 1, normalSmoothLvl);
                    normals[vertexPointer + 5, 0] = tempNormal.X;
                    normals[vertexPointer + 5, 1] = tempNormal.Y;
                    normals[vertexPointer + 5, 2] = tempNormal.Z;
                    vertexPointer += 6;
                }
            }

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

            VertexArrayObject vao = new VertexArrayObject();

            vao.AddVBO(verticesVBO, normalsVBO, texCoordsVBO, tangentsVBO, bitangentsVBO);
            vao.BindBuffersToVao();

            return(vao);
        }
        private Skin SendDataToGpu(string modelPath)
        {
            Skin resultSkin = null;

            // Get mesh data
            using (AssimpModelLoader loader = new AssimpModelLoader(modelPath))
            {
                VertexArrayObject vao      = new VertexArrayObject();
                MeshVertexData    meshData = loader.GetMeshData();
                // explicit null assignment if there is no some of mesh data
                var vertices     = meshData.Verts;
                var normals      = meshData.bHasNormals ? meshData.N_Verts : null;
                var texCoords    = meshData.T_Verts;
                var tangents     = meshData.bHasTangentVertices ? meshData.Tangent_Verts : meshData.bHasTextureCoordinates ? VectorMath.AdditionalVertexInfoCreator.CreateTangentVertices(vertices, texCoords) : null;
                var bitangents   = meshData.bHasTangentVertices ? meshData.Bitanget_Verts : meshData.bHasTextureCoordinates ? VectorMath.AdditionalVertexInfoCreator.CreateBitangentVertices(vertices, texCoords) : null;
                var blendWeights = meshData.bHasAnimation ? meshData.BlendWeights : null;
                var blendIndices = meshData.bHasAnimation ? meshData.BlendIndices : null;

                UInt32[] indices = meshData.bHasIndices ? meshData.Indices.ToArray() : null;

                IndexBufferObject ibo = null;
                VertexBufferObjectTwoDimension <float> normalsVBO = null, texCoordsVBO = null, tangentsVBO = null, bitangentsVBO = null, blendWeightsVBO = null;
                VertexBufferObjectTwoDimension <Int32> blendIndicesVBO = null;

                if (meshData.bHasIndices)
                {
                    ibo = new IndexBufferObject(indices);
                }

                VertexBufferObjectTwoDimension <float> vertexVBO = new VertexBufferObjectTwoDimension <float>(vertices, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);

                if (meshData.bHasNormals)
                {
                    normalsVBO = new VertexBufferObjectTwoDimension <float>(normals, BufferTarget.ArrayBuffer, 1, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                }
                if (meshData.bHasTextureCoordinates)
                {
                    texCoordsVBO = new VertexBufferObjectTwoDimension <float>(texCoords, BufferTarget.ArrayBuffer, 2, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                }
                if (meshData.bHasTangentVertices)
                {
                    tangentsVBO = new VertexBufferObjectTwoDimension <float>(tangents, BufferTarget.ArrayBuffer, 4, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                }
                if (meshData.bHasTangentVertices)
                {
                    bitangentsVBO = new VertexBufferObjectTwoDimension <float>(bitangents, BufferTarget.ArrayBuffer, 5, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                }
                if (meshData.bHasAnimation)
                {
                    Int32 skeletonWeightsPerVertexCount = (Int32)loader.m_skeletonType;
                    if (skeletonWeightsPerVertexCount > 4)
                    {
                        throw new NotImplementedException("There is no implementation yet for cases when there are more than four weights influencing on vertex.");
                    }

                    Int32 vectorSize = skeletonWeightsPerVertexCount;
                    blendWeightsVBO = new VertexBufferObjectTwoDimension <float>(blendWeights, BufferTarget.ArrayBuffer, 6, vectorSize, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                    blendIndicesVBO = new VertexBufferObjectTwoDimension <int>(blendIndices, BufferTarget.ArrayBuffer, 7, vectorSize, VertexBufferObjectBase.DataCarryFlag.Invalidate);
                }

                vao.AddVBO(vertexVBO, normalsVBO, texCoordsVBO, tangentsVBO, bitangentsVBO, blendWeightsVBO, blendIndicesVBO);
                vao.AddIndexBuffer(ibo);
                vao.BindBuffersToVao();

                if (meshData.bHasAnimation)
                {
                    ParentBone rootBone = AssimpConverter.Converter.ConvertAssimpBoneToEngineBone(meshData.SkeletonRoot);
                    resultSkin = new AnimatedSkin(vao, rootBone);
                }
                else
                {
                    resultSkin = new Skin(vao);
                }
            }

            return(resultSkin);
        }