![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Programming Error ! Programming error messages |
![]() |
|
frag grenade Random explode explosion effect c++ opengl
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
I want to explode my grenade, and the frags must go in a random (or anything alike) direction. Problem is that i must generate as many possible random numbers in less time possible. So the 3D direction of the particles are random. How can I get the fragments/particles going from the center of the grenade to any random direction? Usage of the function rand() causes the fragments to go in 4 directions or so. |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
r = drand48()*2*pi; x = cos(r); y = sin(r); r = sqrt(x*x+y*y+z*z); x /= r; y /= r; z /= r; should have been z = drand48()*2-1; r = drand48()*2*pi; x = cos(r); y = sin(r); r = sqrt(1-z*z); x *= r; y *= r; |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|