Outerra forum

User mods, screenshots & videos => Vehicles => Topic started by: mLichy on April 20, 2013, 10:26:23 pm

Title: 57' Chevy Belair
Post by: mLichy on April 20, 2013, 10:26:23 pm
I made this 2-3 years ago for GTA IV.  Now I'm converting it for Outerra :) 

I'm currently spending time refining the geo and adding/adjusting detail. 
I have a bit of work to do though yet.  I've also been tweaking the shaders.

I have an issue with alphas though, where it causes the geo to turn black when in shadow.

I've got the handling working OK, and the scale should be almost right on, unless Max is wrong.
I'm working in Meters though and have the units set to 1 unit = 1 inch I think.... but that might be incorrect?

I had the front suspension on the Swing setup, but it was causing the wheels to be either too high off the ground then,
or too low.  Not sure why that is yet.

Anyways, more to come....


(http://i.imgur.com/lHB3RCp.jpg)
(http://i.imgur.com/6PSu6FV.jpg)
(http://i.imgur.com/SJjve1O.jpg)


Title: Re: 57' Chevy Belair
Post by: M7 on April 20, 2013, 11:13:27 pm
A beauty!
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 21, 2013, 03:22:01 am
Now all I hear is the Beach Boys.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 21, 2013, 08:46:51 am
Haha.  I want to try and add horn audio. But I'm not sure that works yet
Title: Re: 57' Chevy Belair
Post by: mLichy on April 21, 2013, 10:57:32 am
The scale seems about right I think?  ha ha

(http://i.imgur.com/3wGKlOh.jpg?1)
Title: Re: 57' Chevy Belair
Post by: mLichy on April 21, 2013, 10:02:56 pm
Improved the model, and added more detail.  Also tweaked the handling and some other stuff. 
I'll probably put up a download here soon, and let you guys mess with it. 

As you can see though, the car's wheels clip the ground or something, and cause it to jitter.
Should the Center of Mass be at 0,0,0 in Max?  The wheels then go below 0,0,0.

Audio may be loud..

[youtube]vnOx202roe8[/youtube]

Or if the video doesn't embed....
http://youtu.be/vnOx202roe8 (http://youtu.be/vnOx202roe8)
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 12:56:28 am
Ugh. YouTube fked up the video. Gets distorted.
Will re-upload probably.
Title: Re: 57' Chevy Belair
Post by: cameni on April 22, 2013, 02:16:52 am
That picture waving is youtube's attempt to correct the shaking?

Oh my ears :D
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 22, 2013, 02:43:53 am
Yeah the stabilization can do odd things to video game UI's

The car seems to drive pretty nice. The freak outs happen when the suspension can't travel up enough. You have to give an unrealistic travel and that will be fixed. The power and other handling seems fine.

One thing I would change is model the front headlights so you can put a chrome reflector and actual glass in front. Something all OT cars should have to set the standard.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 09:19:04 am
Thanks!

The front headlights are modeled, at least the upper ones.  Although not 100% accurate.  I have multiple layers of glass and then curved chrome behind.  But maybe I'll try to find ref images of the light and model it better. 

Thanks for the suspension tip :)

I want to try the swing arms again in the front, but the wheels then were half into the ground or way above I think.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 09:55:50 am
Here's the Download.  As I said, model is WIP yet, and really all of it :) 

Tweak the handling as you please!

The rest will be up to me yet.  But I will also keep fiddling with the handling/engine, unless someone else does it better ;).

Download

https://docs.google.com/file/d/0BxlmpYQ9TVWKSXB2dEhZOFM0YVE/edit?usp=sharing (https://docs.google.com/file/d/0BxlmpYQ9TVWKSXB2dEhZOFM0YVE/edit?usp=sharing)
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 22, 2013, 11:47:02 am
You may want to add "everyone" permission that file. I requested access but set up a million people will do the same.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 12:41:28 pm
Oh damn, sorry.  Ok.  I could also use Dropbox if that works?


Edit:  Should be public now.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 22, 2013, 12:51:55 pm
Works now, thanks.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 01:39:22 pm
Now I need to make it sound and act like this :) ,

http://www.youtube.com/watch?feature=player_detailpage&v=ZluH6AwlDBk#t=259s (http://www.youtube.com/watch?feature=player_detailpage&v=ZluH6AwlDBk#t=259s)
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 22, 2013, 01:46:02 pm
Ill work on that later.. Now I just need someone to model a 1958 Plymouth Fury..

(http://upload.wikimedia.org/wikipedia/commons/9/9c/Christine.jpg)

God, do I love that car.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 02:32:52 pm
hehe, well, I'm looking to make another car :)

I was thinking of many different ones I could make. 

 - Hearse
 - Bus
 - Model T or similar era car
 - 66 Chevy Nova SS
Title: Re: 57' Chevy Belair
Post by: mLichy on April 22, 2013, 07:29:23 pm
Think I might make this. Looks badass.

(http://americanclassicars.com/wp-content/uploads/2010/12/1949SamBarrisMercury.jpg)
Title: Re: 57' Chevy Belair
Post by: mLichy on April 23, 2013, 09:48:04 am
I think what I can do/what can be done on this belair too, would be to make 2 wheel Params, and set the front to slip less and rear to slip more.  I'm not sure it's currently rear wheel drive in-engine either, I think it might be FWD?
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 23, 2013, 11:26:16 am
Looks RWD from my testing. Unless it is all wheel drive.. TO THE CODE!!

Outerra - 57 Chevy [Stock Handling] (http://www.youtube.com/watch?v=M8Wt4Nui-VM#)
Title: Re: 57' Chevy Belair
Post by: mLichy on April 23, 2013, 11:42:20 am
It shouldn't be 4x4, but I copied the BMW code in and modded it a bit.  So it is probably whatever that was.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 23, 2013, 03:52:28 pm
Ok, I rubbed this down with my magic stick for two hours.

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

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

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

   var wheelparam2 =
    {
        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: 20,
        damping_compression: 0.1,
        damping_relaxation: 0.3,
        slip: 0.65,  //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',wheelparam2); //<-- the name "wheel_FR" is the name you used for your wheel in 3d max
    this.add_wheel('wheel_lf_L0',wheelparam2);
    //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',wheelparam2);
    this.add_wheel('wheel_lr_L0',wheelparam2);



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.85, 0.25, 0.25 ];             //base pitch for start, idle, throttle
    this.add_sound_emitter("wheel_lf_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 = 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.1}};
}

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

this.geom = this.get_geomob(0)
this.swheel = this.geom.get_joint("steering_Wheel_center_L0");
//this.geom = this.get_mesh_id("steering_Wheel_center_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 *= 6.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));

    //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();

    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]);
}

I am starting to get the hang of how odd this coding system works..

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?
Title: Re: 57' Chevy Belair
Post by: Chaoz on April 23, 2013, 03:54:03 pm
pls refrain from touching anything with your "magic stick"... :D
Title: Re: 57' Chevy Belair
Post by: mLichy on April 23, 2013, 04:20:37 pm
Is there a way to set the FOV for the FP camera?  I know we can set the position.  But it would be nice to be able to widen the FOV a bit. 
Title: Re: 57' Chevy Belair
Post by: deathevor on April 23, 2013, 07:15:08 pm
In game graphics menu.
But also thought if it's possible to set it in script (individually for each vehicle).
Title: Re: 57' Chevy Belair
Post by: mLichy on April 23, 2013, 07:45:06 pm
Yeah. I wanted to set for my specific car. Maybe it's just a code update to check if in FP mode of the vehicle like camera pos.  Then it picks up the custom fov
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 23, 2013, 11:16:37 pm
www.youtube.com/watch?v=tcUFIkyDB-w (http://www.youtube.com/watch?v=tcUFIkyDB-w#)
Title: Re: 57' Chevy Belair
Post by: mLichy on April 23, 2013, 11:34:22 pm
Haha. Nice. Hydraulics
Title: Re: 57' Chevy Belair
Post by: Juggernautz on April 24, 2013, 12:55:10 am
Hahaha. Zeos, you are a God amongst men. Looks like you've got the springy powerup from Carmageddon. ;)
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 24, 2013, 02:58:55 am
Don't quite know what to make of this car. The bounding box of the suspension must be messing with it. Even allowing a full meter of upward travel on the suspension she still flips out (very literally) when you are going fast across terrain. I did manage to get the multiple gear system working.

STILL LOOKING TO MOVE THE SOUND EFFECTS TO WHEEL RPM!! and not speed through the air.
Title: Re: 57' Chevy Belair
Post by: cameni on April 24, 2013, 04:54:37 am
I will add the wheel rpm into the wheel_data structure.
Title: Re: 57' Chevy Belair
Post by: mLichy 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.
Title: Re: 57' Chevy Belair
Post by: giucam 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.
Title: Re: 57' Chevy Belair
Post by: mLichy 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. 
Title: Re: 57' Chevy Belair
Post by: mLichy 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. 
Title: Re: 57' Chevy Belair
Post by: cameni 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.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera 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.
Title: Re: 57' Chevy Belair
Post by: cameni 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.
Title: Re: 57' Chevy Belair
Post by: mLichy 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.
Title: Re: 57' Chevy Belair
Post by: mLichy 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.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 28, 2013, 09:39:54 pm
new Version,

57' Belair (Outerra Engine) Test #2 (http://www.youtube.com/watch?v=clDPf4VdXmw#ws)

(http://i.imgur.com/R1j56XP.jpg?1)

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 (https://docs.google.com/file/d/0BxlmpYQ9TVWKUlBIRnVnNlJ4SW8/edit?usp=sharing)
Title: Re: 57' Chevy Belair
Post by: M7 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 .
Title: Re: 57' Chevy Belair
Post by: mLichy 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.
Title: Re: 57' Chevy Belair
Post by: M7 on April 28, 2013, 11:31:27 pm
yep center of mass did it , great!!
Title: Re: 57' Chevy Belair
Post by: mLichy 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.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 29, 2013, 11:17:05 am
I have also been playing with the new car and the new slip params.. They work great but make it even harder to get right.
Title: Re: 57' Chevy Belair
Post by: M7 on April 29, 2013, 11:24:01 am
Drive much better with that last js. Thanks a lot!

One things still confuse me though, when i hit the tab key and read the speed in knots, it doesn't quite match the speed in mph on the dashboard. Is the tab key reading wrong?
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 29, 2013, 11:39:21 am
It is Meters per second in the HUD. It was never knots they just didn't change it.

EDIT: Also Mlichy you should make the column shifter move when the car changes gear!
Title: Re: 57' Chevy Belair
Post by: mLichy on April 29, 2013, 12:09:26 pm
Yeah, I was thinking about that  ^.  Should be easy to do. 

I may also have the pedals move on gas/brake, but I'm not sure if you can animate
over time?  Not just have On/Off position, but move/slide between.  We'd want this for doors opening too, or other parts.  So it's a gradual open and not just open/close.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on April 29, 2013, 01:16:24 pm
Well the stuff of the airplanes moves that way.. So you should be able easily.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 29, 2013, 01:28:50 pm
That's what I was thinking.  But is that setup differently?  Or does it use the same base code?   

So otherwise, maybe I'd have to do some sorta if statement in the updateframe() and use that with rotate_joint_orig, and every frame, rotate it a bit, till I reach the value I want.....  I guess?

Similar to the steering wheel setup I have maybe.  I have the Bonnet/Boot rigged right now in the version you have, so you could test if you want.  I will test maybe tomorrow AM.  The engine audio is linked to the bonnet right now, so you could get the name from that. 
Title: Re: 57' Chevy Belair
Post by: cameni on April 29, 2013, 02:21:19 pm
Two ways, either animate via the script using the time that's passed as a parameter (see ddenn's mig29 script), or later it will be possible to control animations made in modeler directly.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 29, 2013, 02:35:00 pm
Ok. Cool. Thanks!  Yeah exporting from the DCC app would be great.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 30, 2013, 09:50:07 am
Took a real quick stab at adding in the slip_lateral property now.  It feels pretty good I think.
I was able to do a controlled drift for like 20meters or so around a bend, and recover fine.  Still needs work though probably.

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: 1.30,  //0.8
slip_lateral_coef: 0.80,
        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: 1.25,  //0.8
slip_lateral_coef: 0.72,
        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.15}};
}

//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]);
}
Title: Re: 57' Chevy Belair
Post by: M7 on April 30, 2013, 10:35:44 am
I'm no expert but it does feel right to me. Love it. I was trying to make some drift too but i just dont have the touch yet. I think this might get me to undust my usb steering wheel.
Title: Re: 57' Chevy Belair
Post by: mLichy on April 30, 2013, 10:55:21 am
ha ha, yeah.  It's not always drifting/easy to get into, which is cool.  But definitely makes it harder to do on a keyboard.  I should plug in my steering wheel! Forgot I had one! 
Title: Re: 57' Chevy Belair
Post by: ddenn on April 30, 2013, 11:25:24 am
Just found time to test your Belair - very nice work, thanks for sharing!
Title: Re: 57' Chevy Belair
Post by: mLichy on April 30, 2013, 12:38:12 pm
Thanks :)  It's still not "done", but not too far off.  Mainly small stuff now. 

Title: Re: 57' Chevy Belair
Post by: mLichy on May 12, 2013, 10:14:59 pm
**Update**

I've made some improvements/changes, so here's a new download!

Fixes/Changes:

- Tweaked Shaders.
- Improved/tweaked the handling (hopefully feels better?)
- Fixed some shading/geo issues on the car.
- Added more detail to geo in spots.
- Added Animated/Working Gear Lever/Gas Pedal/Brake Pedal.
- Added Animated Doors/Hood/Trunk  (Hold "O" Key to Open/Close.  Need to Animate Yet/Finish Engine Geometry).
- Added Floor Mats.
- possibly more stuff?

To Do:

- Add Manual Transmission/ Implement vehicle script by giucam.
- Animate Doors/Trunk/Hood over time.
- Finish Engine Bay/ Engine Geometry.
- Create final/better engine Audio and get it to sound more fluid.
- Potentially add smoke fx, extra audio.
- Add Horn Audio.
- Working Radio?


Download:

https://docs.google.com/file/d/0BxlmpYQ9TVWKUVlpck1qS044TjA/edit?usp=sharing
Title: Re: 57' Chevy Belair
Post by: deathevor on May 12, 2013, 10:57:18 pm
Just checked - it's brilliant.

Only 2 things:

1) Missing thumbnail
2) As you mentioned - you must hold "O"  to keep them open. Which is a bit "wrong".

Apart from that - it's brilliant.

Title: Re: 57' Chevy Belair
Post by: mLichy on May 12, 2013, 11:18:58 pm
Thanks.

Yeah , there is no way to have them stay open otherwise I don't think?
Maybe, I'll have to look into it. The open/close value changes on key depress.
But maybe I can override it.
Title: Re: 57' Chevy Belair
Post by: deathevor on May 12, 2013, 11:33:24 pm
I think Cameni mentioned that he've assigned few buttons as State buttons - which switch the state on the press.

Another thing is to make your own state in script, and change it on key pressed (not sure it will work - never tied in Outerra. :)
Title: Re: 57' Chevy Belair
Post by: deathevor on May 12, 2013, 11:40:47 pm
Right, wrong about first one:
http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code (http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code)
Only holding change the state.



Title: Re: 57' Chevy Belair
Post by: ZeosPantera on May 13, 2013, 12:17:04 am
Does the sound and Dash Gauge still not work on wheel rpm? I went flying off a cliff and it registered the car speed.

Do you think LOD switching will allow a CRAZY high detail engine only loaded when the hood is open. Because that would be amazing.

Why not look up how the MIG opens its landing gear? Do the same thing.
Title: Re: 57' Chevy Belair
Post by: cameni on May 13, 2013, 01:44:56 am
Right, wrong about first one:
http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code (http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code)
Only holding change the state.
That should be handled in the script by acting just on the key press (value=1), and remembering the state of the doors, doing open/close as needed.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 13, 2013, 09:30:58 am
I'll try and get the doors to stay open/closed using another method, and also animate.

They do not work on the wheel RPM.  I could swap out my engine code like I said, and use the vehicle script from the thread, which I think has that all setup already.  But doesn't it stop the engine audio then when the tires come off the ground?  Sounds very odd then. 

I'm not sure about the LOD stuff. I thought about that too.  We would need to be able to force swap/override an LOD model  in the script.
Although, in the engine case, specifically target an geomob.  Maybe I can just hide/unhide the lower/higher poly engine?
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on May 13, 2013, 12:20:12 pm
But doesn't it stop the engine audio then when the tires come off the ground?  Sounds very odd then. 

Only if the wheels are spinning when you go off the ground/cliff and you slam your brakes mid-air would your wheels stop and the engine go down to idle.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 13, 2013, 01:27:06 pm
I think when I tested the code he had, the engine audio cut out completely when the tires came off the ground.  But I need to try again to be sure.
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on May 13, 2013, 02:32:57 pm
I remember cameni saying something a year ago about the wheels only animating and giving power only when touching the ground. Could be the same setup causing that.. He will need to change that.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 13, 2013, 07:04:55 pm
Oh yeah, that is right I'm pretty sure.
Title: Re: 57' Chevy Belair
Post by: jeffmorris on May 13, 2013, 08:58:49 pm
Beautiful car! Please remove the gear shifter from the floor of the car. The car has gear shifter on the steering column.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 13, 2013, 09:27:23 pm
Thanks, yeah, I should remove that. 
Title: Re: 57' Chevy Belair
Post by: ZeosPantera on May 14, 2013, 03:51:33 pm
I found this talking about the 55 belair.. https://www.youtube.com/watch?feature=player_detailpage&v=iFflMym0RvA#t=191s (https://www.youtube.com/watch?feature=player_detailpage&v=iFflMym0RvA#t=191s) 

Yours might be too fast!
Title: Re: 57' Chevy Belair
Post by: mLichy on May 14, 2013, 05:37:09 pm
Yeah, it probably is.  I think probably accelerates too fast and maybe too high top speed.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 16, 2013, 08:58:18 pm
Right, wrong about first one:
http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code (http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code)
Only holding change the state.
That should be handled in the script by acting just on the key press (value=1), and remembering the state of the doors, doing open/close as needed.


I got the state working, so the doors open on Key Down, and don't close again till Key Down pressed.  Instead of holding the key down.
But I'm still unsure how to animate.

It seems like the dt passed into the action is only a static value.  It doesn't update per frame as the updateFrame Function.  I tried to pass in a global variable from updateFrame, but that doesn't seem to work either. 

 
Title: Re: 57' Chevy Belair
Post by: cameni on May 17, 2013, 03:25:23 am
dt is delta time, you have to accumulate it.
Title: Re: 57' Chevy Belair
Post by: mLichy on May 18, 2013, 09:30:57 pm
**Update**

- Added more detail to doors
- Doors/ect now Open on "O" Key Down, and close again on "O" Key Down.
- Added slightly more geo into engine, very minor.
- Removed Gear Shift on floor.
- Added Thumbnail image.

Download

https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing (https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing)
Title: Re: 57' Chevy Belair
Post by: Atrax on May 26, 2013, 08:13:06 am
Great model dude! Thanks for sharing, it's much appreciated!
And to many more to come =P
Title: Re: 57' Chevy Belair
Post by: bugsblake on May 30, 2013, 01:56:12 pm
thanks for this! and i love the update! :D working gears, foot pedals! love it! great job! only thing missing is shut off sound! great work!
Title: Re: 57' Chevy Belair
Post by: PytonPago on August 06, 2013, 01:29:05 pm
**Update**

- Added more detail to doors
- Doors/ect now Open on "O" Key Down, and close again on "O" Key Down.
- Added slightly more geo into engine, very minor.
- Removed Gear Shift on floor.
- Added Thumbnail image.

Download

https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing (https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing)

Thanks man ! ... i have a little question doe ... how in script is the "O" key bound to the AOpen event ? .... Want to try make an separate opening script for left and right doors trough else keys and im aether so damn blind or dont get it the right way.   :-\
Title: Re: 57' Chevy Belair
Post by: mLichy on August 06, 2013, 02:48:03 pm
I'd have to look at it at my PC. But should be bound via object names/Id.
But I don't think separate doors are supported yet via multiple buttons?

Maybe?
Title: Re: 57' Chevy Belair
Post by: PytonPago on August 06, 2013, 02:56:41 pm
I'd have to look at it at my PC. But should be bound via object names/Id.
But I don't think separate doors are supported yet via multiple buttons?

Maybe?

 .. yes, i was a little disoriented by the Camenys thread about car functions ... i hope its not a OT pre-defined button for the AOpen function, that its the "O" key ... that would make me sad.  :( If there would be a way to just change someway the key bound to each instance of the AOpen script (just like the constants multipliers used right now) ... it would be awesome. ... but, it may be the pre-defined way, cause OT probably has so the possibility to change the key-boundings trough the option menu that way.    ... Now thinking, this will make a hell of my BM-project. :O
Title: Re: 57' Chevy Belair
Post by: James on August 09, 2013, 01:09:44 am
(http://i.imgur.com/mm5ELcW.jpg)
Does this mean I'm a bad driver?
Title: Re: 57' Chevy Belair
Post by: Jagerbomber on August 09, 2013, 01:12:13 am
We can't see, but... I bet there's a 10 car pile-up underneath that giant car.
Title: Re: 57' Chevy Belair
Post by: James on August 09, 2013, 01:16:03 am
No, the car is just up really high because I flipped over and my car "flipped" out (hehe).
Title: Re: 57' Chevy Belair
Post by: Jagerbomber on August 09, 2013, 05:09:57 pm
lol Wasn't sure because the Alt says 0.
Title: Re: 57' Chevy Belair
Post by: mLichy on August 22, 2013, 09:24:38 am
I tried driving my car with a steering wheel a little while back, and it was quite difficult.  I'd maybe want to make adjustments based on keyboard/wheel input, or find a good medium I think. 
Title: Re: 57' Chevy Belair
Post by: patmarrnc on February 09, 2018, 12:50:43 pm
**Update**

- Added more detail to doors
- Doors/ect now Open on "O" Key Down, and close again on "O" Key Down.
- Added slightly more geo into engine, very minor.
- Removed Gear Shift on floor.
- Added Thumbnail image.

Download


https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing (https://docs.google.com/file/d/0BxlmpYQ9TVWKZ0tySkNpcms2Yjg/edit?usp=sharing)
Does anybody know if this Belair is still available anywhere for DL? The link above is the most recent one in the thread, and it's broken.
Title: Re: 57' Chevy Belair
Post by: M7 on February 22, 2018, 11:35:04 am
Looks like MLichy is not around anymore. I still have a version of the beautifull Belair and i dont think Mlichy would mind that i share. So just unzip and drop in your packages folder and should work.

https://1drv.ms/u/s!AnTWIilCTaDFgZUush18iPiNZRxPWQ
Title: Re: 57' Chevy Belair
Post by: patmarrnc on February 25, 2018, 06:03:40 pm
Looks like MLichy is not around anymore. I still have a version of the beautifull Belair and i dont think Mlichy would mind that i share. So just unzip and drop in your packages folder and should work.

https://1drv.ms/u/s!AnTWIilCTaDFgZUush18iPiNZRxPWQ

thank you very much!!