traveltime = self.animstate_endtime - self.animstate_starttime;
phasepos = (nexttick - self.animstate_starttime) / traveltime; // range: [0, 1]
- if(self.platmovetype != 1)
+ if(!self.platmovetype)
+ self.platmovetype = 2; // default
+ switch(self.platmovetype)
{
- phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
- phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1]
- phasepos = phasepos + 1; // correct range to [0, 2]
- phasepos = phasepos / 2; // correct range to [0, 1]
+ case 1: // linear
+ break;
+ case 2: // cosine
+ phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
+ phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1]
+ phasepos = phasepos + 1; // correct range to [0, 2]
+ phasepos = phasepos / 2; // correct range to [0, 1]
+ break;
+ case 2: // inverted cosine
+ phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
+ phasepos = sin(phasepos); // sin [pi, 2pi] is in [-1, 1]
+ phasepos = phasepos + 1; // correct range to [0, 2]
+ phasepos = phasepos / 2; // correct range to [0, 1]
+ break;
}
nextpos = self.origin + (delta * phasepos) + (delta2 * phasepos * phasepos);
// derivative: delta + 2 * delta2 * phasepos (e.g. for angle positioning)
// of controlled animation, so let's just use linear movement.
// Alternatively entities can choose to specify non-controlled movement.
// The only currently implemented alternative movement is linear (value 1)
- if (traveltime < 0.15 || self.platmovetype == 1)
+ if (traveltime < 0.15 || self.platmovetype < 2)
{
self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
self.nextthink = self.ltime + traveltime;