Outerra forum

Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => Topic started by: zzz on June 29, 2014, 08:21:16 am

Title: speed vectors?
Post by: zzz on June 29, 2014, 08:21:16 am
Is it possible to get the Vehicle's speed method to return individual xyz vectors instead of overall velocity?
Title: Re: speed vectors?
Post by: cameni on June 29, 2014, 09:36:41 am
We'll expose a velocity method that returns both the linear and angular vector speeds.
Title: Re: speed vectors?
Post by: zzz on June 29, 2014, 10:09:25 am
Thanks. Is there a timeline on that?
Title: Re: speed vectors?
Post by: cameni on June 29, 2014, 10:12:00 am
It will get into the next update which could be out soon, just some issues at exit need to be addressed.
Title: Re: speed vectors?
Post by: zzz on June 29, 2014, 04:41:56 pm
  • script: velocity method for getting speed vectors in vehicle physics
great! what's the syntax on that?

and videomaker.exe gives some errors on quitting although I'm not using it.
Title: Re: speed vectors?
Post by: cameni on June 29, 2014, 05:11:57 pm
I've added it to the wiki. Returns an object with linear and angular member variables in world space.
Title: Re: speed vectors?
Post by: zzz on June 29, 2014, 06:08:44 pm
I've added it to the wiki. Returns an object with linear and angular member variables in world space.

Could you give me an example line? I tried this (and variations)

this.velocity('angular').y

for pitch velocity but got nowhere.
Title: Re: speed vectors?
Post by: cameni on June 29, 2014, 06:22:31 pm
Try
var v=this.velocity();
v.angular.x ...
Title: Re: speed vectors?
Post by: zzz on June 29, 2014, 07:09:51 pm
I think the vectors might be relative to the world instead of the model. Asking it not to go over "50 velocity" limits its speed to numbers that don't match any units and change depending on the heading. Also if you turn the vehicle 180 degrees it does not change the velocity function's outputs.

edit: yeah, seems 250ish heading positive x, 160ish positive y.
Title: Re: speed vectors?
Post by: cameni on June 30, 2014, 03:06:16 am
Yes, they are in world space. Can be converted to model space via the quaternion, but there's no easily usable math lib in JS for it, so it will be probably better to provide transformation functions.
Title: Re: speed vectors?
Post by: zzz on June 30, 2014, 04:37:20 pm
so it will be probably better to provide transformation functions.

So the function won't get much use until those are created? I read up on quaternions and the maths is... dense.
Title: Re: speed vectors?
Post by: cameni on July 01, 2014, 05:06:29 am
Depends on how you mean to use it. You may want to implement a stabilizer that controls the vehicle in tangential plane, and for that you'll need world space vectors.

I have added a bool flag to instruct the method that you want model space vectors.
Title: Re: speed vectors?
Post by: zzz on July 02, 2014, 04:38:38 am
Thanks. The linear speeds work perfectly, but with angular is the conversion correct? After some bugs I logged the changing angular.z speed and it cycled between -8 to 8 as I was in an increasingly fast 360 degree spin along that axis.
Title: Re: speed vectors?
Post by: zzz on July 03, 2014, 11:57:52 am
Thanks. The linear speeds work perfectly, but with angular is the conversion correct? After some bugs I logged the changing angular.z speed and it cycled between -8 to 8 as I was in an increasingly fast 360 degree spin along that axis.

Was my interpretation of this correct?
Title: Re: speed vectors?
Post by: cameni on July 03, 2014, 02:54:26 pm
Hm I didn't notice any issues with the angular speed in local frame; it's used, for example, on boats for stabilization.
Title: Re: speed vectors?
Post by: zzz on July 03, 2014, 06:36:13 pm
hmm, this a screen of the angular readouts of the x-axis as the ship rolls left about 180 degrees/s.

http://s9.postimg.org/u2y3pesb3/screen_1404426459.jpg (http://s9.postimg.org/u2y3pesb3/screen_1404426459.jpg)

Just in case my axis was wrong I tried the same whilst logging the y and z axis. They all stayed at very low numbers and none of them increased proportionately with the roll speed.

What turned me onto it was to stop my models sliding out of control I use this code to autocompensate:

Code: [Select]
var velo = this.velocity(1);
if (velo.linear.x > 0) {
  this.extra_force({y:0,z:0},{y:0,x:-latForce});
  }
if (velo.linear.x < 0) {
  this.extra_force({y:0,z:0},{y:0,x:latForce});
  }

and it works perfectly. When I use something similar to stop yawing or pitching it overshoots the zero point by some margin until it reverses speed, overshoots even more and eventually oscillates out of control, no matter how low the forces, speed and acceleration are.

Code: [Select]
if (velo.angular.x > 0) {
  this.extra_force({y:100,z:0},{z:0,x:-angForce});
  this.extra_force({y:-100,z:0},{z:0,x:angForce});
  }
if (velo.angular.x < 0) {
  this.extra_force({y:100,z:0},{z:0,x:angForce});
  this.extra_force({y:-100,z:0},{z:0,x:-angForce});
  }

edit: here's a screen with all 3 axis being logged.

http://s28.postimg.org/uhiaxd76l/screen_1404427168.jpg (http://s28.postimg.org/uhiaxd76l/screen_1404427168.jpg)

at that time it was yawing right so fast it was a blur, with a slight pitch up and barely no roll.
Title: Re: speed vectors?
Post by: cameni on July 03, 2014, 10:31:27 pm
To me it seems you are detecting pitch (x axis), but acting on yaw.
Title: Re: speed vectors?
Post by: zzz on July 04, 2014, 01:24:38 pm
Seems you were right. That on top of working in m/s instead of rad/s and the compensators not working unless all 3 were active meant it couldn't do anything but oscillate out of control. Sorry for bothering you. :-[

But if it's any consolation the updated js file may save you having to make that UFO flight model.