# D3DXMATRIX ,Random Pos ?

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

## Recommended Posts

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); } }

##### Share on other sites
What do you mean "it will draw random pos without stop continuesly"?

##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by jamessshi, 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.
You 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?

In that case, you have two options:

1. Generate the positions once at startup, store them somewhere, and apply those positions each frame

2. 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.

##### Share on other sites
You are right Steve billboard positions changes every frame,Thank you ,i will try that now..

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002139
×