Inheritance: _TurboSliceModuleHack
    private Vector4 planeForTransform(Camera camera, GameObject target, Vector3 _start, Vector3 _end)
    {
        Ray r;

        r = camera.ScreenPointToRay(_start);
        Vector3 start = r.GetPoint(10f);

        r = camera.ScreenPointToRay(_end);
        Vector3 end = r.GetPoint(10f);

        Vector3 _middle = (_start + _end) / 2f;

        r = camera.ScreenPointToRay(_middle);
        Vector3 middle = r.GetPoint(15f);

        List <Vector3> _plane = new List <Vector3>();

        _plane.Add(start);
        _plane.Add(middle);
        _plane.Add(end);

        Vector4 plane = TurboSlice.planeFromTriangle(target, _plane.ToArray());

        return(plane);
    }
    // Use this for initialization
    void Start()
    {
        if (_instance != null)
        {
            Debug.LogWarning("There may be multiple TurboSlice components in scene " + Application.loadedLevelName + ". Please review this!");
        }

        _instance = this;

        if (meshCaching)
        {
            meshCaches = new Dictionary <Mesh, MeshCache>();

            foreach (GameObject go in preload)
            {
                Sliceable s = ensureSliceable(go);

                MeshCache c = cacheFromGameObject(s, false);
                c.wasPreloaded = true;

                MeshFilter filter = getMeshFilter(s);

                if (filter == null)
                {
                    Mesh m = filter.sharedMesh;

                    meshCaches[m] = c;
                }
                else
                {
                    Debug.LogWarning("Turbo Slicer cannot preload object '" + go.name + "'; cannot find mesh filter.");
                }
            }
        }
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     if(_instance == null)
     {
         _instance = this;
     }
     else if(_instance != this)
     {
         GameObject.Destroy(gameObject);
     }
 }
 // Use this for initialization
 void Start()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else if (_instance != this)
     {
         GameObject.Destroy(gameObject);
     }
 }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        if (turboSlice == null)
        {
            Object _turboSlice = FindObjectOfType(typeof(TurboSlice));

            if (_turboSlice != null)
            {
                turboSlice = (TurboSlice)_turboSlice;
            }
            else
            {
                GameObject _newSlice = new GameObject();

                _newSlice.AddComponent <TurboSlice>();

                turboSlice = _newSlice.GetComponent <TurboSlice>();

                Debug.LogWarning("Slicer in scene '" + Application.loadedLevelName + "' can't find a TurboSlice component! Creating now. Configure manually as per the guide to avoid run-time configuration.");
            }
        }

        if (editorVisualization != null)
        {
            editorVisualization.enabled = false;
        }

        bool hasAllPlaneDefiners = true;

        hasAllPlaneDefiners = planeDefiner1 != null;
        hasAllPlaneDefiners = planeDefiner2 != null;
        hasAllPlaneDefiners = planeDefiner3 != null;

        if (hasAllPlaneDefiners == false)
        {
            Debug.LogError("Slicer '" + gameObject.name + "' in scene '" + Application.loadedLevelName + "' is missing a plane definer!");
        }
    }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        if(turboSlice == null)
        {
            Object _turboSlice = FindObjectOfType(typeof(TurboSlice));

            if(_turboSlice != null)
            {
                turboSlice = (TurboSlice) _turboSlice;
            }
            else
            {
                GameObject _newSlice = new GameObject();

                _newSlice.AddComponent<TurboSlice>();

                turboSlice = _newSlice.GetComponent<TurboSlice>();

                Debug.LogWarning("Slicer in scene '" + Application.loadedLevelName + "' can't find a TurboSlice component! Creating now. Configure manually as per the guide to avoid run-time configuration.");
            }
        }

        if(editorVisualization != null)
        {
            editorVisualization.enabled = false;
        }

        bool hasAllPlaneDefiners = true;

        hasAllPlaneDefiners = planeDefiner1 != null;
        hasAllPlaneDefiners = planeDefiner2 != null;
        hasAllPlaneDefiners = planeDefiner3 != null;

        if(hasAllPlaneDefiners == false)
        {
            Debug.LogError("Slicer '" + gameObject.name + "' in scene '" + Application.loadedLevelName + "' is missing a plane definer!");
        }
    }
    public GameObject[] splitByTriangle(GameObject target, Vector3[] triangleInWorldSpace, bool destroyOriginal)
    {
        Vector4 v = TurboSlice.planeFromTriangle(target, triangleInWorldSpace);

        return(splitByPlane(target, v, destroyOriginal));
    }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        if(_instance != null)
        {
            Debug.LogWarning("There may be multiple TurboSlice components in scene " + Application.loadedLevelName + ". Please review this!");
        }

        _instance = this;

        if(meshCaching)
        {
            meshCaches = new Dictionary<Mesh, MeshCache>();

            foreach(GameObject go in preload)
            {
                Sliceable s = ensureSliceable(go);

                MeshCache c = cacheFromGameObject(s, false);
                c.wasPreloaded = true;

                MeshFilter filter = getMeshFilter(s);

                if(filter == null)
                {
                    Mesh m = filter.sharedMesh;

                    meshCaches[m] = c;
                }
                else
                {
                    Debug.LogWarning("Turbo Slicer cannot preload object '" + go.name + "'; cannot find mesh filter.");
                }
            }
        }
    }