Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: axis_integrator  (Read 1782 times)

zzz

  • Sr. Member
  • ****
  • Posts: 266
  • newbie
axis_integrator
« on: September 19, 2015, 06:41:18 pm »

It seems the axis_integrator function no longer exists, which is a bit worrying as it's key to turret functionality  :-[
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6512
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: axis_integrator
« Reply #1 on: September 20, 2015, 02:25:04 am »

Axis integrator was just a piece of js injected into vehicle scripts. To use it, simply include this code:

Code: [Select]
function axis_integrator(maxspeed,maxaccel,clamp_min,clamp_max){
  this.mac = maxaccel ? maxaccel : 1.0;
  this.msp = maxspeed;
  this.speed = 0;
  this.value = 0;
  this.targ = 0;
  this.cmin = clamp_min!=undefined ? clamp_min : Number.NEGATIVE_INFINITY;
  this.cmax = clamp_max!=undefined ? clamp_max : Number.POSITIVE_INFINITY;
}

axis_integrator.prototype.set = function(v){this.targ = v}
axis_integrator.prototype.set_max_speed = function(v){this.msp = v}
axis_integrator.prototype.changed = function(dt){
  var ob = this.speed;
  var dm = this.mac*dt;
  if(this.targ > ob+dm)
    this.speed += dm;
  else if(this.targ < ob-dm)
    this.speed -= dm;
  else
    this.speed = this.targ;
  var ov = this.value;
  this.value += this.speed*this.msp*dt;
  if(this.value < this.cmin) this.value = this.cmin;
  if(this.value > this.cmax) this.value = this.cmax;
  return ov != this.value;
}
Logged

zzz

  • Sr. Member
  • ****
  • Posts: 266
  • newbie
Re: axis_integrator
« Reply #2 on: September 20, 2015, 09:06:11 am »

Thanks. It is working now. What values does the direction float3 {x:0.0,y:0.0,z:0.0} field of this.fire take? I know they're the same setup as the spotlight directions but as mine only needed orthog angles I got past them without really understanding them. Some direction values make the projectile speed and size really big or small.
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6512
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: axis_integrator
« Reply #3 on: September 20, 2015, 12:02:01 pm »

Absolute value of the dir vector multiplies the speed, so you should keep it a unit vector (but that wasn't intended, I'll normalize it). It should not affect the size though.
Logged