예제 #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
        private Cone GetConeAtParameter(double t)
        {
            Point  point = Point.Create(GetHyperbolicRadius(t), 0, t);
            double slope = A * t / B / B / Math.Sqrt(1 + Math.Pow(t / B, 2));
            double angle;

            if (Accuracy.LengthIsZero(slope))
            {
                angle = Math.PI / 2;
            }
            else
            {
                angle = Math.Atan(-1 / slope);
            }

            if (Accuracy.AngleIsNegative(angle))
            {
                angle += Math.PI;
            }

            Debug.Assert(angle < Math.PI && angle > 0, "Cone angle improper.");

            Frame frame = Frame.Create(Point.Create(0, 0, t), Direction.DirX, Direction.DirY);

            return(Cone.Create(frame, GetHyperbolicRadius(t), angle));
        }
예제 #3
0
파일: ScaleGizmo.cs 프로젝트: xorza/NetGL
        private void AddCones()
        {
            const float ConeWidth  = 0.05f;
            const float ConeLength = 0.20f;

            _arrowRenderer          = SceneObject.AddComponent <MeshRenderable>();
            _arrowRenderer.Material = _material;

            var xCone = Cone.Create(ConeWidth, ConeLength, 6);

            xCone.Transform(new Matrix(new Vector3(1 - ConeLength, 0, 0), new Quaternion(Vector3.Forward, MathF.PI / 2), Vector3.One));
            _coneVertexCount = xCone.Vertices.Length;

            var yCone = Cone.Create(ConeWidth, ConeLength, 6);

            yCone.Transform(new Matrix(new Vector3(0, 1 - ConeLength, 0), Quaternion.Identity, Vector3.One));

            var zCone = Cone.Create(ConeWidth, ConeLength, 6);

            zCone.Transform(new Matrix(new Vector3(0, 0, 1 - ConeLength), new Quaternion(Vector3.Right, MathF.PI / 2), Vector3.One));

            _arrowMesh = CompoundMesh.Create(xCone, yCone);
            _arrowMesh = CompoundMesh.Create(_arrowMesh, zCone);

            _arrowMesh.CalculateBounds();
            _arrowRenderer.Mesh = _arrowMesh;
        }
예제 #4
0
        protected BevelGear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double bevelAngle, double bevelKneeRatio, double depth)
            : base(parent, gearData, conjugateGearData, toothProfile, helicalAngle, depth)
        {
            BevelAngle     = bevelAngle;
            BevelKneeRatio = bevelKneeRatio;

            StartPoint    = Point.Create(0, 0, XOffset);
            EndPoint      = StartPoint - Vector.Create(0, 0, Depth * Math.Cos(Alpha));
            StartFrame    = Frame.Create(StartPoint, Direction.DirX, -Direction.DirY);
            EndFrame      = Frame.Create(EndPoint, Direction.DirX, -Direction.DirY);
            StartDiameter = GearData.PitchDiameter;
            EndDiameter   = StartDiameter - 2 * Depth * Math.Sin(Alpha);
            StartCone     = Cone.Create(StartFrame, StartDiameter / 2, Math.PI / 2 - Alpha);
            EndCone       = Cone.Create(EndFrame, EndDiameter / 2, Math.PI / 2 - Alpha);
        }
예제 #5
0
        protected override ITrimmedCurve GetTransformedProfileCurve(ITrimmedCurve iTrimmedCurve, double param)
        {
            int numPoints = 10000;

            Matrix trans = Matrix.CreateRotation(Axis, HelixRotations * param);

            Point[] points       = new Point[numPoints + 1];
            Frame   profileFrame = Frame.Create(StartPoint + (EndPoint - StartPoint) * param, StartFrame.DirX, StartFrame.DirY);
            Cone    profileCone  = Cone.Create(profileFrame, (StartDiameter + (EndDiameter - StartDiameter) * param) / 2, Math.PI / 2 - Alpha);

            for (int j = 0; j <= numPoints; j++)
            {
                double t             = iTrimmedCurve.Bounds.Start + iTrimmedCurve.Bounds.Span * (double)j / numPoints;
                Vector pointVector   = iTrimmedCurve.Geometry.Evaluate(t).Point.Vector;
                double angle         = Circle.Create(Frame.Create(Point.Origin, Direction.DirX, -Direction.DirY), GearData.PitchRadius).ProjectPoint(pointVector.GetPoint()).Param;
                double startDistance = pointVector.Magnitude - StartDiameter / 2;
                double endDistance   = pointVector.Magnitude * EndScale - EndDiameter / 2;
                double distance      = startDistance + (endDistance - startDistance) * param;
                points[j] = profileCone.WrapPoint(angle, distance);
            }

            return(CurveSegment.Create(NurbsCurve.CreateThroughPoints(false, points, Accuracy.LinearResolution)).CreateTransformedCopy(trans));
        }
예제 #6
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);
        }
    }