示例#1
0
        public Sun(string dataBaseName, PlanetParameters param, Planet parent, MeshVBOs vbos, Texture t, ShaderProgram shader, ShaderProgram lineShader)
            : base(dataBaseName, param, parent, vbos, t, shader, lineShader)
        {
            bufferVerts = new VBO<float>(new float[] { -1, 1, 0, 1, 1, 0, 1, -1, 0, -1, -1, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.vertex);
            bufferElems = new VBO<ushort>(new ushort[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer, VBO<ushort>.PointerType.element);

            squareUvs = new VBO<float>(new float[] { 0, 1, 1, 1, 1, 0, 0, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.texCoord);
            squareVerts = new VBO<float>(new float[] { -2, 2, 0, 2f, 2f, 0, 2f, -2f, 0, -2f, -2f, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.vertex);
            squareElems = new VBO<ushort>(new ushort[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer, VBO<ushort>.PointerType.element);

            this.coronaShader = new ShaderProgram(File.ReadAllText("content/shaders/coronaShader.vert"), File.ReadAllText("content/shaders/coronaShader.frag"), "coronaShader");
            Console.WriteLine(coronaShader.ProgramInfoLog);
            coronaShader.setUniform("proj", Form1.projectionMatrix);
            coronaShader.setUniform("model", Matrix4.Identity);

            this.billboardShader = new ShaderProgram(File.ReadAllText("content/shaders/billboardShader.vert"), File.ReadAllText("content/shaders/billboardShader.frag"), "billboardShader");
            Console.WriteLine(billboardShader.ProgramInfoLog);
            billboardShader.setUniform("proj", Form1.projectionMatrix);
            billboardShader.setUniform("model", Matrix4.Identity);

            frameBufferTime = 0;
            bufferResolution = new Vector2(1024, 1024);

            bufferTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, bufferTexture);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)bufferResolution.X, (int)bufferResolution.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);

            frameBuffer = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, bufferTexture, 0);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); // make sure to set the framebuffer back to the default, or else bugs,
            //bugs that take two hours to debug
        }
示例#2
0
        public Planet(string dataBaseName, PlanetParameters param, Planet parent, MeshVBOs vbos, Texture t, ShaderProgram shader, ShaderProgram lineShader)
            : base(vbos, t, shader)
        {
            this.parent = parent;
            this.lineShader = lineShader;
            this.RevolutionOrientation = -1;
            this.AxisTilt = Matrix4.Identity;
            this.DrawAxisTilt = true;

            this.ScenicDistance = param.DFSScenic[dataBaseName];
            this.HoursPerRotation = param.RotationPeriod[dataBaseName];
            this.AxisTilt = Matrix4.CreateFromAxisAngle(new Vector3(0, 0, -1), (float)MathHelper.DegreesToRadians(param.AxialTilt[dataBaseName]));
            this.RealisticRadius = param.RadiusRealistic[dataBaseName];
            this.ScenicRadius = param.RadiusScenic[dataBaseName];
            this.Scale = (float)ScenicRadius;
            this.OrbitalPeriod = param.OrbitalPeriod[dataBaseName];
            this.inclinationAngle = param.InclinationAngle[dataBaseName];
            this.longitudeAscendingNode = param.LongitudeAscendingNode[dataBaseName];
            this.longitudePerihelion = param.LongitudePerihelion[dataBaseName];
            this.eccentricity = param.Eccentricity[dataBaseName];
            this.longitudeAscendingNodeRadians = MathHelper.DegreesToRadians(longitudeAscendingNode);
            this.longitudePerihelionRadians = MathHelper.DegreesToRadians(longitudePerihelion);
            this.inclinationAngleRadians = MathHelper.DegreesToRadians(inclinationAngle);
            this.newRadius = 0;
            this.PeriodAngle = longitudePerihelionRadians;
            this.eccentricAnomaly = 0;
            this.createTransform();
            if (parent != null)
                this.Orbit = new Orbit(this, parent.Position, this.ScenicDistance, 360, lineShader, this.inclinationAngle, this.longitudeAscendingNode, this.longitudePerihelion, this.eccentricity);
            float[] axisVerts = { 0, -2, 0, 0, 2, 0 };
            this.axisLine = new VBO<float>(axisVerts, BufferTarget.ArrayBuffer, VBO<float>.PointerType.vertex);
        }
示例#3
0
 public PlanetRing(MeshVBOs vbos, Texture t, Planet p)
 {
     this.vbos = vbos;
     this.texture = t;
     this.parent = p;
     this.transform = parent.Transform;
 }
示例#4
0
 public Mesh(MeshVBOs vbos, Texture t, ShaderProgram defaultShader)
 {
     this.Shader = defaultShader;
     this.Vbos = vbos;
     this.Texture = t;
     this.Position = new Vector3(0);
     this.Transform = Matrix4.Identity;
     this.Rotation = Matrix4.Identity;
     this.Scale = 1f;
     this.createTransform();
 }
示例#5
0
        public Earth(string dataBaseName, PlanetParameters param, Planet parent, MeshVBOs vbos, Texture diffuse, Texture specular, Texture night, Texture normal, Texture clouds, ShaderProgram earthShader, ShaderProgram lineShader)
            : base(dataBaseName, param, parent, vbos, diffuse, earthShader, lineShader)
        {
            this.specularT = specular;
            this.nightT = night;
            this.normalT = normal;
            this.cloudsT = clouds;
            this.cloudsSphereScale = Matrix4.CreateScale(1.005f);

            cloudShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/cloudShader.frag"), "cloudShader");
            Console.WriteLine(cloudShader.ProgramInfoLog);
            cloudShader.setUniform("proj", Form1.projectionMatrix);
        }