ParticleSystem::ParticleSystem(DeviceHelper& device, XMFLOAT3 emitterPos) : m_particlesCount(0), m_particlesToCreate(0.0f), m_emitterPos(emitterPos) { srand(static_cast<unsigned int>(time(0))); m_vertices = device.CreateVertexBuffer<ParticleVertex>(MAX_PARTICLES, D3D11_USAGE_DYNAMIC); shared_ptr<ID3DBlob> vsByteCode = device.CompileD3DShader(L"resources/shaders/Particles.hlsl", "VS_Main", "vs_4_0"); shared_ptr<ID3DBlob> gsByteCode = device.CompileD3DShader(L"resources/shaders/Particles.hlsl", "GS_Main", "gs_4_0"); shared_ptr<ID3DBlob> psByteCode = device.CompileD3DShader(L"resources/shaders/Particles.hlsl", "PS_Main", "ps_4_0"); m_vs = device.CreateVertexShader(vsByteCode); m_gs = device.CreateGeometryShader(gsByteCode); m_ps = device.CreatePixelShader(psByteCode); m_layout = device.CreateInputLayout<ParticleVertex>(vsByteCode); m_cloudTexture = device.CreateShaderResourceView(L"resources/textures/smoke.png"); m_opacityTexture = device.CreateShaderResourceView(L"resources/textures/smokecolors.png"); D3D11_SAMPLER_DESC sd = device.DefaultSamplerDesc(); sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; m_samplerState = device.CreateSamplerState(sd); }
ParticleSystem::ParticleSystem(DeviceHelper& device, XMFLOAT3 emitterPos) : m_emitterPos(emitterPos), m_particlesToCreate(0.0f), m_particlesCount(0), m_dirCoordDist(-1.0f, 1.0f), m_velDist(MIN_VELOCITY, MAX_VELOCITY), m_angleVelDist(MIN_ANGLE_VEL, MAX_ANGLE_VEL) { m_vertices = device.CreateVertexBuffer<ParticleVertex>(MAX_PARTICLES, D3D11_USAGE_DYNAMIC); auto vsByteCode = device.LoadByteCode(L"particlesVS.cso"); auto gsByteCode = device.LoadByteCode(L"particlesGS.cso"); auto psByteCode = device.LoadByteCode(L"particlesPS.cso"); m_vs = device.CreateVertexShader(vsByteCode); m_gs = device.CreateGeometryShader(gsByteCode); m_ps = device.CreatePixelShader(psByteCode); m_layout = device.CreateInputLayout<ParticleVertex>(vsByteCode); m_cloudTexture = device.CreateShaderResourceView(L"resources/textures/smoke.png"); m_opacityTexture = device.CreateShaderResourceView(L"resources/textures/smokecolors.png"); auto sd = device.DefaultSamplerDesc(); sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; m_samplerState = device.CreateSamplerState(sd); }