| 328 | } |
| 329 | |
| 330 | void ParticleSystem::sphereEmitter(uint &index, |
| 331 | vec3f pos, |
| 332 | vec3f vel, |
| 333 | vec3f spread, |
| 334 | float r, |
| 335 | int n, |
| 336 | float lifetime, |
| 337 | float lifetimeVariance) |
| 338 | { |
| 339 | float4 *posPtr = m_pos.getHostPtr(); |
| 340 | float4 *velPtr = m_vel.getHostPtr(); |
| 341 | |
| 342 | uint start = index; |
| 343 | uint count = 0; |
| 344 | |
| 345 | for (int i = 0; i < n; i++) { |
| 346 | vec3f x = randSphere(); |
| 347 | |
| 348 | // float dist = length(x); |
| 349 | if (index < m_numParticles) { |
| 350 | vec3f p = pos + x * r; |
| 351 | float age = 0.0; |
| 352 | |
| 353 | float lt = lifetime + frand() * lifetimeVariance; |
| 354 | |
| 355 | vec3f dir = randSphere(); |
| 356 | dir.y = fabs(dir.y); |
| 357 | vec3f v = vel + dir * spread; |
| 358 | |
| 359 | posPtr[index] = make_float4(p.x, p.y, p.z, age); |
| 360 | velPtr[index] = make_float4(v.x, v.y, v.z, lt); |
| 361 | |
| 362 | index++; |
| 363 | count++; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | m_pos.copy(GpuArray<float4>::HOST_TO_DEVICE, start, count); |
| 368 | m_vel.copy(GpuArray<float4>::HOST_TO_DEVICE, start, count); |
| 369 | } |
| 370 | |
| 371 | void ParticleSystem::setModelView(float *m) |
| 372 | { |
no test coverage detected