示例#1
0
    /* 2D
     * private void DrawLine(int index)
     * {
     *  newPosition = lastPosition;
     *  newPosition += direction;
     *  lineRenderer.SetPosition(index, newPosition);
     *  lastPosition = newPosition;
     * }
     */

    private void DrawLine(Vector3 lastPosition, Vector3 newPosition)
    {
        // Cylinder approach
        if (Scenes.DrawingApproach == 0)
        {
            GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            cylinder.transform.parent = gameObject.transform;
            cylinder.GetComponent <MeshRenderer>().material = material;
            float   distance = Vector3.Distance(newPosition, lastPosition);
            Vector3 newScale = cylinder.transform.localScale;
            newScale.y = distance / 2;
            newScale.x = scale;
            newScale.z = scale;
            cylinder.transform.localScale = newScale;
            cylinder.transform.position   = Vector3.Lerp(lastPosition, newPosition, 0.5f);
            cylinder.transform.up         = newPosition - lastPosition;
        }

        // Cone approach
        else
        {
            GameObject cone = CreateCone.Create(1, scale, scale * Scenes.WidthDecreaseRate);
            cone.transform.parent = gameObject.transform;
            cone.GetComponent <MeshRenderer>().material = material;
            Vector3 newScale = cone.transform.localScale;
            newScale.y = Vector3.Distance(lastPosition, newPosition);
            cone.transform.localScale = newScale;
            cone.transform.position   = lastPosition;
            cone.transform.up         = newPosition - lastPosition;
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        shapes [0] = new _Shape(PrimitiveType.Cube);
        shapes [0].ShowShape();
        shapes [1] = new _Shape(PrimitiveType.Sphere);
        CreateCone c = new CreateCone();

        c.OnWizardCreate();
        shapes [2] = new _Shape(c.getGameObject());
    }
示例#3
0
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            CreateCone newCone = new CreateCone(modelSpace.Project.CreateNewOperationId());

            //The width,height,depth of cuboid is setted with default value now
            //We'll improve it next version by using mouse draging
            Length.LengthUnit unit   = modelSpace.Project.Environment.DefaultLengthUnit;
            float             value1 = modelSpace.Project.Environment.GridSize.Value;
            float             value2 = modelSpace.Project.Environment.GridSize.Value * 2;

            newCone.Height       = new Length(value2, unit);
            newCone.BottomRadius = new Length(value1, unit);
            newCone.TopRadius    = new Length(0f, unit);

            //Get the refPoint
            Vector3 center = modelSpace.SceneRender.DisplayedGridPoint;

            newCone.Center = new Vector3WithUnit(center, modelSpace.Project.Environment.DefaultLengthUnit);

            //Set the aline axis
            switch (modelSpace.Project.Environment.GridPlane)
            {
            case GridPlane.XY:
                newCone.AlineAxis = Axis.Z;
                break;

            case GridPlane.XZ:
                newCone.AlineAxis = Axis.Y;
                break;

            case GridPlane.YZ:
                newCone.AlineAxis = Axis.X;
                break;

            default:
                newCone.AlineAxis = Axis.Z;
                break;
            }

            //Create the new single
            modelSpace.Project.CreateNewSingle(newCone);

            workspace.SelectTool();
        }