Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > Fires of Heaven Related Forums > Uberworlds Development Forum
User Name
Password
Or, use your gamerDNA username: (more...)
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 05-20-2008, 02:39 PM   #1 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 231
+8 Internets
Send a message via ICQ to Cloud9_
math help

What do I need to know for the following?

I am trying to build a particle system with various effects. I have a fireworks like explosion, but trying to get a 'cone' effect is a little rougher for me right now.

I want to be able to pass the direction of the cone (between 1 and 360 degrees) the intensity of the particles (how fast they shoot out of the emitter), and the degree of the cone mouth (for example, the particles can be shot anywhere from 10 degrees to 25 degrees from the emitter)

I am using XNA right now, so I have a position vector, and velocity vector, how would I come up with the velocity vector? Tried a few things but not sure what type of math is involved

Can anyone point me in the right direction?
Cloud9_ is offline   Reply With Quote
Old 05-20-2008, 03:12 PM   #2 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 231
+8 Internets
Send a message via ICQ to Cloud9_
Think i got it;

Code:
        
private static Vector2 SetParticleVelocity(float direction, float directionRange, float speed)
        {

            speed = RNG.GetRandomFloat(.01f, speed);

            return new Vector2(
                speed * (float)Math.Sin(RNG.GetRandomFloat(direction, directionRange)),
                speed * (float)Math.Cos(RNG.GetRandomFloat(direction, directionRange)));
an amendment to the code, to get it to behave more like I wanted to;

Code:
private static Vector2 SetParticleVelocity(float direction, float directionRange, float speed)
        {
            direction = MathHelper.ToRadians(direction);
            directionRange = MathHelper.ToRadians(directionRange);

            float randomDirection = RNG.GetRandomFloat(direction - (directionRange / 2), direction + (directionRange / 2));

            speed = RNG.GetRandomFloat(.01f, speed);            

            return new Vector2(
                (float)Math.Sin(randomDirection) * speed,
                (float)Math.Cos(randomDirection) * speed);
        }
This way you can tell it what direction you want to fire, and also how big the cone you want to fire. The first method, you had to specify the first line and the 2nd line and it will fire particles between the two.

I guess the next step is to make an enum to make it easier to fire "Up, Right, Down, Left, Up/Right, Up/Left" etc etc

Last edited by Cloud9_; 05-20-2008 at 03:28 PM..
Cloud9_ is offline   Reply With Quote
Old 05-21-2008, 08:53 AM   #3 (permalink)
Szlia
Conquest
 
Szlia's Avatar
 
Join Date: Mar 2002
Location: Switzerland
Posts: 5,645
+25 Internets
I am not sure what you want to do, but currently the particle distribution is homogenous in the angle, so depending on what you are trying to do, it might look better if there is a higher particle density in the middle. There are probably dozens of clever way to code that, but here is a brute force dumb way to do it I think:

Code:
float randomDirection = RNG.GetRandomFloat(direction - (directionRange / 2) + RNG.GetRandomFloat(0, directionRange/2), direction + (directionRange / 2)- RNG.GetRandomFloat(0, directionRange/2));
__________________
-retrosabotage-

Last edited by Szlia; 05-21-2008 at 11:00 PM..
Szlia is offline   Reply With Quote
Old 05-21-2008, 11:26 AM   #4 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 231
+8 Internets
Send a message via ICQ to Cloud9_
Quote:
Originally Posted by Szlia View Post
I am not sure what you want to do, but currently the particle distribution is homogenous in the angle, so dpeneding on what you are trying to do, it might look better if there is a higher particle density in the middle. There are probably dozens of clever way to code that, but here is a brute force dumb way to do it I think:

Code:
float randomDirection = RNG.GetRandomFloat(direction - (directionRange / 2) + RNG.GetRandomFloat(0, directionRange/2), direction + (directionRange / 2)- RNG.GetRandomFloat(0, directionRange/2));
I'll plug that in when I get home from work in a few hours... thanks
Cloud9_ is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

uberguilds network



All times are GMT -7. The time now is 03:00 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6