Beispiel #1
0
    void Start()
    {
        int n = 0;

        if (materials == null || materials.Length == 0)
        {
            materials = new Material[1];                // make a blank one
        }

        // let's make a very low poly one
        GameObject go = MakeUVSphere.Create(Vector3.one, 10, 10);

        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.left * 1.4f;
        SpinMeY.Attach(go);
        n++;

        // and now one that looks good
        go = MakeUVSphere.Create(Vector3.one, 24, 24);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.right * 1.4f;
        SpinMeY.Attach(go);
        n++;

        // finally a weird squished one - Aussie rules football anyone?
        go = MakeUVSphere.Create(new Vector3(0.6f, 1.2f, 1.0f), 32, 32);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.up * 2.2f;
        SpinMeY.Attach(go);
    }
    void Start()
    {
        int n = 0;

        if (materials == null || materials.Length == 0)
        {
            materials = new Material[1];                // make a blank one
        }

        GameObject go = MakeUVCapsule.Create(Vector3.one, 10, 10, 1);

        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position         = Vector3.left * 2.4f;
        SpinMeY.Attach(go).RateOfSpin = 25;
        n++;

        go = MakeUVCapsule.Create(Vector3.one, 24, 24, 2);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position         = Vector3.right * 2.4f;
        SpinMeY.Attach(go).RateOfSpin = 50;
        n++;

        go = MakeUVCapsule.Create(new Vector3(0.6f, 1.2f, 1.0f), 32, 32, 3);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position         = Vector3.up * 2.0f;
        SpinMeY.Attach(go).RateOfSpin = 100;
    }
Beispiel #3
0
    void Start()
    {
        int n = 0;

        if (materials == null || materials.Length == 0)
        {
            materials = new Material[1];                // make a blank one
        }

        // let's make a very low poly one
        GameObject go = MakeUVCircle.Create(Vector3.one, AxisDirection.ZMINUS, 10);

        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.left * 1.4f;
        SpinMeY.Attach(go);
        n++;

        // and now one that looks good
        go = MakeUVCircle.Create(Vector3.one, AxisDirection.ZPLUS, 32);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.right * 1.4f;
        SpinMeY.Attach(go);
        n++;

        // and finally a SUPER-fine one, coincidentally also double-sided
        go = MakeUVCircle.Create(Vector3.one, AxisDirection.ZMINUS, 1024, true);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.up * 1.4f;
        SpinMeY.Attach(go);
        n++;

        // a flat one, double-sided
        go = MakeUVCircle.Create(Vector3.one, AxisDirection.YPLUS, 32, true);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.down * 1.0f;
        SpinMeZ.Attach(go);
        n++;

        // an inverted one high where we can see it
        go = MakeUVCircle.Create(Vector3.one, AxisDirection.YMINUS, 32);
        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.up * 4.0f;
        SpinMeY.Attach(go);
        n++;

        // a nice simple five-pointed star
        go = MakeUVCircle.Create(Vector3.one, AxisDirection.ZMINUS, 10, CyclicRadiusModifiers: new float[] { 1.0f, 0.5f });
        go.GetComponent <MeshRenderer>().material = materials[n % materials.Length];
        go.transform.position = Vector3.left * 3.4f + Vector3.up * 1.6f;
        n++;
    }
Beispiel #4
0
    void Start()
    {
        int n = 0;

        {
            List <Vector3> points = new List <Vector3>();

            // 0
            points.Add(new Vector3(-0.7f, -2));
            points.Add(new Vector3(-0.7f, 2));
            points.Add(new Vector3(0, 2));
            points.Add(new Vector3(0, 1));
            points.Add(new Vector3(1, 2));
            // 5
            points.Add(new Vector3(1.5f, 1.5f));
            points.Add(new Vector3(0, 0));
            points.Add(new Vector3(1.5f, -1.5f));
            points.Add(new Vector3(1, -2));
            points.Add(new Vector3(0, -1));
            // 10
            points.Add(new Vector3(0, -2));

            List <int> triangles = new List <int>();
            triangles.Add3 <int>(0, 1, 2);
            triangles.Add3 <int>(0, 2, 3);
            triangles.Add3 <int>(0, 3, 6);
            triangles.Add3 <int>(6, 3, 4);
            triangles.Add3 <int>(6, 4, 5);
            triangles.Add3 <int>(9, 6, 7);
            triangles.Add3 <int>(9, 7, 8);
            triangles.Add3 <int>(0, 6, 9);
            triangles.Add3 <int>(0, 9, 10);

            var go = Extrude2DShape.ExtrudeLoop(
                points.ToArray(),
                1.0f,
                offset: -0.5f,
                triangles: triangles.ToArray());
            go.GetComponent <MeshRenderer> ().materials = new Material[]
            {
                FrontMaterial,
                BackMaterial,
                SideMaterial,
            };
            go.transform.position = Vector3.left * 1.4f;
            SpinMeY.Attach(go);
            n++;
        }
    }
    void Start()
    {
        int n = 0;

        if (materials == null || materials.Length == 0)
        {
            materials = new Material[1];                // make a blank one
        }

        // let's make a very low poly one
        GameObject go = MakeUVCylinder.Create(new Vector3(1, 2f, 1), 31, 10);

        go.GetComponent <MeshRenderer> ().material = materials [n % materials.Length];
        go.transform.position = Vector3.left * 1.4f;
        SpinMeY.Attach(go);
        n++;
    }
Beispiel #6
0
    IEnumerator Start()
    {
        // doing it all by hand
        var t1 = MakeTriangleByHand();
        // and one with a backface
        var t2 = MakeTriangleByHand(AddBackface: true);

        // slide them to the left so we can make something else
        for (float distance = 0; distance >= -2; distance -= Time.deltaTime)
        {
            t1.transform.Translate(new Vector3(-1, -0.7f, 0) * Time.deltaTime);
            t2.transform.Translate(new Vector3(-1, 0.7f, 0) * Time.deltaTime);
            yield return(null);
        }

        // tack on a spin-in-place script
        SpinMeY.Attach(t1, RateOfSpin: 150);
        SpinMeY.Attach(t2, RateOfSpin: 90);

        // coming soon: example using UnityEngine.UI.VertexHelper() class
    }
Beispiel #7
0
    void Start()
    {
        int n = 0;

        if (materials == null || materials.Length == 0)
        {
            materials = new Material[1];                // make a blank one
        }

        GameObject go = MakeUVCone.Create(
            new Vector3(1.0f, 1.0f, 1.0f),
            new Vector3(2.0f, -1.0f, 2.0f),
            14, 2);

        foreach (var renderer in go.GetComponentsInChildren <MeshRenderer> ())
        {
            renderer.material = materials [n % materials.Length];
        }
        go.transform.position = Vector3.left * 1.4f;
        SpinMeY.Attach(go);
        n++;
    }
Beispiel #8
0
    IEnumerator Start()
    {
        List <GameObject> all = new List <GameObject>();

        {
            var go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.transform.position = Vector3.right * -1.3f;
            all.Add(go);
            go = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            go.transform.position = Vector3.right * 0.0f;
            all.Add(go);
            go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.transform.position = Vector3.right * 1.3f;
            all.Add(go);
        }

        foreach (var go in all)
        {
            SpinMeY.Attach(go);
        }

        yield return(WaitForInput());

        foreach (var go in all)
        {
            go.GetComponent <Renderer>().material = MaterialFactory.Instance.abcd;
        }

        yield return(WaitForInput());

        foreach (var go in all)
        {
            UVRemappers.ApplyCylindrical(go, Vector3.zero);
        }

        yield return(WaitForInput());
    }