Example #1
0
        public StarGlow(Section section)
        {
            foreach (var e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    Nickname = e[0].ToString();
                    break;

                case "shape":
                    Shape = e[0].ToString();
                    break;

                case "scale":
                    Scale = e[0].ToInt32();
                    break;

                case "inner_color":
                    InnerColor = new Color3f(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "outer_color":
                    OuterColor = new Color3f(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;
                }
            }
        }
Example #2
0
        public static void Draw(Point peak, double width, double lenght, Direction direction, Color3f color)
        {
            float r = (float)(width / 2.0);
            float rCl = (float)(width / 6.0);
            float arrLen = (float)(lenght / 3.0);
            float step = (float)(Math.PI / 1.5);

            Gl.glColor3f(color.r, color.g, color.b);

            Gl.glBegin(Gl.GL_TRIANGLE_FAN);
            Gl.glVertex3f(peak.x, peak.y, peak.z);
            for (double angle = 0; angle < 2 * Math.PI + step; angle += step)
            {
                Gl.glVertex3f(peak.x + r * (float)Math.Cos(angle), peak.y + r * (float)Math.Sin(angle), peak.z + arrLen);
            }
            Gl.glEnd();

            Gl.glBegin(Gl.GL_QUAD_STRIP);
            for (double angle = 0; angle < 2 * Math.PI + step; angle += step)
            {
                Gl.glVertex3f(peak.x + rCl * (float)Math.Cos(angle), peak.y + rCl * (float)Math.Sin(angle), peak.z + arrLen);
                Gl.glVertex3f(peak.x + rCl * (float)Math.Cos(angle), peak.y + rCl * (float)Math.Sin(angle), peak.z + (float)lenght);
            }
            Gl.glEnd();
        }
Example #3
0
        public Color3f GetValue(float time)
        {
            //Only have one keyframe? Just return it.
            if (Data.Length == 1)
            {
                return(Data [0].Item2);
            }
            //Locate the keyframes to interpolate between
            float   t1 = float.NegativeInfinity;
            float   t2 = 0;
            Color3f v1 = new Color3f(), v2 = new Color3f();

            for (int i = 0; i < Data.Length - 1; i++)
            {
                if (time >= Data [i].Item1 && time <= Data [i + 1].Item1)
                {
                    t1 = Data [i].Item1;
                    t2 = Data [i + 1].Item1;
                    v1 = Data [i].Item2;
                    v2 = Data [i + 1].Item2;
                }
            }
            //Time wasn't between any values. Return max.
            if (t1 == float.NegativeInfinity)
            {
                return(Data [Data.Length - 1].Item2);
            }
            //Interpolate!
            return(AlchemyEasing.EaseColorRGB(Type, time, t1, t2, v1, v2));
        }
Example #4
0
        public static Vec4ub ToVec4ub(this Color3f color)
        {
            ColorSetter3b setter = new ColorSetter3b();

            color.GetColor(setter);
            return(new Vec4ub(setter.C1, setter.C2, setter.C3, 1));
        }
Example #5
0
 public Spine(Entry e)
 {
     LengthScale = e[0].ToSingle();
     WidthScale  = e[1].ToSingle();
     InnerColor  = new Color3f(e[2].ToSingle(), e[3].ToSingle(), e[4].ToSingle());
     OuterColor  = new Color3f(e[5].ToSingle(), e[6].ToSingle(), e[7].ToSingle());
     Alpha       = e[8].ToSingle();
 }
Example #6
0
 public Spine(float length, float width, Color3f inner, Color3f outer, float alpha)
 {
     LengthScale = length;
     WidthScale  = width;
     InnerColor  = inner;
     OuterColor  = outer;
     Alpha       = alpha;
 }
        public AbstractLight(Color3f diffuseColor)
        {
            DiffuseColor = diffuseColor;
            DiffusePower = 4f;

            SpecularColor = new Color3f(1f, 1f, 1f);
            SpecularPower = 3f;
        }
Example #8
0
		public static Color3f EaseColor(EasingTypes type, float time, float t1, float t2, Color3f c1, Color3f c2)
		{
			var h1 = HSLColor.FromRGB (c1);
			var h2 = HSLColor.FromRGB (c2);

			float h = Ease (type, time, t1, t2, h1.H, h2.H);
			float s = Ease (type, time, t1, t2, h1.S, h2.S);
			float l = Ease (type, time, t1, t2, h1.L, h2.L);

			return new HSLColor (h, s, l).ToRGB ();
		}
Example #9
0
        //----------------------------------CONSTRUCTORS--------------------------------//
        /**
         * Constructs a vertex with unknown status
         *
         * @param position vertex position
         * @param color vertex color
         */
        public Vertex(Point3d position, Color3f color)
        {
            this.color = color.Clone();

            x = position.x;
            y = position.y;
            z = position.z;

            adjacentVertices = new List<Vertex>();
            status = UNKNOWN;
        }
Example #10
0
        /**
         * Draw a closed polygon provided in CCW order.  This implementation
         * uses {@link #drawSegment(Vec2, Vec2, Color3f)} to draw each side of the
         * polygon.
         * @param vertices
         * @param vertexCount
         * @param color
         */

        public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color)
        {
            if (vertexCount == 1)
            {
                drawSegment(vertices[0], vertices[0], color);
                return;
            }

            for (int i = 0; i < vertexCount - 1; i += 1)
            {
                drawSegment(vertices[i], vertices[i + 1], color);
            }

            if (vertexCount > 2)
            {
                drawSegment(vertices[vertexCount - 1], vertices[0], color);
            }
        }
Example #11
0
        public Color3f GetColor(Vector2d uvCoordinates, int MIPMAPLOD)
        {
            Color3f result = _colors[0];

            if (uvCoordinates.X < 0.0f)
            {
                uvCoordinates.X += 1.0f;
            }

            if (uvCoordinates.Y < 0.0f)
            {
                uvCoordinates.Y += 1.0f;
            }

            double u = uvCoordinates.X % 1f;
            double v = uvCoordinates.Y % 1f;

            if (u <= 0.5f && v <= 0.5f)
            {
                return(_colors[1]);
            }

            if (u > 0.5f && v > 0.5f)
            {
                return(_colors[1]);
            }

            return(_colors[0]);

            /*
             * if ((((int)Math.Abs(textureCoordinates.X)) % 20) <= 10 && (((int)Math.Abs(textureCoordinates.Y)) % 20) <= 10)
             * {
             *  result = _colors[1];
             * }
             *
             * if ((((int)Math.Abs(textureCoordinates.X)) % 20) > 10 && (((int)Math.Abs(textureCoordinates.Y)) % 20) > 10)
             * {
             *  result = _colors[1];
             * }
             *
             * return result;
             */
        }
Example #12
0
        public unsafe static Color3f ApplyKernel(System.Drawing.Imaging.BitmapData bitmapData, Kernel kernel, int x, int y)
        {
            /*
             * Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
             * System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
             */
            byte *scan0 = (byte *)bitmapData.Scan0.ToPointer();

            int     halfKernelSize = kernel.HalfSize;//(kernel.Size - 1) / 2;
            Color3f result         = new Color3f();

            int startX = System.Math.Max(x - halfKernelSize, 0);
            int endX   = System.Math.Min(x + halfKernelSize, bitmapData.Width - 1);

            int startY = System.Math.Max(y - halfKernelSize, 0);
            int endY   = System.Math.Min(y + halfKernelSize, bitmapData.Height - 1);

            int kernelY      = startY - (y - halfKernelSize);
            int kernelStartX = startX - (x - halfKernelSize);

            for (int yy = startY; yy <= endY; yy++)
            {
                int kernelX = kernelStartX;

                for (int xx = startX; xx <= endX; xx++)
                {
                    //result += (new Color3f(bitmap.GetPixel(xx, yy))) * kernel[kernelY, kernelX];

                    // TODO: because pixels outside of image are not calculated not all kernel elements are used and therefore the sum of factors != 1.0
                    // make kernel factors dependend on how much overlap
                    result += (new Color3f(scan0 + yy * bitmapData.Stride + xx * 3)) * kernel[kernelY, kernelX];

                    kernelX++;
                }

                kernelY++;
            }

            //bitmap.UnlockBits(bitmapData);

            return(result);
        }
Example #13
0
 public static MaterialFormat DefaultColors(this MaterialFormat mf)
 {
     mf.AddMaterial(new MaterialFormat.Mat("Black", Color3f.FromRGB(0, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("White", Color3f.FromRGB(255, 255, 255)));
     mf.AddMaterial(new MaterialFormat.Mat("Red", Color3f.FromRGB(255, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Lime", Color3f.FromRGB(0, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Blue", Color3f.FromRGB(0, 0, 255)));
     mf.AddMaterial(new MaterialFormat.Mat("Yellow", Color3f.FromRGB(255, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Cyan", Color3f.FromRGB(0, 255, 255)));    // Aqua
     mf.AddMaterial(new MaterialFormat.Mat("Magenta", Color3f.FromRGB(255, 0, 255))); // Fuchsia
     mf.AddMaterial(new MaterialFormat.Mat("Silver", Color3f.FromRGB(192, 192, 192)));
     mf.AddMaterial(new MaterialFormat.Mat("Gray", Color3f.FromRGB(128, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Maroon", Color3f.FromRGB(128, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Olive", Color3f.FromRGB(128, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Green", Color3f.FromRGB(0, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Purple", Color3f.FromRGB(128, 0, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Teal", Color3f.FromRGB(0, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Navy", Color3f.FromRGB(0, 0, 128)));
     return(mf);
 }
Example #14
0
 public static MaterialFormat DefaultColors(this MaterialFormat mf)
 {
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.BLACK, Color3f.FromRGB(0, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.WHITE, Color3f.FromRGB(255, 255, 255)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.RED, Color3f.FromRGB(255, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.LIME, Color3f.FromRGB(0, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.BLUE, Color3f.FromRGB(0, 0, 255)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.YELLOW, Color3f.FromRGB(255, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.CYAN, Color3f.FromRGB(0, 255, 255)));    // Aqua
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.MAGENTA, Color3f.FromRGB(255, 0, 255))); // Fuchsia
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.SILVER, Color3f.FromRGB(192, 192, 192)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.GRAY, Color3f.FromRGB(128, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.MAROON, Color3f.FromRGB(128, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.OLIVE, Color3f.FromRGB(128, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.GREEN, Color3f.FromRGB(0, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.PURPLE, Color3f.FromRGB(128, 0, 128)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.TEAL, Color3f.FromRGB(0, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat(WavefrontColor.NAVY, Color3f.FromRGB(0, 0, 128)));
     return(mf);
 }
Example #15
0
        /*
         * public Color3f ApplyKernel(int x, int y)
         * {
         *  return ConvolutionRenderer.ApplyKernel(_bitmap, _kernel, x, y);
         * }*/

        public virtual Bitmap Render()
        {
            Bitmap result = new Bitmap(_bitmap.Width, _bitmap.Height);

            Rectangle rect = new Rectangle(0, 0, _bitmap.Width, _bitmap.Height);

            System.Drawing.Imaging.BitmapData bitmapData = _bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            for (int y = 0; y < result.Height; y++)
            {
                for (int x = 0; x < result.Width; x++)
                {
                    Color3f color = ApplyKernel(bitmapData, _kernel, x, y);
                    result.SetPixel(x, y, color.ToColor());
                }
            }

            _bitmap.UnlockBits(bitmapData);

            return(result);
        }
Example #16
0
        /*public Ecliptic()
         *  : this(new Color3f(1, 1, 1), 10000, 100)
         * {
         * }*/
        public Ecliptic(Color3f color, float size, int num)
        {
            if (Root.Instance.UserInterface == null)
            {
                return;
            }

            VertexP3C3[] data = new VertexP3C3[(num + 1) * 4];
            int          i    = 0;

            material            = Material.CreateSimpleMaterial(null);
            material.DepthTest  = true;
            material.DepthWrite = true;
            material.Additive   = true;


            for (int x = 0; x <= num; ++x)
            {
                float c = (float)x / (float)num;
                float a = c * size - size / 2;
                float b = size / 2;
                c /= 6;

                data[i].Color      = new Color3f(c, 0, 0.5f);
                data[i++].Position = new Vector3(a, 0, b);
                data[i].Color      = new Color3f(c, 0, 0.5f);
                data[i++].Position = new Vector3(a, 0, -b);

                data[i].Color      = new Color3f(0, c, 0.5f);
                data[i++].Position = new Vector3(b, 0, a);
                data[i].Color      = new Color3f(0, c, 0.5f);
                data[i++].Position = new Vector3(-b, 0, a);
            }
            vertices        = Root.Instance.UserInterface.Renderer.CreateStaticVertexBuffer(data, (num + 1) * 4 * 2 * 3 * 4);
            vertices.Format = VertexFormat.VF_P3C3;

            shader = Root.Instance.ResourceManager.LoadShader("simple3d.shader");
        }
Example #17
0
        //----------------------------------CONSTRUCTOR---------------------------------//
        /**
         * Constructs a Object3d object based on a solid file.
         *
         * @param solid solid used to construct the Object3d object
         */
        public Object3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;
            Point3d[] verticesPoints = solid.getVertices();
            int[] indices = solid.getIndices();
            Color3f[] colors = solid.getColors();
            var verticesTemp = new List<Vertex>();

            Dictionary<int,int> revlookup = new Dictionary<int, int> ();
            for (int d=0; d<indices.Length; d++)
                revlookup [indices [d]] = d;

            //create vertices
            vertices = new List<Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                Color3f col = new Color3f(1, 1, 1);
                if(colors.Length > 0)
                    col = colors[i];

                vertex = addVertex(verticesPoints[i], col, Vertex.UNKNOWN);
                verticesTemp.Add(vertex);
            }

            //create faces
            faces = new List<Face>();
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                addFace(v1, v2, v3);
            }

            //create bound
            bound = new Bound(verticesPoints);
        }
Example #18
0
        public LensGlow(Section s)
        {
            foreach (Entry e in s)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    Nickname = e[0].ToString();
                    break;

                case "shape":
                    Shape = e[0].ToString();
                    break;

                case "radius_scale":
                    RadiusScale = e[0].ToInt32();
                    break;

                case "inner_color":
                    InnerColor = new Color3f(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "outer_color":
                    OuterColor = new Color3f(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "glow_fade_in_seconds":
                    GlowFadeInSeconds = e[0].ToSingle();
                    break;

                case "glow_fade_out_seconds":
                    GlowFadeOutSeconds = e[0].ToSingle();
                    break;
                }
            }
        }
Example #19
0
 /**
  * Constructs a solid based on a coordinates file. It contains vertices and indices,
  * and its format is like this:
  *
  * <br><br>4
  * <br>0 -5.00000000000000E-0001 -5.00000000000000E-0001 -5.00000000000000E-0001
  * <br>1  5.00000000000000E-0001 -5.00000000000000E-0001 -5.00000000000000E-0001
  * <br>2 -5.00000000000000E-0001  5.00000000000000E-0001 -5.00000000000000E-0001
  * <br>3  5.00000000000000E-0001  5.00000000000000E-0001 -5.00000000000000E-0001
  *
  * <br><br>2
  * <br>0 0 2 3
  * <br>1 3 1 0
  *
  * @param solidFile file containing the solid coordinates
  * @param color solid color
  */
 public Solid(FileInfo solidFile, Color3f color)
     : this()
 {
     loadCoordinateFile(solidFile, color);
 }
Example #20
0
 /**
  * Loads a coordinates file, setting vertices and indices
  *
  * @param solidFile file used to create the solid
  * @param color solid color
  */
 protected void loadCoordinateFile(FileInfo solidFile, Color3f color)
 {
     //            try
     //            {
     //                BufferedReader reader = new BufferedReader(new FileReader(solidFile));
     //
     //                String line = reader.readLine();
     //                int numVertices = Integer.parseInt(line);
     //                vertices = new Point3d[numVertices];
     //
     //                StringTokenizer tokens;
     //                String token;
     //
     //                for(int i=0;i<numVertices;i++)
     //                    {
     //                        line = reader.readLine();
     //                        tokens = new StringTokenizer(line);
     //                        tokens.nextToken();
     //                        vertices[i]= new Point3d(Double.parseDouble(tokens.nextToken()), Double.parseDouble(tokens.nextToken()), Double.parseDouble(tokens.nextToken()));
     //                    }
     //
     //                reader.readLine();
     //
     //                line = reader.readLine();
     //                int numTriangles = Integer.parseInt(line);
     //                indices = new int[numTriangles*3];
     //
     //                for(int i=0,j=0;i<numTriangles*3;i=i+3,j++)
     //                    {
     //                        line = reader.readLine();
     //                        tokens = new StringTokenizer(line);
     //                        tokens.nextToken();
     //                        indices[i] = Integer.parseInt(tokens.nextToken());
     //                        indices[i+1] = Integer.parseInt(tokens.nextToken());
     //                        indices[i+2] = Integer.parseInt(tokens.nextToken());
     //                    }
     //
     //                colors = new Color3f[vertices.Length];
     //                Arrays.fill(colors, color);
     //
     //                defineGeometry();
     //            }
     //
     //            catch(IOException e)
     //            {
     //                System.out.println("invalid file!");
     //                e.printStackTrace();
     //            }
 }
Example #21
0
 /**
  * Construct a solid based on data arrays. An exception may occur in the case of
  * abnormal arrays (indices making references to inexistent vertices, there are less
  * colors than vertices...)
  *
  * @param vertices array of points defining the solid vertices
  * @param indices array of indices for a array of vertices
  * @param colors array of colors defining the vertices colors
  */
 public Solid(Point3d[] vertices, int[] indices, Color3f[] colors)
     : this()
 {
     setData(vertices, indices, colors);
 }
Example #22
0
 public void drawString(Vec2 pos, string s, Color3f color)
 {
     drawString(pos.x, pos.y, s, color);
 }
Example #23
0
 /**
  * Sets the solid data. Defines the same color to all the vertices. An exception may
  * may occur in the case of abnormal arrays (e.g., indices making references to
  * inexistent vertices...)
  *
  * @param vertices array of points defining the solid vertices
  * @param indices array of indices for a array of vertices
  * @param color the color of the vertices (the solid color)
  */
 public void setData(Point3d[] vertices, int[] indices, Color3f color)
 {
     Color3f[] colors = new Color3f[vertices.Length];
     colors.fill(color);
     setData(vertices, indices, colors);
 }
Example #24
0
 public void Set(Color3f argColor)
 {
     X = argColor.X;
     Y = argColor.Y;
     Z = argColor.Z;
 }
Example #25
0
 public static Vec4f ToVec4f(this Color3f color)
 {
     return(new Vec4f(color.Red, color.Green, color.Blue, 1));
 }
Example #26
0
 /**
  * Draw a solid circle.
  * @param center
  * @param radius
  * @param axis
  * @param color
  */
 public abstract void drawSolidCircle(Vec2 center, double radius, Vec2 axis, Color3f color);
Example #27
0
 /**
  * Draw a circle.
  * @param center
  * @param radius
  * @param color
  */
 public abstract void drawCircle(Vec2 center, double radius, Color3f color);
Example #28
0
        /**
         * Constructs a vertex with unknown status
         *
         * @param x coordinate on the x axis
         * @param y coordinate on the y axis
         * @param z coordinate on the z axis
         * @param color vertex color
         */
        public Vertex(double x, double y, double z, Color3f color)
        {
            this.color = color.Clone();

            this.x = x;
            this.y = y;
            this.z = z;

            adjacentVertices = new List<Vertex>();
            status = UNKNOWN;
        }
Example #29
0
 /**
  * Draw a line segment.
  * @param p1
  * @param p2
  * @param color
  */
 public abstract void drawSegment(Vec2 p1, Vec2 p2, Color3f color);
Example #30
0
 public void DrawString(Vec2 pos, String s, Color3f color)
 {
     DrawString(pos.X, pos.Y, s, color);
 }
Example #31
0
        public static void Draw(List<Point> peaks, double width, double lenght, Direction direction, Color3f color)
        {
            float r = (float)(width / 2.0);
            float rCl = (float)(width / 6.0);
            float arrLen = (float)(lenght / 3.0);
            float step = (float)(Math.PI / 4);

            Gl.glColor3f(color.r, color.g, color.b);

            List<pntCircle> pointsCircle = new List<pntCircle>();

            for (double angle = 0; angle < 2 * Math.PI + step; angle += step)
            {
                pointsCircle.Add(new pntCircle((float)Math.Cos(angle), (float)Math.Sin(angle)));
            }

            ///!Оптимизировать
            switch (direction)
            {
               case Direction.Up:
                    foreach (Point peak in peaks)
                    {
                        Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                        Gl.glVertex3f(peak.x, peak.y, peak.z);
                        foreach (pntCircle pCr in pointsCircle)
                        {
                            Gl.glVertex3f(peak.x + r * pCr.cos, peak.y + r * pCr.sin, peak.z - arrLen);
                        }
                        Gl.glEnd();

                        Gl.glBegin(Gl.GL_QUAD_STRIP);
                        foreach (pntCircle pCr in pointsCircle)
                        {
                            Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + rCl * pCr.sin, peak.z - arrLen);
                            Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + rCl * pCr.sin, peak.z - (float)lenght);
                        }
                        Gl.glEnd();
                    }
                break;
                    case Direction.Down:
                foreach (Point peak in peaks)
                {
                    Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                    Gl.glVertex3f(peak.x, peak.y, peak.z);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + r * pCr.cos, peak.y + r * pCr.sin, peak.z + arrLen);
                    }
                    Gl.glEnd();

                    Gl.glBegin(Gl.GL_QUAD_STRIP);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + rCl * pCr.sin, peak.z + arrLen);
                        Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + rCl * pCr.sin, peak.z + (float)lenght);
                    }
                    Gl.glEnd();
                }
                break;
                case Direction.Forward:
                foreach (Point peak in peaks)
                {
                    Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                    Gl.glVertex3f(peak.x, peak.y, peak.z);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + r * pCr.cos,peak.y - arrLen, peak.z + r * pCr.sin);
                    }
                    Gl.glEnd();

                    Gl.glBegin(Gl.GL_QUAD_STRIP);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y - arrLen, peak.z + rCl * pCr.sin );
                        Gl.glVertex3f(peak.x + rCl * pCr.cos,peak.y - (float)lenght, peak.z + rCl * pCr.sin);
                    }
                    Gl.glEnd();
                }
                break;
                case Direction.Back:
                foreach (Point peak in peaks)
                {
                    Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                    Gl.glVertex3f(peak.x, peak.y, peak.z);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + r * pCr.cos, peak.y + arrLen, peak.z + r * pCr.sin);
                    }
                    Gl.glEnd();

                    Gl.glBegin(Gl.GL_QUAD_STRIP);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + arrLen, peak.z + rCl * pCr.sin);
                        Gl.glVertex3f(peak.x + rCl * pCr.cos, peak.y + (float)lenght, peak.z + rCl * pCr.sin);
                    }
                    Gl.glEnd();
                }
                break;
                case Direction.Right:
                foreach (Point peak in peaks)
                {
                    Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                    Gl.glVertex3f(peak.x, peak.y, peak.z);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x - arrLen, peak.y + r * pCr.cos, peak.z + r * pCr.sin);
                    }
                    Gl.glEnd();

                    Gl.glBegin(Gl.GL_QUAD_STRIP);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x - arrLen, peak.y + rCl * pCr.cos, peak.z + rCl * pCr.sin);
                        Gl.glVertex3f(peak.x - (float)lenght, peak.y + rCl * pCr.cos, peak.z + rCl * pCr.sin);
                    }
                    Gl.glEnd();
                }
                break;
                case Direction.Left:
                foreach (Point peak in peaks)
                {
                    Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                    Gl.glVertex3f(peak.x, peak.y, peak.z);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + arrLen, peak.y + r * pCr.cos, peak.z + r * pCr.sin);
                    }
                    Gl.glEnd();

                    Gl.glBegin(Gl.GL_QUAD_STRIP);
                    foreach (pntCircle pCr in pointsCircle)
                    {
                        Gl.glVertex3f(peak.x + arrLen, peak.y + rCl * pCr.cos, peak.z + rCl * pCr.sin);
                        Gl.glVertex3f(peak.x + (float)lenght, peak.y + rCl * pCr.cos, peak.z + rCl * pCr.sin);
                    }
                    Gl.glEnd();
                }
                break;
            }
        }
Example #32
0
 public DirectonalLight(Color3f diffuseColor, Vector3d direction) : base(diffuseColor)
 {
     _direction   = direction;
     DiffusePower = 1d;
 }
Example #33
0
 public void Set(Color3f argColor)
 {
     X = argColor.X;
     Y = argColor.Y;
     Z = argColor.Z;
 }
Example #34
0
        public static Color3f EaseColorRGB(EasingTypes type, float time, float t1, float t2, Color3f c1, Color3f c2)
        {
            float r = Ease(type, time, t1, t2, c1.R, c2.R);
            float g = Ease(type, time, t1, t2, c1.G, c2.G);
            float b = Ease(type, time, t1, t2, c1.B, c2.B);

            return(new Color3f(r, g, b));
        }
        public virtual Color GetColor(Vector3d direction, IIntersectionResult intersectionResult, Scene scene)
        {
            Color3f result = new Color3f();

            Color3f surfaceColor = Material.Texture != null?Material.Texture.GetColor(GetUVCoordinates(intersectionResult), 0) : Material.Color;

            Color3f reflectionColor = new Color3f();

            if (Material.Reflection > 0.0f)
            {
                // Reflection
                Vector3d reflectionVector = VectorHelpers.GetReflectionVector(direction, GetNormal(intersectionResult));

                IIntersectionResult reflectionIntersectionResult = scene.GetNearestObjectIntersection(reflectionVector, intersectionResult.Intersection, this);

                if (reflectionIntersectionResult != null)
                {
                    reflectionColor = new Color3f(reflectionIntersectionResult.Object.GetColor(direction, reflectionIntersectionResult, scene));
                }
            }

            if (scene.Lights.Count == 0)
            {
                return(surfaceColor.ToColor());
            }

            foreach (AbstractLight light in scene.Lights)
            {
                bool lightVisible = true;

                if (light.Position != null)
                {
                    Vector3d lightDistanceVector = light.Position - intersectionResult.Intersection;
                    double   lightDistance       = lightDistanceVector.Length();

                    foreach (AbstractObject3d o in scene.Objects)
                    {
                        if (o.GetTopParent() == this.GetTopParent())
                        {
                            continue;
                        }

                        IIntersectionResult lightIntersectionResult = o.Intersection(Vector3d.Normalize(lightDistanceVector), intersectionResult.Intersection);

                        if (lightIntersectionResult != null)
                        {
                            if (lightIntersectionResult.IntersectionDistance < lightDistance)
                            {
                                lightVisible = false;
                                break;
                            }
                        }
                    }
                }

                if (!lightVisible)
                {
                    continue;
                }

                Vector3d normal         = GetNormal(intersectionResult);
                Vector3d lightDirection = -light.GetDirection(intersectionResult.Intersection);

                double distanceSquared = light.GetDistance(intersectionResult.Intersection);
                distanceSquared *= distanceSquared;

                double normalDotLightDirection = normal.Dot(lightDirection);
                double diffuseIntensity        = ScalarHelpers.Saturate(normalDotLightDirection);

                Color3f diffuse = diffuseIntensity * light.DiffuseColor * light.DiffusePower / distanceSquared;

                Vector3d halfwayVector = (lightDirection - direction).Normalize();

                double normalDotHalfwayVector = normal.Dot(halfwayVector);
                double specularIntensity      = System.Math.Pow(ScalarHelpers.Saturate(normalDotHalfwayVector), 16f);

                Color3f specular = specularIntensity * light.SpecularColor * light.SpecularPower / distanceSquared;

                //return (surfaceColor * (diffuse + specular)).ToColor();
                result += diffuse + specular;
            }

            return((((surfaceColor * result) * (1.0 - Material.Reflection)) + (reflectionColor * Material.Reflection)).ToColor());
        }
Example #36
0
        /**
         * Constructs a vertex with a definite status
         *
         * @param x coordinate on the x axis
         * @param y coordinate on the y axis
         * @param z coordinate on the z axis
         * @param color vertex color
         * @param status vertex status - UNKNOWN, BOUNDARY, INSIDE or OUTSIDE
         */
        public Vertex(double x, double y, double z, Color3f color, int status)
        {
            this.color = color.Clone();

            this.x = x;
            this.y = y;
            this.z = z;

            adjacentVertices = new List<Vertex>();
            this.status = status;
        }
Example #37
0
 public virtual void set_Renamed(Color3f argColor)
 {
     x = argColor.x;
     y = argColor.y;
     z = argColor.z;
 }
Example #38
0
 /**
  * Draw a solid closed polygon provided in CCW order.
  * @param vertices
  * @param vertexCount
  * @param color
  */
 public abstract void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color);
Example #39
0
        //--------------------------PRIVATES--------------------------------------------//
        /**
         * Composes a solid based on the faces status of the two operators solids:
         * Face.INSIDE, Face.OUTSIDE, Face.SAME, Face.OPPOSITE
         *
         * @param faceStatus1 status expected for the first solid faces
         * @param faceStatus2 other status expected for the first solid faces
         * (expected a status for the faces coincident with second solid faces)
         * @param faceStatus3 status expected for the second solid faces
         */
        private Solid composeSolid(int faceStatus1, int faceStatus2, int faceStatus3)
        {
            var vertices = new List<Vertex>();
            var indices = new List<int>();
            var colors = new List<Color3f>();

            //group the elements of the two solids whose faces fit with the desired status
            groupObjectComponents(object1, vertices, indices, colors, faceStatus1, faceStatus2);
            groupObjectComponents(object2, vertices, indices, colors, faceStatus3, faceStatus3);

            //turn the arrayLists to arrays
            Point3d[] verticesArray = new Point3d[vertices.Count];
            for (int i = 0; i < vertices.Count; i++)
            {
                verticesArray[i] = vertices[i].getPosition();
            }
            int[] indicesArray = new int[indices.Count];
            for (int i = 0; i < indices.Count; i++)
            {
                indicesArray[i] = indices[i];
            }
            Color3f[] colorsArray = new Color3f[colors.Count];
            for (int i = 0; i < colors.Count; i++)
            {
                colorsArray[i] = colors[i].Clone();
            }

            //returns the solid containing the grouped elements
            return new Solid(verticesArray, indicesArray, colorsArray);
        }
Example #40
0
 /**
  * Draw a string.
  * @param x
  * @param y
  * @param s
  * @param color
  */
 public abstract void drawString(double x, double y, string s, Color3f color);
Example #41
0
        public Nebula(StarSystem parent, Section section, FreelancerData data)
            : base(parent, section, data)
        {
            ExteriorShape = new List <string>();
            NebulaLights  = new List <NebulaLight>();


            foreach (Section s in ParseFile(data.Freelancer.DataPath + file, data.VFS))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "texturepanels":
                    TexturePanels = new TexturePanelsRef(s, data);
                    break;

                case "properties":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "flag":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            Properties.Add(e[0].ToString());
                            break;

                        default:
                            FLLog.Warning("Ini", "Invalid Entry in " + s.Name + ": " + e.Name);
                            break;
                        }
                    }
                    break;

                case "fog":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "fog_enabled":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogEnabled != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogEnabled = e[0].ToInt32();
                            break;

                        case "near":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogNear != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogNear = e[0].ToInt32();
                            break;

                        case "distance":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogDistance = e[0].ToInt32();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "opacity":
                            FLLog.Warning("Nebula", "unimplemented fog opacity");
                            break;

                        case "max_alpha":
                            FLLog.Warning("Nebula", "unimplemented max alpha");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "exclusion zones":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "exclusion":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            ExclusionZones.Add(new ExclusionZone(parent, e[0].ToString()));
                            break;

                        case "fog_far":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].FogFar = e[0].ToSingle();
                            break;

                        case "fog_near":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].FogNear = e[0].ToSingle();
                            break;

                        case "zone_shell":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ZoneShellPath = e[0].ToString();
                            break;

                        case "shell_scalar":
                            //if (e.Count != 1) throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ShellScalar = e[0].ToSingle();
                            break;

                        case "max_alpha":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].MaxAlpha = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Color = new Color4(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, 1f);
                            break;

                        case "exclusion_tint":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Tint = new Color3f(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f);
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "exterior":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "shape":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            ExteriorShape.Add(e[0].ToString());
                            break;

                        case "shape_weights":
                            //if (e.Count != 4) throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            if (ExteriorShapeWeights != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorShapeWeights = new List <int>();
                            foreach (IValue i in e)
                            {
                                ExteriorShapeWeights.Add(i.ToInt32());
                            }
                            break;

                        case "fill_shape":
                            if (e.Count == 0)
                            {
                                FLLog.Warning("Nebula", "empty fill_shape in " + file);
                                break;
                            }
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorFillShape != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorFillShape = e[0].ToString();
                            break;

                        case "plane_slices":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorPlaneSlices != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorPlaneSlices = e[0].ToInt32();
                            break;

                        case "bit_radius":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorBitRadius != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorBitRadius = e[0].ToInt32();
                            break;

                        case "bit_radius_random_variation":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorBitRadiusRandomVariation != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorBitRadiusRandomVariation = e[0].ToSingle();
                            break;

                        case "min_bits":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMinBits != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMinBits = e[0].ToInt32();
                            break;

                        case "max_bits":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMaxBits != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMaxBits = e[0].ToInt32();
                            break;

                        case "move_bit_percent":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMoveBitPercent != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMoveBitPercent = e[0].ToSingle();
                            break;

                        case "equator_bias":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorEquatorBias != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorEquatorBias = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "opacity":
                            FLLog.Warning("Nebula", "Exterior opacity not implemented");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "nebulalight":
                    NebulaLights.Add(new NebulaLight(s));
                    break;

                case "clouds":
                    if (CloudsMaxDistance != null)
                    {
                        FLLog.Warning("Ini", "Multiple [Clouds] in Nebula " + ZoneName);
                        break;
                    }
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "max_distance":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsMaxDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsMaxDistance = e[0].ToInt32();
                            break;

                        case "puff_count":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffCount != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffCount = e[0].ToInt32();
                            break;

                        case "puff_radius":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffRadius != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffRadius = e[0].ToInt32();
                            break;

                        case "puff_cloud_size":
                            FLLog.Warning("Nebula", "puff_cloud_size unimplemented");
                            break;

                        case "puff_colora":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffColorA != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffColorA = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                            break;

                        case "puff_colorb":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffColorB != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffColorB = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                            break;

                        case "puff_max_alpha":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffMaxAlpha != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffMaxAlpha = e[0].ToSingle();
                            break;

                        case "puff_shape":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffShape == null)
                            {
                                CloudsPuffShape = new List <string>();
                            }
                            CloudsPuffShape.Add(e[0].ToString());
                            break;

                        case "puff_weights":
                            if (e.Count != 4)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffWeights != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffWeights = new List <int>();
                            foreach (IValue i in e)
                            {
                                CloudsPuffWeights.Add(i.ToInt32());
                            }
                            break;

                        case "puff_drift":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffDrift != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffDrift = e[0].ToSingle();
                            break;

                        case "near_fade_distance":
                            if (e.Count != 2)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsNearFadeDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsNearFadeDistance = new Vector2(e[0].ToSingle(), e[1].ToSingle());
                            break;

                        case "lightning_intensity":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningIntensity != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningIntensity = e[0].ToSingle();
                            break;

                        case "lightning_color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "lightning_gap":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningGap = e[0].ToSingle();
                            break;

                        case "lightning_duration":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningDuration = e[0].ToSingle();
                            break;

                        case "disable_clouds":
                            FLLog.Warning("Nebula", "disable_clouds not implemented");
                            break;

                        case "zwrite_clouds":
                            FLLog.Warning("Nebula", "disable_clouds not implemented");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "backgroundlightning":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "duration":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningDuration = e[0].ToSingle();
                            break;

                        case "gap":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningGap = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningColor = BackgroundLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "dynamiclightning":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "gap":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningGap = e[0].ToSingle();
                            break;

                        case "duration":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningDuration = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "ambient_intensity":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningAmbientIntensity != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningAmbientIntensity = e[0].ToSingle();
                            break;

                        case "intensity_increase":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningIntensityIncrease != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningIntensityIncrease = e[0].ToInt32();
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                default:
                    throw new Exception("Invalid Section in " + file + ": " + s.Name);
                }
            }
        }
Example #42
0
 /** Gets the vertices colors
  *
  * @return vertices colors
  */
 public Color3f[] getColors()
 {
     Color3f[] newColors = new Color3f[colors.Length];
     for (int i = 0; i < newColors.Length; i++)
     {
         newColors[i] = colors[i];
     }
     return newColors;
 }
Example #43
0
        /**
         * Constructs a vertex with definite status
         *
         * @param position vertex position
         * @param color vertex color
         * @param status vertex status - UNKNOWN, BOUNDARY, INSIDE or OUTSIDE
         */
        public Vertex(Point3d position, Color3f color, int status)
        {
            this.color = color.Clone();

            x = position.x;
            y = position.y;
            z = position.z;

            adjacentVertices = new List<Vertex>();
            this.status = status;
        }
Example #44
0
        //---------------------------------------SETS-----------------------------------//
        /**
         * Sets the solid data. Each vertex may have a different color. An exception may
         * occur in the case of abnormal arrays (e.g., indices making references to
         * inexistent vertices, there are less colors than vertices...)
         *
         * @param vertices array of points defining the solid vertices
         * @param indices array of indices for a array of vertices
         * @param colors array of colors defining the vertices colors
         */
        public void setData(Point3d[] vertices, int[] indices, Color3f[] colors)
        {
            this.vertices = new Point3d[vertices.Length];
            this.colors = new Color3f[colors.Length];
            this.indices = new int[indices.Length];
            if (indices.Length != 0)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    this.vertices[i] = vertices[i].Clone();
                    this.colors[i] = colors[i].Clone();
                }
                Array.Copy(indices, 0, this.indices, 0, indices.Length);

                defineGeometry();
            }
        }
Example #45
0
 public void set(Color3f argColor)
 {
     x = argColor.x;
     y = argColor.y;
     z = argColor.z;
 }
Example #46
0
 public abstract void drawPoint(Vec2 argPoint, double argRadiusOnScreen, Color3f argColor);
Example #47
0
        /*public Ecliptic()
            : this(new Color3f(1, 1, 1), 10000, 100)
        {
        }*/
        public Ecliptic(Color3f color, float size, int num)
        {
            if (Root.Instance.UserInterface == null)
                return;

            VertexP3C3[] data = new VertexP3C3[(num + 1) * 4];
            int i = 0;
            material = Material.CreateSimpleMaterial(null);
            material.DepthTest = true;
            material.DepthWrite = true;
            material.Additive = true;

            for (int x = 0; x <= num; ++x)
            {
                float c = (float)x / (float)num;
                float a = c * size - size / 2;
                float b = size / 2;
                c /= 6;

                data[i].Color = new Color3f(c, 0, 0.5f);
                data[i++].Position = new Vector3(a, 0, b);
                data[i].Color = new Color3f(c, 0, 0.5f);
                data[i++].Position = new Vector3(a, 0, -b);

                data[i].Color = new Color3f(0, c, 0.5f);
                data[i++].Position = new Vector3(b, 0, a);
                data[i].Color = new Color3f(0, c, 0.5f);
                data[i++].Position = new Vector3(-b, 0, a);
            }
            vertices = Root.Instance.UserInterface.Renderer.CreateStaticVertexBuffer(data, (num + 1) * 4 * 2 * 3 * 4);
            vertices.Format = VertexFormat.VF_P3C3;

            shader = Root.Instance.ResourceManager.LoadShader("simple3d.shader");
        }
Example #48
0
 /**
  * Method used to add a vertex properly for internal methods
  *
  * @param pos vertex position
  * @param color vertex color
  * @param status vertex status
  * @return the vertex inserted (if a similar vertex already exists, this is returned)
  */
 private Vertex addVertex(Point3d pos, Color3f color, int status)
 {
     int i;
     //if already there is an equal vertex, it is not inserted
     Vertex vertex = new Vertex(pos, color, status);
     for (i = 0; i < vertices.Count; i++)
     {
         if (vertex.equals(vertices[i]))
             break;
     }
     if (i == vertices.Count)
     {
         vertices.Add(vertex);
         return vertex;
     }
     else
     {
         vertex = vertices[i];
         vertex.setStatus(status);
         return vertex;
     }
 }