private void ConstructFaceNormal(MeshGeometry3D themesh, int faceindex)
        {
            Point3D  centroid   = Tools3D.ComputeTriangleCentroid(themesh, faceindex);
            Vector3D facenormal = Tools3D.ComputeTriangleNormal(themesh, faceindex);

            ConstructAnnotationArrow(centroid, facenormal, CONTAINERfacenormals);
        }
        private void ConstructVertexNormalsMatchingFaceNormal(MeshGeometry3D themesh, int faceindex)
        {
            Vector3D facenormal = Tools3D.ComputeTriangleNormal(themesh, faceindex);

            ConstructAnnotationArrow(themesh.Positions[themesh.TriangleIndices[faceindex * 3]], facenormal, CONTAINERfacenormals);
            ConstructAnnotationArrow(themesh.Positions[themesh.TriangleIndices[faceindex * 3 + 1]], facenormal, CONTAINERfacenormals);
            ConstructAnnotationArrow(themesh.Positions[themesh.TriangleIndices[faceindex * 3 + 2]], facenormal, CONTAINERfacenormals);
        }
        private void ConstructVertexNormalsForTwoFaceSituation(MeshGeometry3D themesh)
        {
            Vector3D facenormal0 = Tools3D.ComputeTriangleNormal(themesh, 0);
            Vector3D facenormal1 = Tools3D.ComputeTriangleNormal(themesh, 1);

            // The edge vertices (non-shared) use the face normal as-is
            ConstructAnnotationArrow(themesh.Positions[1], facenormal0, CONTAINERfacenormals);
            ConstructAnnotationArrow(themesh.Positions[3], facenormal1, CONTAINERfacenormals);

            // The shared vertices 0 and 2 use the average of the two normals.
            Vector3D normalavgd = (facenormal0 + facenormal1);

            normalavgd.Normalize();
            ConstructAnnotationArrow(themesh.Positions[0], normalavgd, CONTAINERfacenormals);
            ConstructAnnotationArrow(themesh.Positions[2], normalavgd, CONTAINERfacenormals);
        }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        index = mainCounter;
        mainCounter++;

        // VectorLine.SetEndCap("Arrow", EndCap.Front, axisEndCapTexture, axisEndCapTexture);

        List <Vector3> ptsXY = new List <Vector3>();
        List <Vector3> ptsXZ = new List <Vector3>();
        List <Vector3> ptsYZ = new List <Vector3>();

        //GRID XY
        if (displayGridXY)
        {
            for (int i = 1; i <= gridNSteps; i++)
            {
                ptsXY.Add(new Vector3(0, i * gridDelta, 0));
                ptsXY.Add(new Vector3((gridNSteps + 1) * gridDelta, i * gridDelta, 0));
                ptsXY.Add(new Vector3(i * gridDelta, 0, 0));
                ptsXY.Add(new Vector3(i * gridDelta, (gridNSteps + 1) * gridDelta, 0));
            }
            gridXY       = new VectorLine("gridXY", ptsXY, gridThickness);
            gridXY.color = new Color(1, 1, 1, gridXYAlpha);
        }
        if (displayGridXZ)
        {
            //GRID XZ
            for (int i = 1; i <= gridNSteps; i++)
            {
                ptsXZ.Add(new Vector3(i * gridDelta, 0, 0));
                ptsXZ.Add(new Vector3(i * gridDelta, 0, (gridNSteps + 1) * gridDelta));
                ptsXZ.Add(new Vector3(0, 0, i * gridDelta));
                ptsXZ.Add(new Vector3((gridNSteps + 1) * gridDelta, 0, i * gridDelta));
            }
            gridXZ       = new VectorLine("gridXZ", ptsXZ, gridThickness);
            gridXZ.color = new Color(1, 1, 1, gridXZAlpha);
        }

        if (displayGridYZ)
        {
            //GRID YZ
            for (int i = 1; i <= gridNSteps; i++)
            {
                ptsYZ.Add(new Vector3(0, i * gridDelta, 0));
                ptsYZ.Add(new Vector3(0, i * gridDelta, (gridNSteps + 1) * gridDelta));
                ptsYZ.Add(new Vector3(0, 0, i * gridDelta));
                ptsYZ.Add(new Vector3(0, (gridNSteps + 1) * gridDelta, i * gridDelta));
            }
            gridYZ       = new VectorLine("gridYZ", ptsYZ, gridThickness);
            gridYZ.color = new Color(1, 1, 1, gridYZAlpha);
        }

        axisX = new VectorLine("axisX", new List <Vector3>()
        {
            new Vector3(0, 0, 0),
            new Vector3(axisLength, 0, 0)
        }, axisThickness);
        axisX.color = axisXColor;

        // axisX.endCap = "Arrow";

        axisY = new VectorLine("axisY", new List <Vector3>()
        {
            new Vector3(0, 0, 0),
            new Vector3(0, axisLength, 0)
        }, axisThickness);
        axisY.color = axisYColor;

        axisZ = new VectorLine("axisZ", new List <Vector3>()
        {
            new Vector3(0, 0, 0),
            new Vector3(0, 0, axisLength)
        }, axisThickness);
        axisZ.color = axisZColor;

        if (displayNegativeAxis)
        {
            axisNegX = new VectorLine("axisNegX",
                                      Tools3D.CreateDashedLine(Vector3.zero, new Vector3(-axisLength, 0, 0), .5f, .5f),
                                      axisThickness);
            axisNegX.color = new Color(axisXColor.r, axisXColor.g, axisXColor.b, axisXColor.a * .5f);

            axisNegY = new VectorLine("axisNegY",
                                      Tools3D.CreateDashedLine(Vector3.zero, new Vector3(0, -axisLength, 0), .5f, .5f),
                                      axisThickness);
            axisNegY.color = new Color(axisYColor.r, axisYColor.g, axisYColor.b, axisYColor.a * .5f);

            axisNegZ = new VectorLine("axisNegZ",
                                      Tools3D.CreateDashedLine(Vector3.zero, new Vector3(0, 0, -axisLength), .5f, .5f),
                                      axisThickness);
            axisNegZ.color = new Color(axisZColor.r, axisZColor.g, axisZColor.b, axisZColor.a * .5f);
        }

        if (displayXYZ)
        {
            letterX = new VectorLine("letterX", new List <Vector3>()
            {
                new Vector3(0, 0, 0),
                new Vector3(axisLength, 0, 0)
            }, 1f);
            letterX.MakeText("X", new Vector3(axisLength + .5f, .5f, 0), 1);
            letterX.color = Color.red;

            letterY = new VectorLine("letterY", new List <Vector3>()
            {
                new Vector3(0, 0, 0),
                new Vector3(axisLength, 0, 0)
            }, 1f);
            letterY.MakeText("Y", new Vector3(-.25f, axisLength + 1.5f, 0), 1);
            letterY.color = Color.green;

            letterZ = new VectorLine("letterZ", new List <Vector3>()
            {
                new Vector3(0, 0, 0),
                new Vector3(axisLength, 0, 0)
            }, 1f);
            letterZ.MakeText("Z", new Vector3(0, .5f, axisLength + .5f), 1);
            letterZ.color = Color.blue;
        }

        if (displaySphericalEnds)
        {
            sphericalEnds = new List <Transform>();

            //on s'occupe de l'axe Ox
            sphericalEnds.Add(CreateSphere(Color.red, Vector3.right * axisLength, .5f).transform);
            if (traceXEndPos)
            {
                GameObject tracerGO = Instantiate(tracersPrefabs[0]) as GameObject;
                tracerGO.transform.parent        = sphericalEnds[sphericalEnds.Count - 1];
                tracerGO.transform.localPosition = Vector3.zero;
            }

            //on s'occupe de l'axe Oy
            sphericalEnds.Add(CreateSphere(Color.green, Vector3.up * axisLength, .5f).transform);
            if (traceYEndPos)
            {
                GameObject tracerGO = Instantiate(tracersPrefabs[1]) as GameObject;
                tracerGO.transform.parent        = sphericalEnds[sphericalEnds.Count - 1];
                tracerGO.transform.localPosition = Vector3.zero;
            }

            //on s'occupe de l'axe Oz
            sphericalEnds.Add(CreateSphere(Color.blue, Vector3.forward * axisLength, .5f).transform);
            if (traceZEndPos)
            {
                GameObject tracerGO = Instantiate(tracersPrefabs[2]) as GameObject;
                tracerGO.transform.parent        = sphericalEnds[sphericalEnds.Count - 1];
                tracerGO.transform.localPosition = Vector3.zero;
            }
        }
    }