• 28000+ Members! Dear Guest, click this link to join the RD Army on our official Discord server

3D Gauges

Mari17

10RPM
May 19, 2012
18
14
29
Hi!

On our Polish forum trying to create a script that will handle the tachometer indicator. The script engine speed of rotation is very simple, but the problems start when it inclined at an angle. Indicatnor is not behaving like texture without views.ini added. Do you have any ideas on how to bend it correctly because we are over ideas :-P

Skybh used in the Renault Laguna, but just like us indicator are flat.

This is Elektryk`s script:
Code:
rcar $car = get scriptowner car
float $rpm=0

rcarmodel $wskazowka = get generic model 8 of $car
set $wskazowka scriptcontrolled 1

while 1
{
$rpm=get $car rpm
if $rpm > -5
{
set $wskazowka rotation float[3]{0,0,$rpm/2000}
  set $wskazowka position float[3]{0,0,0}
}


  interrupt
}
 

Stereo

3000RPM
Dec 22, 2009
3,755
4,579
Should just be able to set one of the other rotation angles to a constant if I understand the problem right, eg. float[3]{0, 0.2, $rpm/2000}. I don't know offhand whether that works completely though, not sure what kind of rotation vector the scripts use.
 

Mari17

10RPM
May 19, 2012
18
14
29
Yes, this works, but it gives the same effect as turning the model in ZModeler. Indicator moves all the time axis, and the model is only tilted. We want to turn the axis on which the indicator moves, and not the model itself.
 

Stereo

3000RPM
Dec 22, 2009
3,755
4,579
Ah yeah, gonna have to do trigonometry then, something like
$anglez = $rpm/2000
$anglex = 0.2 * sin $anglez
$angley = 0.2 * cos $anglez
float[3]{$anglex, $angley, $anglez}

I don't have an object set up to test this though so can't say I have the code written correctly. I remember having trouble with multiple operations per line of code but not sure in what way.


It's a yaw-pitch-roll system afaik so you might be able to look up how to do rotation compositions (ie. first a pitch of 0.2 radians, then a roll of $rpm/2000)
 
Last edited:

skybh

250RPM
Apr 5, 2009
364
269
Humm i've tried to that do (inclined needles). But since the rotation point of the model should be placed on car's CG.. If you move you cg, the rotation won't stay ok :(
(I hope you understand what i mean)
For exemple just change CG location of car with opening doors, and see the result lol
 

Mari17

10RPM
May 19, 2012
18
14
29
Skybh if I understand you correctly, it is enough to racer.ini move_cg change from 1 to 0 ;)