コード例 #1
0
        private Vector3 evalVertex(CPNSideEdge sidedEdgeA,
                                   CPNSideEdge sidedEdgeB, float U, float V)
        {
            //int backBIndex = bufferPrev.N - Bindex;

            evaluator.EvalAt(0, sidedEdgeA);
            Vector3 v0  = evaluator.EvalVertex(sidedEdgeA);
            Vector3 dA0 = evaluator.EvalDev(sidedEdgeA);

            evaluator.EvalAt(U, sidedEdgeA);
            Vector3 vA = evaluator.EvalVertex(sidedEdgeA);
            Vector3 nA = evaluator.EvalNormal(sidedEdgeA);

            evaluator.EvalAt(1 - V, sidedEdgeB);
            Vector3 vB = evaluator.EvalVertex(sidedEdgeB);
            Vector3 nB = evaluator.EvalNormal(sidedEdgeB);

            evaluator.EvalAt(1, sidedEdgeB);
            Vector3 dB0 = -evaluator.EvalDev(sidedEdgeB);

            float   kA    = -Vector3.Dot(dB0, nA);
            Vector3 part1 = vA + /*sidedEdgeA.guide[0].thickness **/ ((vB - v0) + kA * V * nA);

            float   kB    = -Vector3.Dot(dA0, nB);
            Vector3 part2 = vB + /*sidedEdgeB.guide[0].thickness * */ ((vA - v0) + kB * U * nB);

            float U2 = U * U;
            float V2 = V * V;

            return((part1 * U2 + part2 * V2) / (U2 + V2));
        }
コード例 #2
0
        public void writeWithGuideBack(CPNSideEdge guide, int N, float step, OutputMesh mesh,
                                       CPNGuideEvaluator evaluator)
        {
            this.step = step;
            requestSize(N + 1);

            //We should have only one thickness on multisided edge, you know?
            this.thickness = 1;

            for (int i = 0; i <= N; i++)
            {
                //This is the eval-back
                evaluator.EvalAt(1.0f - i * step, guide);
                Vector3 dev = evaluator.EvalDev(guide);
                vertices[i] = evaluator.EvalVertex(guide);
                if (i == 0)
                {
                    devFirst = dev;
                }
                if (i == N)
                {
                    devLast = dev;
                }
                evaluator.EvalAt(i * step + DELTA, guide);
                verticesDplus[i] = evaluator.EvalVertex(guide);
                evaluator.EvalAt(i * step - DELTA, guide);
                verticesDminus[i] = evaluator.EvalVertex(guide);
                normals[i]        = evaluator.EvalNormal(guide, dev).normalized;
                uvs[i]            = evaluator.EvalUV(guide);
                for (int k = 0; k < countP; k++)
                {
                    properties[k][i] = evaluator.EvalProperty(guide, k);
                }
            }
        }