예제 #1
0
        /**
         * Returns a list of all datapoints contained in the given volume
         */
        public static List <DataPoint> GetSelectedPoints(MeshDeformerMove volume)
        {
            List <DataPoint> pointsInVolume = new List <DataPoint>();

            for (int i = 0; i < dataPoints.Count; i++)
            {
                DataPoint dp = dataPoints[i];
                if (volume.IsInside(dp.GetPos()))
                {
                    pointsInVolume.Add(dp);
                    dp.SetSelected(true);
                    dataParticles[i].startColor = Color.magenta;
                }
                else
                {
                    dp.SetSelected(false);
                    dataParticles[i].startColor = dp.GetColor();
                }
            }
            pSystem.SetParticles(dataParticles);
            // Add the volume in BoolOperation et clear the last volume
            BoolOperation.currentVolume = volume;
            BoolOperation.currentSelectedDataPoints.Clear();
            return(pointsInVolume);
        }
예제 #2
0
        /**
         * Initialize the particles or prefab and preprocess the data
         */
        private void InitParticles()
        {
            dataParticles = new ParticleSystem.Particle[dataPoints.Count];
            for (int i = 0; i < dataPoints.Count; i++)
            {
                dataParticles[i].position = dataPoints[i].GetPos();
                if (dataPoints[i].isSelected())
                {
                    dataParticles[i].startColor = Color.magenta;
                }
                else
                {
                    dataParticles[i].startColor = dataPoints[i].GetColor();
                }
                dataParticles[i].startSize         = 0.01f;
                dataParticles[i].remainingLifetime = i; // since lifetime isn't used, we can store the corresponding datapoint id in it
            }
            pSystem.SetParticles(dataParticles, dataParticles.Length);
            collisionEvents = new List <ParticleCollisionEvent>();

            // if there are already some volume, select the first and show the selection
            MeshDeformerMove volume = (MeshDeformerMove)GameObject.FindObjectOfType(typeof(MeshDeformerMove));

            if (volume != null)
            {
                GetSelectedPoints(volume);
            }
        }
예제 #3
0
        void LaunchRay(Vector3 origin, Vector3 dir)
        {
            Debug.Log("launchRay");
            Ray        ray = new Ray(origin, dir.normalized);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 0.05f, 1 << 9))
            {
                Debug.Log("je suis dans le premier if");
                MeshDeformerMove current_mesh = hit.collider.GetComponent <MeshDeformerMove>();
                if (current_mesh != null)
                {
                    current_mesh.SelectVertices(hit.point);
                    meshHit = current_mesh;
                    Debug.Log("j'ai terminé !");
                }
            }
        }