Kinetic Visualization
 All Classes Functions Variables Pages
ParticleSystemCuda.h
1 #pragma once
2 #include "Cuda.h"
3 #include "CudaArray.h"
4 #include "particleCuda.cuh"
5 #include "RenderStates.h"
6 
7 
8 extern "C" void SetParticle(Particle *hostparticle_parameter);
9 extern "C" void CalcBBGrid(uint* cellStart, uint* cellEnd, float4* sortedPos,float4* sortedVel, float3* sortedForce, uint* indices, uint* hash, float4* pos, float4* vel, float3* force, uint count, uint numCells);
10 
11 //Initialize
12 extern "C" void InitParticlesCuda(uint* block, cudaExtent res, float isosurface);
13 extern "C" void SortStartPositionsAfterIndicesCuda(uint* block, uint* indices, unsigned int count);
14 extern "C" void GenerateQRSequenceCuda(uint* block, unsigned int count);
15 
16 extern "C" void initTransferFunctionTexture(cudaArray* tfArray);
17 extern "C" void initVolumenTexture(cudaArray* volArray, cudaExtent volumeSize);
18 extern "C" void initPCDTexture(cudaArray* volArray, cudaExtent volumeSize);
19 extern "C" void BindVolumeCuda(cudaArray* volume_array);
20 extern "C" void UnbindVolumeCuda();
21 extern "C" void BindPCDCuda(cudaArray* volume_array);
22 extern "C" void UnbindPCDCuda();
23 extern "C" void BindTransferfunctionCuda(cudaArray* volume_array);
24 extern "C" void UnbindTransferfunctionCuda();
25 
26 //Particles & Rules
27 extern "C" void ParticlesGradientCuda(float4* pos, float4* vel, float4* newvel, unsigned int count);
28 extern "C" void ParticlesPCDCuda(float4* pos, float4* vel, float4* newvel, unsigned int count);
29 extern "C" void ParticlesPCD2Cuda(float4* pos, float4* vel, float4* newvel, unsigned int count);
30 extern "C" void ParticlesFlockingCuda(float4* pos, float4* vel, uint* cellStart, uint* cellEnd, float4* newvel, unsigned int count);
31 extern "C" void ParticlesPredefinedDirectionCuda(float4* vel, float4* newvel, unsigned int count);
32 extern "C" void ParticlesDensityCuda(float4* pos, uint* cellStart, uint* cellEnd, float4* newpos, unsigned int count);
33 
34 extern "C" void IntegrateParticlesCuda(float4* pos, float4* newpos, float4* vel, unsigned int* start, unsigned int count);
35 extern "C" void SortParticlesCuda(float *sortKeys, unsigned int *indices, unsigned int numParticles);
36 extern "C" void CalcParticlesDepthCuda( float4* pos, float* keys, unsigned int* indices, int numParticles);
37 
38 extern "C" void CaclulatePositionsAndVelocities(uint* indices, float4* pos, float4* vel, cudaExtent res, unsigned int count);
39 
40 //Volume Block
41 extern "C" void CalcVolumeBlockCuda(float4* block, cudaExtent res, cudaExtent blocks_size, cudaExtent blocks_num);
42 
43 //div
44 extern "C" void render_kernel(dim3 gridSize, dim3 blockSize, uint *d_output, uint imageW, uint imageH, float density, float brightness, float transferOffset, float transferScale);
45 extern "C" void copyInvViewMatrix(float *invViewMatrix, size_t sizeofMatrix);
46 
47 extern "C" void IntegrateParticlesNavierStrokesCuda(float3* force, float3* actforce, float4* pos, float4* newpos, float4* vel, float4* newvel, float* pressure, float3* viscosity, unsigned int* startpos, unsigned int count);
48 extern "C" void CalcualteForcePressureAndViscosityCuda( float* pressure, float3* viscosity, float4* oldPos, float4* oldVel, float* oldPressure, uint* cellStart, uint* cellEnd, uint numParticles, cudaExtent res);
49 extern "C" void EvaluateDensityAndPressureCuda(float4* pos, float* pressure, float4* oldPos, uint* cellStart, uint* cellEnd, uint numParticles, cudaExtent res);
50 extern "C" void CollisionDetectionCellsCuda( float3* newVel, float4* oldPos, float4* oldVel, uint* cellStart, uint* cellEnd, uint numParticles, cudaExtent res);
51 
52 extern "C" void CollisionDetectionVolumeCuda(float3* force, float4* pos, float4* vel, uint numParticles);
53 
54 extern "C" void initHGTexture(cudaArray* hg_Array);
55 extern "C" void initHGDevTexture(cudaArray* hg_dev_Array);
56 extern "C" void BindHGCuda(cudaArray* hg_array);
57 extern "C" void BindHGDevCuda(cudaArray* hg_dev_array);
58 extern "C" void UnbindHGCuda();
59 extern "C" void UnbindHGDevCuda();
60 extern "C" void ResetVelocityOfErrorParticlesCuda(float4* new_vel, float4* oldVel, float4* oldPos, uint numParticles);
61 
63 {
64 public:
69  ParticleSystemCuda(int numParticles);
73  ~ParticleSystemCuda(void);
74 
78  glm::vec3 runEmitter(glm::vec3 pos);
82  glm::vec3 runEmitter(glm::vec3 pos, glm::vec3 vel);
86  void ParticleSystemCuda::AddParticles(unsigned int &index, glm::vec3 pos, glm::vec3 vel, glm::vec3 spread, float r, int n, float lifetimeVariance);
87 
91  void InitCube(glm::vec3 origin, glm::vec3 size, glm::vec3 vel, float lifetime);
95  void Update(float duration);
99  void DepthSort();
103  void InitSphere(glm::vec3 origin, glm::vec3 vel, float size, float lifetime);
104 
108  void InitStartPositions();
109 
113  void PrintParticles(unsigned int start, unsigned int count);
114 
118  Particle* Getparticle_parameter();
119 
124  void SetIsoValue(float v);
125 
126  Particle* m_particle_parameter;
127 
134  void SetData(float* pos, float* vel, int numParticles);
135 
139  void Debug();
140 
141  unsigned int m_numParticles;
142 
143 
144  CudaArray<float4> *m_Pos;
145  CudaArray<float4> *m_Vel;
146  CudaArray<float> *m_Depth;
147  CudaArray<unsigned int> *m_Index;
148 
149  CudaArray<float3> *m_Force;
150  CudaArray<float> *m_Pressure;
151  CudaArray<float3> *m_Viscosity;
152 
153  CudaArray<unsigned int>* m_CellStart;
154  CudaArray<unsigned int>* m_CellEnd;
155  CudaArray<unsigned int>* m_Indices2;
156  CudaArray<unsigned int>* m_Hash;
157 
158  unsigned int m_emitterIndex;
159  float3 m_sortVector;
160 
161  float m_time;
162  float m_duration;
163 
164  cudaExtent res;
165 
166 
167  CudaArray<uint>* m_initPos;
168  CudaArray<uint>* m_initResPos;
169  CudaArray<uint>* m_randomSequence;
170 };
171