コード例 #1
0
        private void UpdateBasedOnCoordinates(
            uint triAddress, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3)
        {
            if (triAddress == 0)
            {
                return;
            }

            // update norms
            (float normX, float normY, float normZ, float normOffset) =
                TriangleUtilities.GetNorms(x1, y1, z1, x2, y2, z2, x3, y3, z3);
            Config.Stream.SetValue(normX, triAddress + TriangleOffsetsConfig.NormX);
            Config.Stream.SetValue(normY, triAddress + TriangleOffsetsConfig.NormY);
            Config.Stream.SetValue(normZ, triAddress + TriangleOffsetsConfig.NormZ);
            TriangleOffsetsConfig.SetNormalOffset(normOffset, triAddress);

            // update y bounds
            short yMinMinus5 = (short)(MoreMath.Min(y1, y2, y3) - 5);
            short yMaxPlus5  = (short)(MoreMath.Max(y1, y2, y3) + 5);

            Config.Stream.SetValue(yMinMinus5, triAddress + TriangleOffsetsConfig.YMinMinus5);
            Config.Stream.SetValue(yMaxPlus5, triAddress + TriangleOffsetsConfig.YMaxPlus5);

            // update x projection
            bool xProjection = normX <-0.707 || normX> 0.707;

            Config.Stream.SetValue(
                (byte)(xProjection ? TriangleOffsetsConfig.XProjectionMask : 0),
                triAddress + TriangleOffsetsConfig.Flags,
                mask: TriangleOffsetsConfig.XProjectionMask);
        }
コード例 #2
0
        private void UpdateBasedOnCoordinates(
            uint triAddress, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3)
        {
            if (triAddress == 0)
            {
                return;
            }

            // update norms
            (float normX, float normY, float normZ, float normOffset) =
                TriangleUtilities.GetNorms(x1, y1, z1, x2, y2, z2, x3, y3, z3);
            Config.Stream.SetValue(normX, triAddress + TriangleOffsetsConfig.NormX);
            Config.Stream.SetValue(normY, triAddress + TriangleOffsetsConfig.NormY);
            Config.Stream.SetValue(normZ, triAddress + TriangleOffsetsConfig.NormZ);
            Config.Stream.SetValue(normOffset, triAddress + TriangleOffsetsConfig.NormOffset);

            // update y bounds
            short yMinMinus5 = (short)(MoreMath.Min(y1, y2, y3) - 5);
            short yMaxPlus5  = (short)(MoreMath.Max(y1, y2, y3) + 5);

            Config.Stream.SetValue(yMinMinus5, triAddress + TriangleOffsetsConfig.YMinMinus5);
            Config.Stream.SetValue(yMaxPlus5, triAddress + TriangleOffsetsConfig.YMaxPlus5);
        }
コード例 #3
0
        public TriangleShape(
            double x1,
            double y1,
            double z1,
            double x2,
            double y2,
            double z2,
            double x3,
            double y3,
            double z3)
        {
            X1 = x1;
            Y1 = y1;
            Z1 = z1;
            X2 = x2;
            Y2 = y2;
            Z2 = z2;
            X3 = x3;
            Y3 = y3;
            Z3 = z3;

            (NormX, NormY, NormZ, NormOffset) = TriangleUtilities.GetNorms((int)X1, (int)Y1, (int)Z1, (int)X2, (int)Y2, (int)Z2, (int)X3, (int)Y3, (int)Z3);
        }