Ejemplo n.º 1
0
    private void DrawDirections()
    {
        if (splineMono.Initialized())
        {
            Handles.color = Color.green;

            Vector3 point = splineMono.GetPositionAtTime(0f);
            Handles.DrawLine(point, point + splineMono.GetOrientationAtTime(0f) * directionScale);
            int steps = splineMono.Breaks * splineMono.Curves.Count;
            for (float t = 0; t <= splineMono.Curves.Count; t += 1 / (float)splineMono.Breaks)
            {
                point = splineMono.GetPositionAtTime(t);
                Handles.DrawLine(point, point + splineMono.GetOrientationAtTime(t) * directionScale);
            }

            /*for (int i = 1; i <= steps; i++)
             * {
             *  point = spline.GetPositionAtTime(i / (float)spline.breaks);
             *  Handles.DrawLine(point, point + spline.GetOrientationAtTime(i / (float)steps) * directionScale);
             * }*/
        }
    }
Ejemplo n.º 2
0
    public void Generate()
    {
        if (!spline.Initialized())
        {
            return;
        }
        List <OrientedPoint> path = spline.GetPath2();

        if (path.Count == 0)
        {
            return;
        }

        int[] triangleIndices = GenerateTriangles(path.Count - 1, shape2d.Vertices.Count);


        int edgeLoops   = path.Count;//por legibilidad. borrar una vez que se entienda
        int allVertices = shape2d.Vertices.Count * path.Count;

        Vector3[] vertices = new Vector3[allVertices];
        Vector3[] normals  = new Vector3[allVertices];
        Vector2[] uvs      = new Vector2[allVertices];



        int index = 0;

        foreach (OrientedPoint op in path)
        {
            foreach (Vertex v in shape2d.Vertices)
            {
                vertices[index] = op.LocalToWorld(v.point);
                normals[index]  = op.LocalToWorldDirection(v.normal);
                uvs[index]      = new Vector2(v.uCoord, path.IndexOf(op) / ((float)edgeLoops) * TextureScale);

                index++;
            }
        }


        SetMesh(vertices, normals, uvs, triangleIndices);
    }
Ejemplo n.º 3
0
    private void OnSceneGUI()
    {//movimiento del mouse en la ventana Scene
        splineMono = target as SplineMono;


        if (!splineMono.Initialized())
        {
            return;
        }

        handleTransform = splineMono.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;

        DrawHandles();
        CheckNodeMovement(selectedNode);
        DrawCurves();
        //DrawDirections();
        DrawRotationFixed();
        DrawRotation();
    }
Ejemplo n.º 4
0
 public bool Initialized()
 {
     SplineMono = GetComponent <SplineMono>();
     extruder   = GetComponent <Extruder>();
     return(SplineMono.Initialized() && extruder.Initialized());
 }