Hi All.
I'm trying to create a particle thruster effect. What I'm thinking of doing is to spawn a ring of particles at the starting location
from a 3d direction vector, Where the ring of points are all perpenicular to the Direction vector. Once I have this ring of points I
will create a vector from the centre and give it length to form a apex where all points on the ring move towards.
here is a image of what I'm doing.
I found some steps which is as follows,
//1. Choose any point P randomly which doesn't lie on the line through P1 and P2
//2. Calculate the vector R as the cross product between the vectors P - P1 and P2 - P1. This vector R is now perpendicular to P2 - P1. (If R is 0 then 1. wasn't satisfied)
//3. Calculate the vector S as the cross product between the vectors R and P2 - P1. This vector S is now perpendicular to both R and the P2 - P1.
//4. The unit vectors ||R|| and ||S|| are two orthonormal vectors in the plane perpendicular to P2 - P1.
I tryed following the above but when I set a minus Direction like so d3dvector3(0.0, -1.0, 0.0) or (-1,0,0) My particles dont render, I'm wondering
if I have the math wrong here is what Im doing.
float3 plane[3];
float3 n,p,r,s,p1p2;
//the starting point
float3 p1 = gEmitPosW.xyz;
//apex location
float3 p2 = dir * 1900.0;//add some length to the direction
//p.x = rand(); /* Create a random vector */
//p.y = rand();
//p.z = rand();
//now creating a perp vector
randompoint = normalize(Perpendicular(p1p2));
r = randompoint;
s = normalize(cross(p1p2, r));
dtheta = 36.0;
float th =0.0;
for(theta=0;theta<360;theta+=dtheta)
{
th = radians(theta);
n.x = (r.x) * cos(th) + (s.x) * sin(th);
n.y = (r.y) * cos(th) + (s.y) * sin(th);
n.z = (r.z) * cos(th) + (s.z) * sin(th);
normalize(n);
//set the particl up
////////////////////////////////////////////
Particle p;
p.initialPosW = p1 + n* radius;
p.initialVelW = gEmitDirW.xyz;
p.pDirW = normalize(p2 - p.initialPosW );//p.initialVelW;
p.sizeW = float2(gParticleWidth, gParticleHeight);
p.age = 0.0f;//vRandom.x;
p.type = PT_FLARE;
p.arrayid = 0;
p.initialVelW.x = gFlashspeed;
//add new particle
ptStream.Append(p);
}
Is there some thing wrong in the above code.
If I change the start and end points I can get it to render in the minus directions, but how do I do it when the direction can be unknown at the time.
I tryed doing this but it does nothing
//dir
if(length(p2) - length(p1)< 0)
p1p2 =dir;//p2 - p1;
else
p1p2 =normalize(p1 - p2);
This one has a up direction d3dvector3(0,1,0).
Don't worry about the bit comming out the buttom thats just my flame thrower particle.