Jump to content
  • Advertisement
Sign in to follow this  
hacer

Point Sprites Rendering problem

This topic is 4026 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have some problem with Point Sprites rendering and I am surprised it appeared in this place. I coded particie struci

struct Particle
{
D3DXVECTOR3 m_Pos;
D3DXVECTOR3 m_Velocity;
D3DCOLOR m_Color;
};

Also standard Vertex Struct needed for VertexBuffer During particle initialization I am setting m_Pos on (100.0f, 100.0f, 1.0f) and m_Velocity on (50.0f, 0.0f, 0.0f) Position of every particle is counted using this formula
particles.m_vPos += particles.m_vVel * (float)dElpasedFrameTime; 
So I am assuming that particle should go along X axis only, but there is something weird it looks like it goes along X- and Z-axis, even if m_Velocity.z=0.0f; I thought it has something with matrices but I set them orthographic.
D3DXMATRIX matrix;
D3DMatrixIdenity(&matrix)
d3dDevice->SetTransform( D3DTS_WORLD, &matrix);
d3dDevice->SetTransform( D3DTS_VIEW, &matrix);

D3DXMatrixOrthoOffCenterLH(&matrix, 0.0f, 1024.0f, 768.0f, 0.5f, 0.0f)
d3dDevice->SetTransform( D3DTS_PROJECTION, &matrix);

Her eis the code that renders the particie.
d3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );

    d3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    d3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

	

d 3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );    
d3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE,  TRUE); 
d3dDevice->SetRenderState( D3DRS_POINTSIZE,     FtoDW(1.0) );  
d3dDevice->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(1.0f) );. 
d3dDevice->SetRenderState( D3DRS_POINTSCALE_A,  FtoDW(0.0f) ); 
d3dDevice->SetRenderState( D3DRS_POINTSCALE_B,  FtoDW(0.0f) ); 
d3dDevice->SetRenderState( D3DRS_POINTSCALE_C,  FtoDW(1.0f) ); 

	Vertex *pPointVertices;

	VertexBuffer->Lock( 0, MAX_PARTICLES * sizeof(Vertex),
		                   (void**)&pPointVertices, D3DLOCK_DISCARD );

for( int i = 0; i < MAX_PARTICLES; ++i )
    {
        pPointVertices->posit = particles.m_Pos;
        pPointVertices->color = particles.m_Color;
        pPointVertices++;
    }

    	VertexBuffer->Unlock();
	

d3dDevice->SetStreamSource( 0, VertexBuffer, 0, sizeof(Vertex) );
d3dDevice->SetFVF( Vertex::FVF_Flags );
d3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, MAX_PARTICLES );

	
    d3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
   d3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE,  FALSE );

    d3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
   d3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
}
I have no idea what is going on.

Share this post


Link to post
Share on other sites
Advertisement
I didn't understand your question. Particles doesn't move on desired x axis, but on z axis too?

Also I have noticed few things. 50.0f for x velocity is too much. If you presume that you have i.e 30 FPS, your particle will move in one second 30*50= 1500 on one axis! Isn't that too much?

Also drawing always MAX_PARTICLES will hit your performance. Not all of particles are drawn every moment, you will need to optimize a little bit.

And in particles.m_vPos += particles.m_vVel * (float)dElpasedFrameTime;
I see "particles.m_vVel"
in
for( int i = 0; i < MAX_PARTICLES; ++i )
{
pPointVertices->posit = particles.m_Pos;
pPointVertices->color = particles.m_Color;
pPointVertices++;
}
you don't copy it. If you don't initialize vector you will have some dumb value in your velocity...
Does this:
for( int i = 0; i < MAX_PARTICLES; ++i )
{
pPointVertices->posit = particles.m_Pos;
pPointVertices->color = particles.m_Color;
pPointVertices->m_vVel= particles.m_Velocity;
pPointVertices++;
}
helps?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!