Advertisement

More Particle Systems

Started by July 08, 2001 02:57 PM
0 comments, last by Ratman 23 years, 7 months ago
I finally got around to putting in a particle system for my ISO engine. Im having a little trouble grasping the whole 3D to 2D system though... Someone told me to do it like this:

float x_fac = 1.000;
float y_fac = cos(view_angle);
float z_fac = sin(view_angle);
screen_x = x_fac*particle.pos_x;
screen_y = y_fac*particle.pos_y + z_fac*particle.pos_z;
 </pre> 


I guess Im not getting the view_angle. Is it where the camera is, like 90 would be straight overhead (well 90/360 * 2PI)?

In the quick test I made, I just set the x velocity to +2 and the y velocity to +1 (and left Z velocity at 0). This should make a particle that "follows" along the edges of a 64x32 traingle (if that makes sense…).

But that didnt work out, it moved at a different angle, I assume its because the way Im converting the 3D cords to 2D.

Can someone explain this better to me? I think Im pretty confused…

Thanks

Ratman  </i>   

—————
<A href="http://ratfest.org ">Ratfest.org</a>    

I see what you are trying, I would do something closer to:

  // these three should be precomputed, only ONCE!float x_fac = 1.000;float y_fac = cos(3.14159*view_angle/180.0);float z_fac = sin(3.14159*view_angle/180.0);// following is once per renderscreen_x = 320.0;  // your screen width / 2screen_y = 240.0;  // your screen height / 2screen_x += x_fac*particle.pos_x;screen_y += y_fac*particle[i].pos_y; screen_y += z_fac*particle[i].pos_z;setpixel((int)screen_x, (int)screen_y);  


The above implementation assumes y is positive going southward, negative going northward. It assumes z is positive going downward, and negative going upwards. It also assumes your particles at x=0,y=0,z=0 is the center of the screen. Keep that in mind.

The variable view_angle is the angle of the virtual camera up from the ground, I would set it somewhere between 30-60. I''ve modified the code, so it converts to radians, in case you weren''t doing that.







This topic is closed to new replies.

Advertisement