D3DXMATRIX ,Random Pos ?
when i trying to get random billboarded grass
positions on terrain it will draw random pos
without stop continuesly ! how can i solve this
here is my render part:
int x =rand()%245+10;
int z=rand()%255-10;
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
matworld._41=i*x-z;
matworld._42=0;
matworld._43=j*x-z;
m_device->SetTransform(D3DTS_WORLD,&matworld);
//Billboard::Animate();
m_device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
}
}
hi, i meant it will take new random position over old random positions and so on continuesly ...it will appear and dissappear at mix random positions..u know i just want to keep one random position on terrain.
Quote:Original post by jamesssYou mean that each billboards position changes each frame, and you want the positions to only be defined once at the start, and not move each frame?
hi, i meant it will take new random position over old random positions and so on continuesly ...it will appear and dissappear at mix random positions..u know i just want to keep one random position on terrain.
In that case, you have two options:
- Generate the positions once at startup, store them somewhere, and apply those positions each frame
- Seed the random number generator (srand()) with the same value before you render your billboards.
It's worth noting that the way you're rendering is sub-optimal. It'd be faster (and possibly easier) to put vertices for all the bilboards into one vertex buffer (instead of the vertices for one) with random positions, and then to render them all in one DrawPrimitive() call.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement