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

Pages: 1 2 [3] 4 5 6

Author Topic: 57' Chevy Belair  (Read 39781 times)

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6542
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: 57' Chevy Belair
« Reply #30 on: April 24, 2013, 04:54:37 am »

I will add the wheel rpm into the wheel_data structure.
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #31 on: April 24, 2013, 08:35:53 am »

Well that's why I asked, should the position of the car matter in Max when exporting? Right now the vehicle is centered to 0 based on the chassis center.
So the wheels go below 0.
Logged

giucam

  • Full Member
  • ***
  • Posts: 171
  • It's an ugly pile of bones... like me.
Re: 57' Chevy Belair
« Reply #32 on: April 24, 2013, 08:58:10 am »

One of the biggest issues is that the sound doesn't correspond with the wheels spinning. So I am ramping up the torque to burnout levels and the vehicles emits the same slow movement sounds. Is there a way to have the sound alter pitch based on the actual wheels rotating?

It does not make sense to change the pitch based on the wheels rpm. The pitch of an engine sound depends of the engine rpm, and that's what that code does:
Code: [Select]
    var pitch = this.pitchMultiplier * rpm / this.maxRPM;
    this.snd.set_pitch(0, pitch + this.basepitch[this.sound]);

Changing this.pitchMultiplier, this.maxRPM or this.basepitch allows you to change how the pitch is calculated for a given rpm.

P.S. Please keep the copyright header, right now you're infringing the GPL. You are welcome to add your own copyright line for the modifications you do of course.

EDIT: But yeah, currently the engine rpm is calculated from the car speed. Once there will be a way to get the wheels rpm going freefall won't make the pitch go crazy.
« Last Edit: April 24, 2013, 09:06:44 am by giucam »
Logged
ResidualVM 0.1.1 is OUT! www.residualvm.org

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #33 on: April 24, 2013, 11:28:06 am »

I'm going to try moving the vehicle in Max so that the tires just touch the grid plane.  According to the values for the tire size, it really should be 2x that size I think, according to max.

I believe it should be around 0.66~ and not 0.34. 
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #34 on: April 25, 2013, 05:03:59 pm »

Well, I can try 1 more thing. But, having the wheel bottoms at 0 didn't work.  Having their centers at 0 didn't work, unless the chassis pivot/COM has to be at 0 then. 

In the one vhicle tutorial, it looks like their wheel centers are at 0, and the chassis bottom touches 0.  But they don't show where the chassis pivot actually is.  Unless it is at 0,0,0. 

I wonder how the BMW and other cars are setup?  But, it seems like the current handling on the Belair is pretty good?  It doesn't flip that bad I don't think.  Not as easily as it did before.  Might just have to move the COM lower otherwise or dampen the suspension more. 

It does seem like the weight in the engine is a bit light? Or at least when the vehicle starts to flip, it goes crazy. 
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6542
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: 57' Chevy Belair
« Reply #35 on: April 26, 2013, 01:06:30 am »

What problem are you trying to solve?

In Max it should beirrelevant what the absolute position of the pivot is, everything is computed relative to the pivot. In Sketchup the problem seems to be that you can't set the pivot and it's at 000.
For tires you specify their radius, not diameter.

The flipping problem has nothing to do with the weight, but the forces that are generated when the wheel hits ground too fast and goes below the terrain are sometimes too big, ejecting the whole vehicle into the air. There are ways how to solve it, finer simulation step being the simplest one of them.
Logged

ZeosPantera

  • ||>>-Z-<<||
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2517
  • #1 Outerra Fan Boy
    • My Youtube
Re: 57' Chevy Belair
« Reply #36 on: April 26, 2013, 01:13:57 am »

How about the issue where you press the forward key and the engine start sound begins to play and you get a 2-3 second window of no control where the wheels are not animating but the car driving/sliding forward and you then gain control. You can see it happen in my video above.
Logged
"Fear accompanies the possibility of death, Calm shepherds its certainty" - General Ka Dargo

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6542
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: 57' Chevy Belair
« Reply #37 on: April 26, 2013, 02:46:49 am »

That's because the first key press isn't counted as pressing the pedal but as the ignition, and you have to release it and press again. But yea it's confusing. A separate engine starter will solve that issue, but I have to fix it also for this case of starting and going with one key. Probably will register the first key press too, but the engine force will not jump into full value immediately in that case.
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #38 on: April 26, 2013, 09:49:26 am »

Ok, that makes sense.   That's what it looked like (radius), that tutorial said to use Diameter.
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #39 on: April 28, 2013, 07:48:53 pm »

Looks like the wheels spinning now causes the sound to go wacky, or something.  Using the latest build I mean.

I got the interior refined alot more, and fixed some other issues.  Will post a new download tomorrow or something.
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #40 on: April 28, 2013, 09:39:54 pm »

new Version,





Fixes

- Working Speedometer (accurate to within ~2MPH?, converted from Kmh to Mph)
- Working Gear Needle
- Fixed Audio bug , now Mono.
- Improved/"finished" interior, alot more detail and more accurate.
- Tweaked handling
- Tweaked shaders
- probably more stuff.


Download
https://docs.google.com/file/d/0BxlmpYQ9TVWKUlBIRnVnNlJ4SW8/edit?usp=sharing
« Last Edit: April 28, 2013, 11:18:16 pm by mLichy »
Logged

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: 57' Chevy Belair
« Reply #41 on: April 28, 2013, 11:07:35 pm »

Love the upgrades. Nice new details inside, love the new upholstry. Only one thing is the car dont turn much at anything but very low speed. I tried to play with the js file but it's either its not turning or it will flip too easaly  if i add any grip .
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #42 on: April 28, 2013, 11:14:33 pm »

Yeah.  It's very finicky. Might need to tweak the center of mass.
With the new engine updates from today, the wheels slip even easier I think.

Thanks for the comments :).

I might start working on that mercury eight here soon.
But I want to get this driving a bit better. Also better audio.
« Last Edit: April 28, 2013, 11:16:45 pm by mLichy »
Logged

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie
Re: 57' Chevy Belair
« Reply #43 on: April 28, 2013, 11:31:27 pm »

yep center of mass did it , great!!
Logged

mLichy

  • Full Member
  • ***
  • Posts: 104
  • newbie
Re: 57' Chevy Belair
« Reply #44 on: April 29, 2013, 09:41:20 am »

Here's better handling.  Although now prob. should tweak Acceleration again, or both.  Definitely is a balancing act.
Although cornering at around 40MPH seems not too bad.  Comparing to Forza 4 physics anyways. 

They have Traction control and ABS in there though too.  Which this car wouldn't have.  So that def. helps drive easier.
But I want to make this more fun to drive and not constantly be swerving off the road.


Code: [Select]
//vehicle script file
//see http://xtrac.outerra.com/index.fcgi/wiki/vehicle for example and documentation

/*
 *   Vehicle script file
 *   Copyright (C) 2013  Matt Lichy
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

//*******ENGINE Template/Code by ZeosPantera of Outerra Forum. *********

//invoked only the first time the model is loaded, or upon reload
function init_chassis(){

   var wheelparam =
    {
        radius: 0.34, //<-- edit this to 0.3 (remember our wheel radius of 30cm!)
        width: 0.15, //<-- edit this to 0.2 (this represents the height parameter in 3d max of 20cm!)
        suspension_max: 0.3,
        suspension_min: -0.1,
        suspension_stiffness: 25,
        damping_compression: 0.1,
        damping_relaxation: 0.3,
        slip: 2.22,  //0.8
        roll_influence: 0.1,
rotation: -1.0
   };
       
   var wheelparam_Rear =
   {
        radius: 0.34, //<-- edit this to 0.3 (remember our wheel radius of 30cm!)
        width: 0.15, //<-- edit this to 0.2 (this represents the height parameter in 3d max of 20cm!)
        suspension_max: 0.3,
        suspension_min: -0.1,
        suspension_stiffness: 21,
        damping_compression: 0.1,
        damping_relaxation: 0.3,
        slip: 2.08,  //0.8
        roll_influence: 0.1,
rotation: -1.0
   };
       
//http://www.outerra.com/forum/index.php?topic=1561.msg17833#msg17833
//Wheelbase 115"
//Length 195.6"    
//V8 Bel Air with Powerglide as being 0-60 mph in 12.9 seconds

    this.add_wheel('wheel_rf_L0',wheelparam); //<-- the name "wheel_FR" is the name you used for your wheel in 3d max
    this.add_wheel('wheel_lf_L0',wheelparam);
    //this.add_wheel_swing('suspension_rf_L0', 'wheel_rf_L0', wheelparam);
//this.add_wheel_swing('suspension_lf_L0', 'wheel_lf_L0', wheelparam);
this.add_wheel('wheel_rr_L0',wheelparam_Rear);
    this.add_wheel('wheel_lr_L0',wheelparam_Rear);
   
    this.load_sound("belair_startup.ogg"); //startup
    this.load_sound("belair_onidle.ogg"); //idle
    this.load_sound("e90_offlow.ogg");    //off
    this.load_sound("e90_onlow.ogg"); //on
    this.basepitch = [ 0.3, 0.95, 0.20, 0.20 ];             //base pitch for start, idle, throttle
    this.add_sound_emitter("bonnet_L0");

    //engine properties -- modify these to change the engine behaviour
    this.wheelRadius = 0.34;

    this.torquePoints = [ { rpm: 0,    torque: 1080},
                          { rpm: 1000, torque: 1120},
                          { rpm: 2000, torque: 1235},
                          { rpm: 3000, torque: 1380},
                          { rpm: 4000, torque: 1400},
                          { rpm: 5000, torque: 1415},
                          { rpm: 6000, torque: 1400},
                          { rpm: 7000, torque: 0},
                          { rpm: 8000, torque: 0},
                          { rpm: 9000, torque: 0  } ];

    this.forwardGears = [ { ratio: 4.00, shiftUp: 5000, shiftDown: -1   },
                          { ratio: 3.00, shiftUp: 5000, shiftDown: 2500 },
                          { ratio: 2.00, shiftUp: 5000, shiftDown: 3000 },
                          { ratio: 1.50, shiftUp: 5000, shiftDown: 3000 },
                          { ratio: 1.00, shiftUp: -1,   shiftDown: 3000 } ];
    this.reverseGears = [ { ratio: 4.20, shiftUp: -1, shiftDown: -1 } ];

    this.finalRatio = 4;
    this.torqueMultiplier = 1.45;   //2.25
    this.maximumSpeed = -1; // speed in m/s. a value < 0 means there's no maximum speed
    this.engineBrakeCoefficient = 0.1;
    this.breakingForce = 3800.0;
    this.pitchMultiplier = 0.6;
    //end of engine properties

    this.maxPowerTP = this.torquePoints[0];
    this.maxRPM = 5800;
    var maxPw = 0;
    for (var i = 1; i < this.torquePoints.length; ++i) {
        var tp = this.torquePoints[i];
        if (tp.rpm * tp.torque > maxPw) {
            this.maxPowerTP = tp;
        }
        if (tp.rpm > this.maxRPM) {
            this.maxRPM = tp.rpm;
        }
    }

    this.neutroGear = { ratio: 0.0, shiftUp: -1, shiftDown: -1, index: 0 };
    var prev = null;
    for (var i = 0; i < this.forwardGears.length; ++i) {
        var gear = this.forwardGears[i];
        if (prev)
            prev.next = gear;
        gear.prev = prev;
        gear.index = i + 1;
        prev = gear;
    }

    prev = null;
    for (var i = 0; i < this.reverseGears.length; ++i) {
        var gear = this.reverseGears[i];
        if (prev)
            prev.next = gear;
        gear.prev = prev;
        gear.index = -i - 1;
        prev = gear;
    }


    this.torque = engineTorque;

    return {mass:1570, steering:1.0, steering_ecf:10000, centering: 2.0, centering_ecf: 10, com:{y:0.2, z:-0.10}};
}

//invoked for each new instance of the vehicle
function init_vehicle() {
    this.set_fps_camera_pos({x:-0.32,y:-0.38,z:0.67});

this.geom = this.get_geomob(0)
this.swheel = this.geom.get_joint("steering_Wheel_center_L0");
    this.speedometer = this.geom.get_joint("speed_Needle_L0");
    this.gearNeedle = this.geom.get_joint("gear_Needle_L0");

    this.snd = this.sound();
    this.snd.set_ref_distance(0, 9.0);

    this.started = false;
    this.gear = this.neutroGear;
    this.direction = 0;
}

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

function engineTorque(rpm) {
    var min = 0;
    var max = this.torquePoints.length - 1;

    if (rpm > this.torquePoints[max].rpm || rpm < this.torquePoints[min].rpm)
        return 0;

    while (max - min > 1) {
        var mid = Math.floor(min + (max - min) / 2);
        var tp = this.torquePoints[mid];
        if (tp.rpm == rpm) {
            return tp.torque;
        } else if (tp.rpm > rpm) {
            max = mid;
        } else {
            min = mid;
        }
    }

    var minTp = this.torquePoints[min];
    var maxTp = this.torquePoints[max];
    var TM = maxTp.torque;
    var Tm = minTp.torque;
    var RM = maxTp.rpm;
    var Rm = minTp.rpm;

    var a = (TM - Tm) / (RM - Rm);

    return rpm * a + Tm - Rm * a;
}

function sign(x) {
    return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0));
}

//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering) {
    if (!this.started)
        return;

    if (this.sound == 0 && this.snd.is_playing(0)) { // still starting up
        return;
    }

    steering *= 0.65;
    this.steer(-2, steering);

var steerAngle = steering *= 10.05;
this.geom.rotate_joint_orig(this.swheel, steerAngle, {x:0,y:0,z:1});
   

    var absSpeed = Math.abs(this.speed());
    var khm = absSpeed * 3.6;
    var wheels = absSpeed / (this.wheelRadius * (2 * Math.PI));
   
    //this.log_inf("Khm" + khm);
   
    //Rotate Spedometer Needle
    var spedo = (absSpeed / 8.35) / 1.6;  //Divide to get into 0-120 rotation range, then divide to convert Kmh to MPH roughly.
    if (spedo < 201)  //roughly 120 MPH
    {
        this.geom.rotate_joint_orig(this.speedometer,spedo,{x:0,y:0,z:-1});
    }
     
    //automatic gear shifting
    var rpm = wheels * this.gear.ratio * this.finalRatio * 60;
    if (rpm < 5 && this.gear.index != 0) {
        this.gear = this.neutroGear;
        this.direction = 0;
//         this.log_inf("neutro");
    }
    if (engine != 0.0 && sign(engine) != this.direction) {
        this.direction = sign(engine);
        if (this.direction == 1.0) {
            this.gear = this.forwardGears[0];
//             this.log_inf("forward, gear " + this.gear.index);
        } else if (this.direction == -1.0) {
            this.gear = this.reverseGears[0];
//             this.log_inf("reverse, gear " + this.gear.index);
        }
        rpm = wheels * this.gear.ratio * this.finalRatio * 60;
    }

    if (rpm > this.gear.shiftUp && this.gear.next) {
        this.gear = this.gear.next;
//         this.log_inf("gear up " + this.gear.index);
    } else if (rpm < this.gear.shiftDown && this.gear.prev) {
        this.gear = this.gear.prev;
//         this.log_inf("gear down " + this.gear.index);
    }

    rpm = wheels * this.gear.ratio * this.finalRatio * 60;

    if (this.maximumSpeed < 0 || this.speed < this.maximumSpeed) {
        var force = engine * this.torque(rpm) * this.torqueMultiplier * this.gear.ratio;
        this.wheel_force(2, force);
        this.wheel_force(3, force);
    }

    //From Torcs engine code
    var static_friction = 0.1;
    var engineBrake = this.maxPowerTP.torque * this.engineBrakeCoefficient * this.torqueMultiplier * this.gear.ratio *
                      (static_friction + (1.0 - static_friction) * rpm / this.maxRPM);

    brake *= this.breakingForce;
    this.wheel_brake(-1, brake + engineBrake);

    this.animate_wheels();
   
    //Move Gear Needle into spot based on engine
     //this.log_inf("Gear " + this.gear.index);
   
    if (this.gear.index >= 1) //Drive
    {
       this.geom.rotate_joint_orig(this.gearNeedle,0.55,{x:0,y:0,z:1});
    }
   
    if (this.gear.index == -1) //Reverse
    {
       this.geom.rotate_joint_orig(this.gearNeedle,1.10,{x:0,y:0,z:1});
    }
   
    if (rpm < 5 && this.gear.index == 0) //Neutral
    {
        this.geom.rotate_joint_orig(this.gearNeedle,0.35,{x:0,y:0,z:1});
    }
   
    if (this.gear.index == 0 && (!this.snd.is_playing(0) || this.sound != 1)) {
        this.snd.stop(0);
        this.snd.play(0, 1, true, false);
        this.sound = 1;
    } else if (this.gear.index != 0 && engine == 0 && (!this.snd.is_playing(0) || this.sound != 2)) { //idle
        this.snd.stop(0);
        this.snd.play(0, 2, true, false);
        this.sound = 2;
    } else if (this.gear.index != 0 && engine != 0 && (!this.snd.is_playing(0) || this.sound != 3)) { //throttle
        this.snd.stop(0);
        this.snd.play(0, 3, true, false);
        this.sound = 3;
    }

    var pitch = this.pitchMultiplier * rpm / this.maxRPM;
    this.snd.set_pitch(0, pitch + this.basepitch[this.sound]);
}


*edit - Now that we can add another layer of tire slip, I need to get that into the mix. 
So I could have the tires slip a bit forward/reverse, but grip better while turning, like how it should be.
« Last Edit: April 29, 2013, 10:59:23 am by mLichy »
Logged
Pages: 1 2 [3] 4 5 6