Jump to content
  • Advertisement
Sign in to follow this  
jamesss

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by jamesss
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.
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 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!