예제 #1
0
 public DeviceData(ArrayView2D <Vec3> canvas, ParticleSystemStructOfArrays particles, int width, int height)
 {
     this.canvas    = canvas;
     this.width     = width;
     this.height    = height;
     this.particles = particles;
 }
예제 #2
0
            public HostParticleSystemStructOfArrays(int particleCount, Accelerator device, int width, int height)
            {
                this.particleCount = particleCount;
                Vec3[] poses = new Vec3[particleCount];
                Random rng   = new Random();

                for (int i = 0; i < particleCount; i++)
                {
                    poses[i] = new Vec3((float)rng.NextDouble() * width, (float)rng.NextDouble() * height, 1);
                }

                positions     = device.Allocate(poses);
                velocities    = device.Allocate <Vec3>(particleCount);
                accelerations = device.Allocate <Vec3>(particleCount);

                velocities.MemSetToZero();
                accelerations.MemSetToZero();

                deviceParticleSystem = new ParticleSystemStructOfArrays(positions, velocities, accelerations, width, height);
            }