Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post Posted: January 2nd, 2018, 7:59 pm 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 645
Location: Merville, British Columbia Canada
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


Top 
 Profile  
Reply with quote  
 Post Posted: January 2nd, 2018, 8:12 pm 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 645
Location: Merville, British Columbia Canada
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


Top 
 Profile  
Reply with quote  
 Post Posted: January 2nd, 2018, 8:25 pm 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 645
Location: Merville, British Columbia Canada
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


Top 
 Profile  
Reply with quote  
 Post Posted: January 2nd, 2018, 9:46 pm 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 645
Location: Merville, British Columbia Canada
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


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 4 posts ] 

Board index » Everything


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

Search for:
cron