   Rain particles
  EDIT: Ok sorry for this mess but there were some elements in the code that made it impossible for the forum to post this.Hope you can still help me here...I'm trying to set up some kind of basic rain drop engine right now and I need some help.What I'm doing is creating a static amount of vertices (xyz, color) and using them to draw lines with the D3DPT_LINELIST attribute while having random x and z values.To animate that I'm using a variable from a specific height that decreases every function call and then sets it back to the height.My problem now is to have it looking like rain I'd have to draw it more than once after another.But how can I do that?If I try to set up some kind of timer in the function and draw it again after like 1 second it doesn't work like it's supposed to.Here are my functions:HRESULT CParticle::CalculateRainParticles(LPDIRECT3DDEVICE9EX device){// Create Vertex Declarationif(FAILED(InitializeVertexDeclaration(device)))return E_FAIL;// RainDrop Countm_iRainDrops = 200;// RainDrop Heightfloat height = 100;// Create Rain Verticesm_pRainVertices = new PARTICLEVERTEX[m_iRainDrops];srand((unsigned)(time(0)));for(int i = 0; i < m_iRainDrops; i++){m_pRainVertices.color = D3DCOLOR_XRGB(0, 255, 0);}for(int i = 0; i < (m_iRainDrops - 2); i += 2){float randomX = randfloat(0, 400);float randomZ = randfloat(0, 400);m_pRainVertices.position = D3DXVECTOR3(randomX, height, randomZ);m_pRainVertices[i+1].position = D3DXVECTOR3(randomX, height-4, randomZ);}if(FAILED(device->CreateVertexBuffer(m_iRainDrops * sizeof(PARTICLEVERTEX), D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &m_pD3DVBRain, NULL))){MessageBox(NULL, L"Failed to create VB for RainDrops", L"CreateVertexBuffer() - HRESULT", MB_OK);return E_FAIL;}VOID* pData = NULL;m_pD3DVBRain->Lock(0, m_iRainDrops * sizeof(PARTICLEVERTEX), (VOID**)&pData, NULL);memcpy(pData, m_pRainVertices, m_iRainDrops * sizeof(PARTICLEVERTEX));if(FAILED(m_pD3DVBRain->Unlock())){MessageBox(NULL, L"Failed to unlock Rain VB", L"Unlock() - HRESULT", MB_OK);return E_FAIL;}return S_OK;}void CParticle::DrawRain(LPDIRECT3DDEVICE9EX device){device->SetVertexDeclaration(m_pD3DVertexDeclPositionColor);device->SetStreamSource(0, m_pD3DVBRain, 0, sizeof(PARTICLEVERTEX));device->DrawPrimitive(D3DPT_LINELIST, 0, m_iRainDrops / 2);}void CGraphics::DrawRain(){// Set Variables// Rain drop timingstatic double lastTimeHeightUpdate = 0.0;// last time we updateddouble currentTime = timeGetTime() * 0.001;// get current runtime in secondsD3DXMatrixTranslation(&m_matTranslation, -200.0f, m_fRainHeight, -200.0f);m_matWorld = m_matTranslation;m_pD3DEffect->SetMatrix("xWorld", &m_matWorld);// Set Techniqueif(SUCCEEDED(m_pD3DEffect->SetTechnique("PositionColor"))){UINT numberOfPasses;m_pD3DEffect->Begin(&numberOfPasses, NULL);for(UINT i = 0; i < numberOfPasses; i ++){m_pD3DEffect->BeginPass(i);// --> Draw Rain <--m_pCParticle->DrawRain(m_pD3DDev9);m_pD3DEffect->EndPass();}m_pD3DEffect->End();}if(currentTime - lastTimeHeightUpdate > 0.00005f){m_fRainHeight -= 2.5f;if(m_fRainHeight <= -120.0f)m_fRainHeight = 100.0f;lastTimeHeightUpdate = currentTime;}}[Edited by - lipsryme on April 24, 2010 3:16:50 PM]
  Hmmmmm, you must be interested in your own threads, if you wont even read them after creation.   ;  I didn't want to be harsh, but 1 hour of nothing seemed a bit odd.Okay, I should be more patient......   ;  Well if someone can tell a beginner how to make a Particle Draw engine in c++ D3D9 then I'd be pleased.If you tell me to look at some nvidia sample or whatever it's like looking at hebrew.   ;  Hey, here is a great particle system code sample. It's nice and not hard to integrate into your own project at all. You could base your first particle engine on this, as i did.Grusse   ;  Thanks I'll look into that.