Ejemplo n.º 1
0
 public void setTransparency(uint factor)
 {
     transparency = MathUtility.Crop(factor, 0, 255);
     opaque       = (transparency == 0);
 }
Ejemplo n.º 2
0
 public void setReflectivity(uint factor)
 {
     reflectivity = MathUtility.Crop(factor, 0, 255);
 }
Ejemplo n.º 3
0
        void drawLine(Vertex a, Vertex b, uint color)
        {
            Vertex temp;

            if ((a.clipcode & b.clipcode) != 0)
            {
                return;
            }

            dx = Math.Abs(a.X - b.X);
            dy = Math.Abs(a.Y - b.Y);
            dz = 0;

            if (dx > dy)
            {
                if (a.X > b.X)
                {
                    temp = a; a = b; b = temp;
                }
                if (dx > 0)
                {
                    dz = (b.Z - a.Z) / dx;
                    dy = ((b.Y - a.Y) << 16) / dx;
                }
                z = a.Z;
                y = a.Y << 16;
                var bX = b.X;
                int xPlusOffset;
                for (x = a.X; x <= bX; x++)
                {
                    y2 = y >> 16;
                    if (MathUtility.inrange(x, 0, width - 1) && MathUtility.inrange(y2, 0, height - 1))
                    {
                        offset      = y2 * width;
                        xPlusOffset = x + offset;
                        if (z < zBuffer[xPlusOffset])
                        {
                            if (!screen.antialias)
                            {
                                screen.p[xPlusOffset] = color;
                                zBuffer[xPlusOffset]  = (uint)z;
                            }
                            else
                            {
                                screen.p[xPlusOffset]             = color;
                                screen.p[xPlusOffset + 1]         = color;
                                screen.p[xPlusOffset + width]     = color;
                                screen.p[xPlusOffset + width + 1] = color;
                                zBuffer[xPlusOffset] = (uint)z;
                            }
                        }
                        if (useIdBuffer)
                        {
                            idBuffer[xPlusOffset] = currentId;
                        }
                    }
                    z += dz; y += dy;
                }
            }
            else
            {
                if (a.Y > b.Y)
                {
                    temp = a; a = b; b = temp;
                }
                if (dy > 0)
                {
                    dz = (b.Z - a.Z) / dy;
                    dx = ((b.X - a.X) << 16) / dy;
                }
                z = a.Z;
                x = a.X << 16;
                int bY = b.Y;
                int x2PlusOffset;
                for (y = a.Y; y <= bY; y++)
                {
                    x2 = x >> 16;
                    if (MathUtility.inrange(x2, 0, width - 1) && MathUtility.inrange(y, 0, height - 1))
                    {
                        offset       = y * width;
                        x2PlusOffset = x2 + offset;
                        if (z < zBuffer[x2PlusOffset])
                        {
                            if (!screen.antialias)
                            {
                                screen.p[x2PlusOffset] = color;
                                zBuffer[x2PlusOffset]  = (uint)z;
                            }
                            else
                            {
                                screen.p[x2PlusOffset]             = color;
                                screen.p[x2PlusOffset + 1]         = color;
                                screen.p[x2PlusOffset + width]     = color;
                                screen.p[x2PlusOffset + width + 1] = color;
                                zBuffer[x2PlusOffset] = (uint)z;
                            }
                        }
                        if (useIdBuffer)
                        {
                            idBuffer[x2PlusOffset] = currentId;
                        }
                    }
                    z += dz; x += dx;
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a random vector.
 /// </summary>
 /// <param name="fact"></param>
 /// <returns></returns>
 public static Vector Random(float fact)
 {
     return(new Vector(fact * MathUtility.Random(), fact * MathUtility.Random(), fact * MathUtility.Random()));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Builds the cartesian coordinates out of the given cylindric coordinates.
 /// </summary>
 public void BuildCartesian()
 {
     X = R * MathUtility.Cos(Theta);
     Y = R * MathUtility.Sin(Theta);
 }
Ejemplo n.º 6
0
 public void setFov(float fov)
 {
     fovfact = (float)Math.Tan(MathUtility.DegreesToRadians(fov) * 0.5);
 }
Ejemplo n.º 7
0
 public void clear(uint bgcolor)
 {
     MathUtility.clearBuffer(p, bgcolor);
 }