Пример #1
0
        public MeshPreviewSelector()
        {
            InitializeComponent();

            var previewRenderer = new PreviewRenderer(new Size(200, 200));

            previewRenderer.BackgroundColor = new Vector4(0.75f, 0.75f, 0.75f, 1f);

            var meshes = new List <Mesh>();

            meshes.Add(Icosahedron.Create(0.45f, 0));
            meshes.Add(Icosahedron.Create(0.45f, 1));
            meshes.Add(Tube.Create(0.3f, 0.35f, 0.7f, 20));
            meshes.Add(Cloud.Create(CloudShape.Sphere, 0.9f, 50000));
            meshes.Add(Cone.Create(0.3f, 0.8f));
            meshes.Add(TrefoilKnot.Create());

            var rotation = Quaternion.CreateFromYawPitchRoll(0, -0.25f, -0.2f);

            MeshesListBox.ItemsSource = meshes
                                        .Select(_ => new MeshPreviewViewModel(_, previewRenderer.RenderPreview(_, rotation)))
                                        .ToArray();

            previewRenderer.Dispose();
        }
Пример #2
0
    // Token: 0x060041A6 RID: 16806 RVA: 0x0014C3B4 File Offset: 0x0014A7B4
    public void OnButtonHit(int id)
    {
        this.animTimeout = this.animTimeMax;
        BaseObject baseObject = null;

        switch (id)
        {
        case 0:
        {
            baseObject = Triangle.Create(1f, 0);
            float[] array = new float[6];
            array[0]            = 4f;
            array[1]            = 4f;
            this.shapeParamsMax = array;
            float[] array2 = new float[6];
            array2[0]             = 1f;
            array2[1]             = 1f;
            this.shapeParamsStart = array2;
            break;
        }

        case 1:
            baseObject          = PlaneObject.Create(1f, 1f, 1, 1);
            this.shapeParamsMax = new float[]
            {
                4f,
                4f,
                1f,
                1f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                1f,
                1f,
                0f,
                0f
            };
            break;

        case 2:
        {
            baseObject = Circle.Create(1f, 3);
            float[] array3 = new float[6];
            array3[0]           = 2.5f;
            array3[1]           = 40f;
            this.shapeParamsMax = array3;
            float[] array4 = new float[6];
            array4[0]             = 1f;
            array4[1]             = 3f;
            this.shapeParamsStart = array4;
            break;
        }

        case 3:
            baseObject          = Ellipse.Create(1f, 0.5f, 3);
            this.shapeParamsMax = new float[]
            {
                2.5f,
                1.2f,
                40f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                0.5f,
                3f,
                0f,
                0f,
                0f
            };
            break;

        case 4:
            baseObject          = Ring.Create(0.5f, 1f, 3);
            this.shapeParamsMax = new float[]
            {
                1f,
                2.5f,
                40f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                0.5f,
                1f,
                3f,
                0f,
                0f,
                0f
            };
            break;

        case 5:
            baseObject          = Box.Create(1f, 1f, 1f, 1, 1, 1, false, null, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                2.5f,
                2.5f,
                2.5f,
                1f,
                1f,
                1f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                1f,
                1f,
                1f,
                1f
            };
            break;

        case 6:
            baseObject          = Cylinder.Create(1f, 3f, 3, 1, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.25f,
                4f,
                40f,
                1f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                3f,
                3f,
                1f,
                0f,
                0f,
                0f
            };
            break;

        case 7:
            baseObject          = Cone.Create(1f, 0f, 0f, 2f, 3, 10, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.25f,
                0f,
                4f,
                40f,
                10f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                2f,
                3f,
                10f,
                0f,
                0f
            };
            break;

        case 8:
        {
            baseObject = Sphere.Create(1f, 4, 0f, 0f, 0f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            float[] array5 = new float[6];
            array5[0]           = 2.25f;
            array5[1]           = 40f;
            this.shapeParamsMax = array5;
            float[] array6 = new float[6];
            array6[0]             = 1f;
            array6[1]             = 4f;
            this.shapeParamsStart = array6;
            break;
        }

        case 9:
            baseObject          = Ellipsoid.Create(1f, 1f, 1f, 4, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.25f,
                2.45f,
                2.5f,
                40f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                1f,
                4f,
                0f,
                0f,
                0f
            };
            break;

        case 10:
            baseObject          = Pyramid.Create(1f, 1f, 1f, 1, 1, 1, false, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                2.7f,
                2.7f,
                1.7f,
                1f,
                1f,
                1f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                1f,
                1f,
                1f,
                1f,
                0f,
                0f,
                0f
            };
            break;

        case 11:
        {
            baseObject = GeoSphere.Create(1f, 0, GeoSpherePrimitive.BaseType.Icosahedron, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            float[] array7 = new float[6];
            array7[0]           = 2.45f;
            array7[1]           = 4f;
            this.shapeParamsMax = array7;
            float[] array8 = new float[6];
            array8[0]             = 1f;
            this.shapeParamsStart = array8;
            break;
        }

        case 12:
            baseObject          = Tube.Create(0.8f, 1f, 1f, 3, 1, 0f, false, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                0.8f,
                1.5f,
                4f,
                40f,
                0f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                0.8f,
                1f,
                1f,
                3f,
                0f,
                0f,
                0f,
                0f
            };
            break;

        case 13:
            baseObject          = Capsule.Create(1f, 1f, 4, 1, false, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.2f,
                4f,
                40f,
                1f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                4f,
                1f,
                0f,
                0f,
                0f
            };
            break;

        case 14:
            baseObject          = RoundedCube.Create(1f, 1f, 1f, 1, 0.2f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.6f,
                1.6f,
                1.6f,
                20f,
                0.6f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                1f,
                1f,
                1f,
                0.2f,
                0f,
                0f,
                0f
            };
            break;

        case 15:
            baseObject          = Torus.Create(1f, 0.5f, 4, 4, 0f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1.6f,
                0.8f,
                40f,
                40f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                0.5f,
                4f,
                4f,
                0f,
                0f,
                0f
            };
            break;

        case 16:
            baseObject          = TorusKnot.Create(0.5f, 0.3f, 10, 4, 2, 3, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                1f,
                0.5f,
                120f,
                40f,
                2f,
                3f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                0.5f,
                0.3f,
                10f,
                4f,
                2f,
                3f,
                0f,
                0f,
                0f
            };
            break;

        case 17:
            baseObject = Arc.Create(1f, 1f, 1f, 1f, 10, PivotPosition.Botttom);
            ((Arc)baseObject).gizmo.gameObject.transform.localPosition = new Vector3(-1f, -1f, 0f);
            this.shapeParamsMax = new float[]
            {
                4f,
                3f,
                2f,
                1f,
                20f,
                -1f
            };
            this.shapeParamsStart = new float[]
            {
                0.5f,
                0.5f,
                0.1f,
                0.5f,
                0f,
                0f
            };
            break;

        case 18:
            baseObject          = SphericalCone.Create(1f, 20, 180f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                2f,
                40f,
                20f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                1f,
                20f,
                360f,
                0f,
                0f,
                0f
            };
            break;

        case 19:
            baseObject          = SuperEllipsoid.Create(1f, 1f, 1f, 20, 0.5f, 1f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom);
            this.shapeParamsMax = new float[]
            {
                2f,
                2f,
                2f,
                20f,
                0.5f,
                1f,
                0f,
                0f,
                0f
            };
            this.shapeParamsStart = new float[]
            {
                0.5f,
                0.5f,
                0.5f,
                1f,
                0f,
                0f,
                0f,
                0f,
                0f
            };
            break;

        case 20:
            this.textureToggle = !this.textureToggle;
            break;

        case 21:
            this.flatNormals = !this.flatNormals;
            break;
        }
        if (baseObject)
        {
            if (this.shapeOld)
            {
                UnityEngine.Object.Destroy(this.shapeOld.gameObject);
            }
            this.shapeOld  = this.shapeMain;
            this.shapeMain = baseObject;
            this.shapeMain.gameObject.GetComponent <Renderer>().material = new Material(this.GetSpecularShader());
            this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 0.7058824f, 0.7058824f));
            this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_SpecColor", Color.white);
            this.shapeMain.gameObject.transform.position = this.prevPosition.position;
            this.nextShowTimeout = this.nextShowTimeoutMax;
            this.shapeID         = id;
        }
        if (this.textureToggle)
        {
            this.shapeMain.GetComponent <MeshRenderer>().sharedMaterial = (Resources.Load("Checker") as Material);
        }
        else
        {
            this.shapeMain.GetComponent <MeshRenderer>().sharedMaterial = new Material(this.GetSpecularShader());
            this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 0.7058824f, 0.7058824f));
            this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_SpecColor", Color.white);
        }
    }