private void AddToDraw(HyperLine projectedTriangle, float depth)
        {
            if (primitiveCount == privitiveBuffer.Length)
            {
                int newBufferSize = primitiveCount * 2;
                Array.Resize(ref privitiveBuffer, newBufferSize);
                Array.Resize(ref depthBuffer, newBufferSize);
            }

            privitiveBuffer[primitiveCount] = projectedTriangle;
            depthBuffer[primitiveCount]     = depth;
            primitiveCount++;
        }
        public void Draw(HyperLine value, Matrix <float> worldViewProjection)
        {
            if (!drawMode)
            {
                throw new InvalidOperationException("Begin must be called.");
            }

            HyperLine triangle = value;

            if (TryProjectPrimitive(ref triangle, worldViewProjection))
            {
                float depth = (triangle.Start.W + triangle.End.W) / 2f;
                AddToDraw(triangle, depth);
            }
        }
        private bool TryProjectPrimitive(ref HyperLine hyperLine, Matrix <float> worldViewProjection)
        {
            Vector4 u = new Vector4();

            var pStart = ProjectVector(hyperLine.Start, worldViewProjection, out u.X);
            var pEnd   = ProjectVector(hyperLine.End, worldViewProjection, out u.Y);

            const float epsilon = float.Epsilon;

            if (u.X < epsilon || u.Y < epsilon)
            {
                return(false);
            }

            pStart /= u.X;
            pEnd   /= u.Y;

            hyperLine = new HyperLine(pStart, pEnd, hyperLine.Color);
            return(true);
        }
Пример #4
0
 public bool Equals(HyperLine other)
 {
     return(Start == other.Start && End == other.End && Color == other.Color);
 }