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: Panther G rigged!  (Read 19258 times)

murkz

  • Full Member
  • ***
  • Posts: 152
    • The Antisocial Gamer
Panther G rigged!
« on: May 04, 2013, 02:46:07 pm »






Snorri's amazing skins really do look superb in Outerra


Code: [Select]

//vehicle script file
//see http://xtrac.outerra.com/index.fcgi/wiki/vehicle for example and documentation
var turret,mantlet,barrel;

const MaxTurretXSpeed = 10; //deg/s
const MaxTurretYSpeed = 20; //deg/s
const MaxTurretXAccel = 120;//deg/s^2
const MaxTurretYAccel = 160;//deg/s^2
const MinTurretAngle = -8;  //in deg  gun depression
const TurretAngleSpan = 18; //in deg  gun elevation
const TurningBoost = 0.4;   //boost coefficient to help with turning at speed
const TurnForceCoef = 0.8;  //portion of engine force for neutral turns
const RollingFriction = 1000;//force that needs to be overcome to get wheels turning
const EF = 25000.0;         //engine force
const BF = 20000.0;         //braking force
const EFr = 0.02;           //engine force reduction coef with speed
const maxkmh = 40;          //top speed


function radians(v){
  return v*Math.PI/180.0;
}


//invoked only the first time the model is loaded, or upon reload
function init_chassis(){
  var wheelparam = {
    radius: 0.50,
    width: 0.20,
    suspension_max: 0.25,
    suspension_min: -0.25,
    //ride height   
    suspension_stiffness: 3.9,

    damping_compression: 0.5,
    damping_relaxation: 0.4,
    slip: 4,
    slip_lateral_coef: 0.3,
    roll_influence: 0.1
  //rotation: -1
  };
  this.add_wheel('wheel1', wheelparam);
  this.add_wheel('wheel2', wheelparam);
  this.add_wheel('wheel3', wheelparam);
  this.add_wheel('wheel4', wheelparam);
  this.add_wheel('wheel5', wheelparam);
  this.add_wheel('wheel6', wheelparam);
  this.add_wheel('wheel7', wheelparam);
  this.add_wheel('wheel8', wheelparam); 
  this.add_wheel('wheel9', wheelparam);
  this.add_wheel('wheel10', wheelparam);
  this.add_wheel('wheel11', wheelparam);
  this.add_wheel('wheel12', wheelparam);
  this.add_wheel('wheel13', wheelparam);
  this.add_wheel('wheel14', wheelparam);
  this.add_wheel('wheel15', wheelparam);
  this.add_wheel('wheel16', wheelparam);
 
  this.load_sound("panther_eng_starter.ogg");
  this.load_sound("panther_trans_01.ogg");
  this.add_sound_emitter("turret");
 
  var geom = this.get_geomob(0);
  turret = geom.get_joint('turret');
  mantlet = geom.get_joint('Mantlet');
  barrel = geom.get_joint('barrel');
 
  return {mass:11500, com:{z:0.5,y:0.5}, steering:2.0, steering_ecf:60, centering: 100, centering_ecf:20,
    turretx_speed: radians(MaxTurretXSpeed),
    turrety_speed: MaxTurretYSpeed/TurretAngleSpan,
    turretx_accel: radians(MaxTurretXAccel),
    turrety_accel: MaxTurretYAccel/TurretAngleSpan,
  };
}

//invoked for each new instance of the vehicle
function init_vehicle(){
  this.set_fps_camera_pos({x:-0.5,y:0.00,z:3.40});
  this.snd = this.sound();
  this.geom = this.get_geomob(0);
  this.turx = this.tury = 0.0;
}

//invoked when engine starts or stops
function engine(start){
  if(start){
    this.snd.play(0, 0, false, false);
    this.snd.play(0, 1, true, true);
  }
  else
    this.snd.stop(0);
  this.started = start;
}

//handle extra actions
function action(k,v,dt)
{
  switch(k){
  case ATurretX: this.geom.rotate_joint_orig(turret, v, {x:0,y:0,z:-1}); break;
  case ATurretY: this.geom.rotate_joint_orig(mantlet, radians(TurretAngleSpan*0.5*(1+v)+MinTurretAngle), {x:1,y:0,z:0}); break;
  }
}

const forceloss = 1.0 / (EFr*maxkmh + 1);

//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering)
{
  var kmh = this.max_tire_speed()*3.6;
 
  //reduce engine force with speed (hack)
  var esign = engine<0 ? -1 : 1;
  engine = EF*Math.abs(engine);
  var force = (esign>0) == (kmh>=0)
        ? 1.0/(EFr*Math.abs(kmh) + 1)
        : 1.0;
  force -= forceloss;
  force = esign*Math.max(0.0, Math.min(force, 1.0));
  engine *= force;
   
  this.snd.set_pitch(0, 1+0.01*kmh);
   
  //if(steering!=0) engine *= 1.5;
  //var el = steering>0 ? 0 : engine;
  //var er = steering<0 ? 0 : engine;
  var df = EF*TurnForceCoef*force;
  var el=engine,er=engine;
  var spd = 1 + TurningBoost*this.speed();
  if(this.started){
    if(steering>0){
      el-=spd*df; er+=df;
    }
    else if(steering<0){
      er-=spd*df; el+=df;
    }
  }

  this.wheel_force(-2, el);
  this.wheel_force(-3, er);
   
  brake *= BF;
  brake += RollingFriction;

  this.wheel_brake(-1, brake);

  //this.log_inf("L:"+el+" R:"+er+"   B:"+brake+"  SPD:"+kmh);
 
  //this.geom.rotate_joint_orig(turret, this.turx, {x:0,y:0,z:-1});
  //this.geom.rotate_joint_orig(mantlet, this.tury, {x:1,y:0,z:0});

  this.animate_wheels();
}


I would like to thank cameni for the code to make the turret turn, the gun elevate and the tank perform more realistically.

In the model in max, I have left roads wheels as odd numbers and right road wheels as even numbers. The barrel has to be a child of the mantlet and the mantlet a child of the turret.

The pivot for the barrel needs to be moved to the turret end, so it will raise up/down.



http://farm9.staticflickr.com/8545/8708330090_dd69a09077_o.jpg larger pic.



Tiger 1 model by Vexman and skin by Snorri.


Jeff
« Last Edit: May 06, 2013, 04:05:17 am by murkz »
Logged

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: Panther G rigged!
« Reply #1 on: May 04, 2013, 05:36:02 pm »

Super nice!!!!
Logged

Foxiol

  • Full Member
  • ***
  • Posts: 101
  • Gamer
Re: Panther G rigged!
« Reply #2 on: May 04, 2013, 06:17:57 pm »

That looks incredible with those textures. Nice job.
Logged

ZeosPantera

  • ||>>-Z-<<||
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2520
  • #1 Outerra Fan Boy
    • My Youtube
Re: Panther G rigged!
« Reply #3 on: May 05, 2013, 12:54:29 am »

I will kill anyone you want for that Tiger 1 with a movable turret..

{anyone}
Logged
"Fear accompanies the possibility of death, Calm shepherds its certainty" - General Ka Dargo

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !
Re: Panther G rigged!
« Reply #4 on: May 05, 2013, 04:48:00 am »

I will kill anyone you want for that Tiger 1 with a movable turret..

{anyone}


You're better start to train like Leon then. And buying a nice plant to moisture every day.   ;D  ... fine work ! ... will definitely take some of it for my work later.  ;)
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: Panther G rigged!
« Reply #5 on: May 05, 2013, 01:47:54 pm »

The texture job looks amazing, I love the reflectance texture on the panther. I have to learn to do these now.


It seems that in order to import the turret, it needs to be at the root hierachy, as the chassis. Lucky that you showed that pic otherwise i would a hard time figuring this out.

On the tiger2 i can't seems to find the way to get the gun to move up and down. I did set the mantlet pivot right where the mantlet/turret meet. Do you have ideas as  what i could have done wrong?
Logged

murkz

  • Full Member
  • ***
  • Posts: 152
    • The Antisocial Gamer
Re: Panther G rigged!
« Reply #6 on: May 05, 2013, 01:52:20 pm »

I set the Panther G mantlet pivot slightly further back, so it would rotate around the turret correctly. Have you linked it as per the picture?

Other than that M7 I run out of talent, as I have no coding skills.

To get the starter sound to play:

this.snd.play(0, 1, true, false);

to

this.snd.play(0, 1, true, true);
« Last Edit: May 05, 2013, 01:54:36 pm by murkz »
Logged

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: Panther G rigged!
« Reply #7 on: May 05, 2013, 05:24:55 pm »

Thanks ! startup sound works now. As for the hierachy, i did follow the same order as in your pic.
Logged

murkz

  • Full Member
  • ***
  • Posts: 152
    • The Antisocial Gamer
Re: Panther G rigged!
« Reply #8 on: May 05, 2013, 06:33:48 pm »

Did you see I used a capital M for Mantlet?

Could that be it.

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: Panther G rigged!
« Reply #9 on: May 05, 2013, 09:50:09 pm »

Thanks again!!! it works!!!!
Logged

ZeosPantera

  • ||>>-Z-<<||
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2520
  • #1 Outerra Fan Boy
    • My Youtube
Re: Panther G rigged!
« Reply #10 on: May 05, 2013, 11:59:48 pm »

Damnit I will not have the release of these tanks held up by Syntax Capitalization Mistakes!
Logged
"Fear accompanies the possibility of death, Calm shepherds its certainty" - General Ka Dargo

murkz

  • Full Member
  • ***
  • Posts: 152
    • The Antisocial Gamer
Re: Panther G rigged!
« Reply #11 on: May 06, 2013, 02:01:29 am »

Well done M7 :)