Ejemplo n.º 1
0
        public void BakeFrame(float time)
        {
            if (cache == null)
            {
                return;
            }

            ObiParticleCache.Frame frame = new ObiParticleCache.Frame();

            frame.time = time;

            for (int i = 0; i < solver.renderablePositions.Length; ++i)
            {
                // If the particle has not been allocated or is inactive, skip it.
                if (!solver.allocatedParticles.Contains(i) || !solver.activeParticles.Contains(i))
                {
                    continue;
                }

                frame.indices.Add(i);

                if (cache.localSpace)
                {
                    frame.positions.Add(solver.transform.InverseTransformPoint(solver.renderablePositions[i]));
                }
                else
                {
                    frame.positions.Add(solver.renderablePositions[i]);
                }
            }

            cache.AddFrame(frame);
        }
Ejemplo n.º 2
0
        public void BakeFrame(float time)
        {
            if (cache == null)
                return;

            ObiParticleCache.Frame frame = new ObiParticleCache.Frame();

            frame.time = time;

            for (int i = 0; i < solver.renderablePositions.Length; ++i){

                // If the particle has not been allocated or is inactive, skip it.
                if (!solver.allocatedParticles.Contains(i) || !solver.activeParticles.Contains(i))
                    continue;

                frame.indices.Add(i);

                if (cache.localSpace)
                    frame.positions.Add(solver.transform.InverseTransformPoint(solver.renderablePositions[i]));
                else
                    frame.positions.Add(solver.renderablePositions[i]);

            }

            cache.AddFrame(frame);
        }
Ejemplo n.º 3
0
        public void BakeFrame(float time)
        {
            if (cache == null)
            {
                return;
            }

            ObiParticleCache.Frame frame = new ObiParticleCache.Frame();

            frame.time = time;

            for (int i = 0; i < solver.renderablePositions.Length; ++i)
            {
                // If the particle has not been allocated or is inactive, skip it.
                ObiSolver.ParticleInActor pa = solver.particleToActor[i];
                if (pa == null || !pa.actor.active[pa.indexInActor])
                {
                    continue;
                }

                frame.indices.Add(i);

                if (cache.localSpace)
                {
                    frame.positions.Add(solver.transform.InverseTransformPoint(solver.renderablePositions[i]));
                }
                else
                {
                    frame.positions.Add(solver.renderablePositions[i]);
                }
            }

            cache.AddFrame(frame);
        }
Ejemplo n.º 4
0
        void PlaybackFrame(float time)
        {
            if (cache == null)
            {
                return;
            }

            // Get current frame from cache:
            ObiParticleCache.Frame frame = cache.GetFrame(time, interpolate);

            if (frame == null)
            {
                return;
            }

            if (solver.allocatedParticles.Count < frame.indices.Count)
            {
                Debug.LogError("The ObiSolver doesn't have enough allocated particles to playback this cache.");
                Playing = false;
                return;
            }

            // Set active particles:
            solver.activeParticles = new HashSet <int>(frame.indices);

            // Apply current frame:
            for (int i = 0; i < frame.indices.Count; ++i)
            {
                if (frame.indices[i] >= 0 && frame.indices[i] < solver.renderablePositions.Length)
                {
                    if (cache.localSpace)
                    {
                        solver.renderablePositions[frame.indices[i]] = solver.transform.TransformPoint(frame.positions[i]);
                    }
                    else
                    {
                        solver.renderablePositions[frame.indices[i]] = frame.positions[i];
                    }
                }
            }

            Oni.SetParticlePositions(solver.OniSolver, solver.renderablePositions, solver.renderablePositions.Length, 0);
            solver.UpdateActiveParticles();
        }