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.