Esempio n. 1
0
 public void GenerateGeometry(GLScene scene)
 {
     my_OpenGL  = scene.GL;
     my_Texture = new Texture()
     {
         Name = ""
     };
     my_VertexBufferArray = new VertexBufferArray();
     my_VertexBufferArray.Create(my_OpenGL);
     my_VertexBufferArray.Bind(my_OpenGL);
     CreateVertexBuffer(GLScene.positionAttribute);
     CreateNormalBuffer(GLScene.normalAttribute);
     CreateColorBuffer(GLScene.colorAttribute);
     CreateTextureCoordBuffer(GLScene.textureAttribute);
     CreateIndexBuffer();
     my_VertexBufferArray.Unbind(my_OpenGL);
     if (my_OpenGL != null & my_UseTexture & my_TextureFile != "")
     {
         try
         {
             my_Texture.Create(my_OpenGL, my_TextureFile);
             my_Texture.Name = my_TextureFile;
         }
         catch (System.Exception)
         {
             MessageBox.Show("Unable to create Texture from File:" + my_TextureFile, "GeometryGL error", MessageBoxButton.OK, MessageBoxImage.Error);
             my_Texture = new Texture();
         }
     }
 }
Esempio n. 2
0
 public void SetLightData(OpenGL gl, GLScene scene, ShaderProgram shader)
 {
     if (my_SwitchedOn)
     {
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].type", (float)my_Type);
         shader.SetUniform3(gl, "lights[" + my_Index.ToString() + "].position", (float)my_Position.X, (float)my_Position.Y, (float)my_Position.Z);
         shader.SetUniform3(gl, "lights[" + my_Index.ToString() + "].direction", (float)my_Direction.X, (float)my_Direction.Y, (float)my_Direction.Z);
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].cutOff", (float)Math.Cos(my_CutOff * Math.PI / 180));
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].outerCutOff", (float)Math.Cos(my_OuterCutOff * Math.PI / 180));
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].constant", my_Constant);
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].linear", my_Linear);
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].quadratic", my_Quadratic);
         shader.SetUniform3(gl, "lights[" + my_Index.ToString() + "].ambient", my_Ambient.ScR, my_Ambient.ScG, my_Ambient.ScB);
         shader.SetUniform3(gl, "lights[" + my_Index.ToString() + "].diffuse", my_Diffuse.ScR, my_Diffuse.ScG, my_Diffuse.ScB);
         shader.SetUniform3(gl, "lights[" + my_Index.ToString() + "].specular", my_Specular.ScR, my_Specular.ScG, my_Specular.ScB);
     }
     else
     {
         shader.SetUniform1(gl, "lights[" + my_Index.ToString() + "].type", 0.0F);
     }
 }