Example #1
0
    void ChangeColor(float r, float g, float b)
    {
        Color c = new Color(r, g, b);

        //laser.SetColor(c);

        if (lineShape != null || splineShape != null)
        {
            lineShape.ChangeColor(c);
            lineSection.ChangeColor(c);
            if (lineHair)
            {
                lineHair.ChangeColor(c);
            }
            splineShape.ChangeColor(c);
            splineSection.ChangeColor(c);
            splineHair.ChangeColor(c);
        }

        Paint.SetColor(c);
        splineShape.GetComponent <MeshRenderer>().material.color   = c;
        splineSection.GetComponent <MeshRenderer>().material.color = c;
        splineHair.GetComponent <MeshRenderer>().material.color    = c;
        lineShape.GetComponent <MeshRenderer>().material.color     = c;
        lineSection.GetComponent <MeshRenderer>().material.color   = c;
        lineHair.GetComponent <MeshRenderer>().material.color      = c;
    }
Example #2
0
    public void EndDrawing()
    {
        // set the collider and the mesh
        if (objectType == ObjectType.Shape)
        {
            shape.SetMeshCollider();
            ObjectManager.instance.AddObject(shape.gameObject);
            shape.gameObject.AddComponent <MeshEditor>().StartGroupGeneration();
            shape = null;

            // add reflection
            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcShape>().SetMeshCollider();
                ObjectManager.instance.AddObject(ms.reflection);
            }
        }
        else if (objectType == ObjectType.Section)
        {
            section.SetMeshCollider();
            ObjectManager.instance.AddObject(section.gameObject);
            section.gameObject.GetComponent <MeshEditor>().StartGroupGeneration();
            section = null;

            // add reflection
            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcSection>().SetMeshCollider();
                ObjectManager.instance.AddObject(ms.reflection);
            }
        }
        else if (objectType == ObjectType.Hair)
        {
            hair.SetMeshCollider();
            hair.gameObject.GetComponent <MeshEditor>().StartGroupGeneration();

            // add reflection
            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcHair>().SetMeshCollider();
                ObjectManager.instance.AddObject(ms.reflection);
            }

            var        refTrail = hair.GetComponent <HairSplineTrail>();
            GameObject trail    = Instantiate(Resources.Load("NURBSTrail"), new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            trail.GetComponent <NURBSTrail>().InitNURBS(refTrail.spline, refTrail.trackLength, new Vector3(0.005f, 0, 0));
            trail.GetComponent <MeshRenderer>().material.color = hair.GetComponent <MeshRenderer>().material.color;
            hair = null;
            Destroy(hair.GetComponent <HairSplineTrail>());
            Destroy(hair);
            refTrail.Init(hairObject);
            ObjectManager.instance.AddObject(trail);
            Destroy(go.GetComponent <HairSplineTrail>());
        }
        if (ms.gameObject.activeSelf)
        {
            ms.reflection.GetComponent <MeshEditor>().StartGroupGeneration();
        }

        // set object cursor back
        objectCursor.SetActive(true);
        GameObject.Find("Tracker").GetComponent <TrackerScript>().numMesh++;
    }
Example #3
0
    public void UpdateDrawing(Vector3 position, Vector3 up, Vector3 forward, Vector3 right)
    {
        // updates shape
        if (objectType == ObjectType.Shape)
        {
            Vector3 actualPosition = position;
            if (ConstrainX)
            {
                actualPosition.x = shape.startPoint.x;
            }
            if (ConstrainY)
            {
                actualPosition.y = shape.startPoint.y;
            }
            if (ConstrainZ)
            {
                actualPosition.z = shape.startPoint.z;
            }

            if (!ConstrainLength)
            {
                shape.SetEndPoint(GridSnapTool.Snap(actualPosition));
            }
            else
            {
                Vector3 dir = (actualPosition - shape.startPoint).normalized;
                shape.SetEndPoint(GridSnapTool.Snap(shape.startPoint + LengthConstraint * dir));
            }

            lengthText.text = "" + Vector3.Distance(shape.endPoint, shape.startPoint);

            // checks if there is a mirror -> make a copy
            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcShape>().SetEndPoint(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)));
            }
        }
        else if (objectType == ObjectType.Section)
        {
            Vector3 actualPosition = position;
            if (ConstrainX)
            {
                actualPosition.x = section.startPoint.x;
            }
            if (ConstrainY)
            {
                actualPosition.y = section.startPoint.y;
            }
            if (ConstrainZ)
            {
                actualPosition.z = section.startPoint.z;
            }

            if (!ConstrainLength)
            {
                section.SetEndPoint(GridSnapTool.Snap(actualPosition));
            }
            else
            {
                Vector3 dir = (actualPosition - section.startPoint).normalized;
                section.SetEndPoint(GridSnapTool.Snap(section.startPoint + LengthConstraint * dir));
            }

            lengthText.text = "" + Vector3.Distance(section.endPoint, section.startPoint);

            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcSection>().SetEndPoint(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)));
            }
        }
        else if (objectType == ObjectType.Hair)
        {
            Vector3 actualPosition = position;
            if (ConstrainX)
            {
                actualPosition.x = hair.startPoint.x;
            }
            if (ConstrainY)
            {
                actualPosition.y = hair.startPoint.y;
            }
            if (ConstrainZ)
            {
                actualPosition.z = hair.startPoint.z;
            }

            //shape.SetEndPoint(actualPosition);
            hair.ResetPoint(GridSnapTool.Snap(startPosition), transform.rotation.eulerAngles.x);
            hair.GetComponent <HairSplineTrail>().BuildMeshTrail(GridSnapTool.Snap(actualPosition), up, forward, right, true);



            if (!ConstrainLength)
            {
                hair.SetEndPoint(GridSnapTool.Snap(actualPosition));
            }
            else
            {
                Vector3 dir = (actualPosition - hair.startPoint).normalized;
                hair.SetEndPoint(GridSnapTool.Snap(hair.startPoint + LengthConstraint * dir));
            }

            lengthText.text = "" + Vector3.Distance(hair.endPoint, hair.startPoint);

            if (ms.gameObject.activeSelf)
            {
                ms.reflection.GetComponent <ProcHair>().SetEndPoint(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)));
            }
        }
    }