The Partridge Family were neither partridges nor a family. Discuss.
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » January 2nd, 2018, 7:59 pm
Hey folks, I am working on a particle emitter and i want to do a z axis scaling where i get a random z value between - 1 and 1. I want to scale the positive from 1 to 2 or n size and negative from 1 to near 0.
Particle update. I diffuse transparency by life / lifespan which gives me a value between 0 and 1.
I should be able to use this to get from 1 to 0 and 1 to 2 ?.
What i am trying to achieve is a pseudo 3d look
Code: Select all
void Particle::Update(const float & dt)
{
if (!done)
{
if ((life -= dt) > 0.0f)
{
if (diffuse)
{
Get<Animation>().SetTransparency(life / lifeSpan);
}
Get<Transform>().velocity.y += gravity;
Get<Transform>().Update(dt);
if (doRotate)
{
Vec2f v = Get<Transform>().velocity;
Get<Transform>().rotation_angle = v.Normalize().Angle();
Get<Transform>().Rotate();
}
/// here
Vec2f scale = { Zscaler,Zscaler };
scale.Normalize();
Get<Transform>().Scale({ scale.x + (life / lifeSpan),scale.y + (life / lifeSpan) });
}
else
{
done = true;
Get<Transform>().Scale({ 1.0f,1.0f });
}
}
}
any suggestions ?
Curiosity killed the cat, satisfaction brought him back
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » January 2nd, 2018, 8:12 pm
hmm i think this has fixed it
Code: Select all
if (doScale)
{
float sign = Sign<float>(Zscaler);
float scaler = (1.0f - (life / lifeSpan));
if (sign < 0)
Get<Transform>().Scale({ 1.0f + scaler,1.0f + scaler });
else
Get<Transform>().Scale({ 1.0f - scaler,1.0f - scaler });
}
Curiosity killed the cat, satisfaction brought him back
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » January 2nd, 2018, 8:25 pm
Now the trick is to render the -Zscalers ones before the tiles to give the illusion of going away behind the tiles and other objects
Curiosity killed the cat, satisfaction brought him back
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » January 2nd, 2018, 9:46 pm
Yes!! did it, particles that scale small get drawn first, then tiles, then larger scaled particles last .
Curiosity killed the cat, satisfaction brought him back