Пример #1
0
 /// <summary>
 /// Constructor for the SphereCamera class, initiates variables according to the parent call to the
 /// constructor.
 /// </summary>
 /// <param name="origin">The vertex3 that represents the origin of the sphere(the central point).</param>
 /// <param name="radius">The value of the radius of the sphere, allows for the camera to be positioned
 /// at radius distance from the origin.</param>
 public SphereCamera(Vertex3 origin, float radius)
 {
     lookAT = origin;
     this.radius = radius;
     x = (float)((this.radius * Math.Sin(theta) * Math.Cos(ro))+lookAT.getVals()[0]);
     z = (float)((this.radius * Math.Sin(theta) * Math.Sin(ro))+lookAT.getVals()[1]);
     y = (float)((this.radius * Math.Cos(theta)) + lookAT.getVals()[2]);
     normal = new Vertex3((float)(-Math.Sin(ro) * Math.Cos(theta)), (float)(-Math.Sin(ro) * Math.Sin(theta)),(float) -Math.Cos(ro));
 }
Пример #2
0
 /// <summary>
 /// Mutator method for changing the point at which the camera looks.
 /// </summary>
 /// <param name="newLookAt">The new point we wish to look at.</param>
 /// <returns>True if the lookAt variable is changed, false otherwise.</returns>
 public bool changeLookAt(Vertex3 newLookAt)
 {
     if (newLookAt != null)
     {
         lookAT = newLookAt;
         moveCamera(0, 0);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #3
0
 /// <summary>
 /// The moveCamera method accepts the theta and ro delta values, (the latitude and longitude angle changes)
 /// and performs the correct translation of the camera position.
 /// NOTE: This may need to be changed to reflect a change after it has already moved, currently
 /// I believe it resets after every move, so a subsequent move will have the camera at a different orientation
 /// than it begins with.
 /// </summary>
 /// <param name="deltaTheta">The latitude change of the camera.</param>
 /// <param name="deltaRo">The longitude change of the camera.</param>
 public void moveCamera(double deltaTheta, double deltaRo)
 {
     theta += deltaTheta;
     ro += deltaRo;
     x = (float)((this.radius * Math.Sin(theta) * Math.Cos(ro))+lookAT.getVals()[0]);
     z = (float)((this.radius * Math.Sin(theta) * Math.Sin(ro))+lookAT.getVals()[1]);
     y = (float)((this.radius * Math.Cos(theta)) + lookAT.getVals()[2]);
     normal = new Vertex3((float)(-Math.Sin(ro) * Math.Cos(theta)), (float)(-Math.Sin(ro) * Math.Sin(theta)), (float)-Math.Cos(ro));
 }
Пример #4
0
 /// <summary>
 /// The moveCamera method accepts a delta angle value, and then a bool which determines which angle the camera should
 /// be moving against. The other angle is not used, so we can get a clear left-to-right or up-to-down movement.
 /// </summary>
 /// <param name="delta">The angle which we are to use.</param>
 /// <param name="isRo">The bool that determines wether this angle is a deltaRO or a deltaTHETA angle.</param>
 public void moveCamera(double delta, bool isRo)
 {
     if (isRo)
     {// If this is a ro angle
         ro += delta;
     }
     else
     {
         theta += delta;
     }
     x = (float)((this.radius * Math.Sin(theta) * Math.Cos(ro)) + lookAT.getVals()[0]);
     z = (float)((this.radius * Math.Sin(theta) * Math.Sin(ro)) + lookAT.getVals()[1]);
     y = (float)((this.radius * Math.Cos(theta)) + lookAT.getVals()[2]);
     normal = new Vertex3((float)(-Math.Sin(ro) * Math.Cos(theta)), (float)(-Math.Sin(ro) * Math.Sin(theta)), (float)-Math.Cos(ro));
 }
Пример #5
0
        /// <summary>
        /// Another creation of a mesh for viewing the 3D Spectrograph.
        /// </summary>
        /// <param name="vertix">The vertix that starts the mesh.</param>
        private void AddMesh(Vertex3[] vertix)
        {
            if (!Loaded) // Play nice
                return;
            Vertex3 temp;
            double[] tempd;

            for (int i = 0; i < vertix.Length; i++)
            {
                if ((i + GraphInformation.NCurves) < vertix.Length)
                {
                    if (!(i % GraphInformation.NCurves == GraphInformation.NCurves - 1))
                    {
                        Vertex3[] tempvs = new Vertex3[3];
                        temp = vertix[i];
                        tempvs[0] = temp;
                        temp = vertix[i + 1];
                        tempvs[1] = temp;
                        temp = vertix[i + GraphInformation.NCurves];
                        tempvs[2] = temp;

                        GL.Begin(BeginMode.Triangles);
                        for (int y = 0; y < 3; y++)
                        {
                            temp = tempvs[y];
                            tempd = temp.getVals();
                            GL.Color4(temp.getColor());
                            GL.Vertex3(tempd[0], tempd[1], tempd[2]);
                        }
                        GL.End();
                        GL.Begin(BeginMode.LineStrip);
                        for (int y = 0; y < 3; y++)
                        {
                            temp = tempvs[y];
                            tempd = temp.getVals();
                            GL.Color4(Color4.Black);
                            GL.Vertex3(tempd[0], tempd[1], tempd[2]);
                        }
                        GL.End();
                    }
                    if (!(i % GraphInformation.NCurves == 0))
                    {
                        GL.Begin(BeginMode.Triangles);
                        temp = vertix[i];
                        tempd = temp.getVals();
                        GL.Color4(temp.getColor());
                        GL.Vertex3(tempd[0], tempd[1], tempd[2]);
                        temp = vertix[i + GraphInformation.NCurves];
                        tempd = temp.getVals();
                        GL.Color4(temp.getColor());
                        GL.Vertex3(tempd[0], tempd[1], tempd[2]);
                        temp = vertix[i + GraphInformation.NCurves - 1];
                        tempd = temp.getVals();
                        GL.Color4(temp.getColor());
                        GL.Vertex3(tempd[0], tempd[1], tempd[2]);
                        GL.End();
                    }
                }
            }
        }