Page 1 of 1 [ 4 posts ]

#### pseudo z axis on 2d scaling

 Print view Previous topic | Next topic

#### pseudo z axis on 2d scaling

Author Message
 Post subject: pseudo z axis on 2d scaling  Posted: January 2nd, 2018, 7:59 pm

Joined: November 30th, 2013, 7:40 pm
Posts: 645
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:
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

 Post subject: Re: pseudo z axis on 2d scaling  Posted: January 2nd, 2018, 8:12 pm

Joined: November 30th, 2013, 7:40 pm
Posts: 645
hmm i think this has fixed it
Code:
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

 Post subject: Re: pseudo z axis on 2d scaling  Posted: January 2nd, 2018, 8:25 pm

Joined: November 30th, 2013, 7:40 pm
Posts: 645
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

 Post subject: Re: pseudo z axis on 2d scaling  Posted: January 2nd, 2018, 9:46 pm

Joined: November 30th, 2013, 7:40 pm
Posts: 645
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

Display posts from previous:  Sort by

 Page 1 of 1 [ 4 posts ]

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: