Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Development Programming Misc > Point Sprite pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 925 of 979
Post > Topic >>

Point Sprite problem

by "haci.2x" <MLendzion@[EMAIL PROTECTED] > Jul 12, 2007 at 01:43 PM

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

I have particle struct




Code:
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



Code:
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.



Code:
D3DXMATRIX matrix;
D3DMatrixIdenity(&matrix)
d3dDevice->SetTransform( D3DTS_WORLD, &matrix);
d3dDevice->SetTransform( D3DTS_VIEW, &matrix);

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



Here is the code that renders the particie.



Code:
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[i].m_Pos;
        pPointVertices->color = particles[i].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.




 1 Posts in Topic:
Point Sprite problem
"haci.2x" <M  2007-07-12 13:43:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 5:24:34 CDT 2008.