Пример #1
0
    void Update()
    {
        if (resolutionScaling > constants.MAX_RESOLUTION_SCALE)
        {
            resolutionScaling = constants.MAX_RESOLUTION_SCALE;
        }

        if (resolutionScaling <= 0)
        {
            resolutionScaling = 1;
        }

        cam = GetComponent <Camera>();
        if (cam == null)
        {
            cam = Camera.main;
        }

        optionsStruct.options.pointMode = pointMode;
        if (!showPickMarker)
        {
            previewCube.SetActive(false);
        }
        else
        {
            previewCube.SetActive(true);
        }

        if (optionsStruct.pickRendered)
        {
            if (placeNext && optionsStruct.Pick.hit == 0)
            {
                Debug.Log("missed!");
            }
            else
            {
                Vector3 pickCentre = optionsStruct.PickLocation();
                if (placeNext)
                {
                    Debug.Log("Mouse located at " + pickCentre.ToString());
                    if (optionsStruct.Pick.isHighestLOD == 0)
                    {
                        Debug.Log("Warning: pick may not represent actual point in cloud");
                    }
                    //Here is an example of how to place an object at the position returned by pick
                    if (placeCubesOnPick)
                    {
                        var marker = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        marker.GetComponent <Renderer>().material.color = Color.red;
                        marker.transform.position = pickCentre;
                    }
                }
                previewCube.transform.position = pickCentre;
            }
            placeNext = false;
        }

        Vector3 mp = Input.mousePosition;

        optionsStruct.setPick((uint)(mp.x * resolutionScaling), (uint)((cam.pixelHeight - mp.y) * resolutionScaling));

        if (Input.GetMouseButtonDown(0))
        {
            placeNext = true;
        }
    }