Particle Disapears when i draw a skybox

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Particle Disapears when i draw a skybox

      Hi everyone

      i am trying to learn to use pointsprites and i have one sprite drawn.

      it works fine if i just draw the sprite

      but if i first draw a skybox and then the sprite its not visible

      i tried to disable Z wrtiting before the Skybox like this:
      m_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE);

      but it didnt do any good

      does anyone have any ideas for me please?
    • i just realized it might be even a bigger problem than i thought:(

      when i just had the particle in the origin it showed as it should as long as i didnt render the skybox but when i put somthing in for x or z as a position it started moving which it really shouldnt

      here is my code if someone could take a look at it
      [source]
      struct PARTICLECUSTOMVERTEX{
      float x, y, z;
      DWORD Diffuse;
      };
      #define D3DFVF_PARTICLEVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)

      class FBSParticleSystem
      {
      private:
      protected:
      public:
      FBSParticle *m_Particles;
      DWORD m_NumParticles;
      LPDIRECT3DVERTEXBUFFER9 m_pVB;
      LPDIRECT3DTEXTURE9 m_Texture;

      FBSParticleSystem(LPDIRECT3DDEVICE9 Device, DWORD NumParticles)
      {
      m_NumParticles = NumParticles;
      m_Particles = new FBSParticle[m_NumParticles];
      m_pVB = NULL;
      m_Texture = NULL;
      Device->CreateVertexBuffer(m_NumParticles*sizeof(PARTICLECUSTOMVERTEX), 0, D3DFVF_PARTICLEVERTEX, D3DPOOL_DEFAULT, &m_pVB, NULL);
      if(FAILED(D3DXCreateTextureFromFile(Device, "Sprite.bmp", &m_Texture))){
      MessageBox(NULL, "Could not find 2.bmp", "Particle", MB_OK);
      }
      }

      ~FBSParticleSystem()
      {
      if(m_pVB)
      m_pVB->Release();

      if(m_Texture)
      m_Texture->Release();

      if(m_Particles)
      delete [] m_Particles;
      }

      VOID Update(LPDIRECT3DDEVICE9 g_pd3dDevice)
      {
      PARTICLECUSTOMVERTEX *vertices = new PARTICLECUSTOMVERTEX[m_NumParticles];
      for(DWORD Counter = 0; Counter < m_NumParticles; Counter++)
      {
      vertices[Counter].x = 5;
      vertices[Counter].y = 5;
      vertices[Counter].z = 0;
      }
      PARTICLECUSTOMVERTEX* pVertices = NULL;
      m_pVB->Lock( 0, sizeof(PARTICLECUSTOMVERTEX) * m_NumParticles, (void**)&pVertices, D3DLOCK_DISCARD);
      memcpy( pVertices, vertices, sizeof(PARTICLECUSTOMVERTEX)*m_NumParticles );
      m_pVB->Unlock();
      FLOAT MinSize, Scale1, Scale2, Scale3, Size;

      Size = 15.0f;
      MinSize = 0.0f;
      Scale1 = 0.0f;
      Scale2 = 0.0f;
      Scale3 = 1.0f;

      g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, false );
      g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
      g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);

      g_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, true);
      g_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, true);
      g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&Size ));
      g_pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *((DWORD*)&MinSize));
      g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_A, *((DWORD*)&Scale1));
      g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_B, *((DWORD*)&Scale2));
      g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_C, *((DWORD*)&Scale3));

      g_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(PARTICLECUSTOMVERTEX) );
      g_pd3dDevice->SetFVF( D3DFVF_PARTICLEVERTEX );
      g_pd3dDevice->SetTexture(0, m_Texture);
      g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, m_NumParticles );

      g_pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, FALSE );
      g_pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
      g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,false);

      }
      };





      could it be something about the way i fill the Vertex-Buffer?

      [/source]