/// \param effectDef XML tag containing the effect definition ParticleEffect::ParticleEffect(TiXmlElement *effectDef) { // assign defaults m_nTotalParticleCount = 0; m_bCycleParticles = true; m_bIsDead = false; m_IsDying = false; m_nLiveParticleCount = 0; m_fEmitPartial = 1.0f; // start with at least one particle m_vecGravity = Vector3::kZeroVector; m_vecPosition = Vector3::kZeroVector; m_txtParticleTexture = NULL; m_UpdateFunc.clear(); m_InitFunc.clear(); m_fPILife = 1.0f; m_fPISpeed = 100.0f; m_fPIDragValue = 0.0f; m_PIFadeIn = 0.0f; m_PIFadeOut = 1.0f; m_PIFadeMax = 1.0f; m_PIRotationSpeed = 0.0f; m_PIRotationStopTime = 0.0f; m_distFunc = NULL; // default emit rate is all at once (or at least all in the first .01 secs) m_nEmitRate = m_nTotalParticleCount * 100; m_sort = false; m_vertBuffer = NULL; m_indexBuffer = NULL; // get system data effectDef->Attribute("particleCount", &m_nTotalParticleCount); const char *filename = effectDef->Attribute("textureName"); // initialize effect properties from the xml tag initProperties(effectDef); // allocate memory needed m_Particles = new Particle[m_nTotalParticleCount]; m_drawOrder = new int[m_nTotalParticleCount]; initParticles(); // create vertex and index buffers, and initialize index buffer. We can // create the index buffer as static since it doesn't change values; this // will increase performance a little. m_vertBuffer = new VertexLBuffer(m_nTotalParticleCount * 4, true); m_indexBuffer = new IndexBuffer(m_nTotalParticleCount * 2); initIndexBuffer(); // this should be replaced with the renderer version of loading a texture gDirectoryManager.setDirectory(eDirectoryTextures); D3DXIMAGE_INFO structImageInfo; //image information HRESULT hres=D3DXCreateTextureFromFileEx(pD3DDevice, filename, 0,0,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_FILTER_NONE, D3DX_DEFAULT,0,&structImageInfo,NULL, &m_txtParticleTexture); }
HRESULT ManagementSprite::init(ID3D11Device* p_device) { HRESULT hr = S_OK; initSprites(); initSpriteCollection(); hr = initVertexBuffer(p_device); if(SUCCEEDED(hr)) hr = initIndexBuffer(p_device); return hr; }