1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Speed sensor and digital shower in track

Discussion in 'Racer Problems & Fixes' started by AMGfan(BPM), Jun 28, 2010.

  1. I was wondering if is it possible to add a speed sensor radar in track? racer has any feature to measure speed in spline and show digital value using view.ini?

    like it

    thanks in advance.
  2. Stereo

    Premium Member

    The scripts added in last versions can definitely read car speed, whether they can then display it on a track object I'm not sure. Having it display on-screen is easier, but that'd look a lot like a regular speedometer:wink:

    Maybe if you set up the sign with animation sequences to display each number the script could set those?
  3. @stereo: what about variables? like $mirror, $tracksunmap and the likes... would there not be one for $speed (or whatever) as well? Else it would be hard to make dials? Just pondering.. that's all. :)
  4. It should be possible via the scripting, but I have NO idea how all that works yet, there don't seem to be any docs available that I know of!? Search Racer.nl seems to be the only elegant way to find some stuff :D

    But I guess as Stereo said, when the car crosses a point in the track, the script could read out car world velocity (not wheel velocity), and then set an image to be rendered on a track object... better yet, have three polys textured, and then slide the X coord of the UVW mapping across to the right number (0-9) and set the speed that way!?
    Better than having about 350 textures from 0 >> whatever speed you want (350 in this case)


  5. hmmm interesting! looks complex. Ruud, can you explain if is it possible?

  6. Stereo

    Premium Member

    Yeah, the part I can't figure a 'best method' is editing the track appropriately. I don't see any options to just swap textures on an object. The scripting is also pretty much a track based feature, and I haven't done any track editing. So I don't really know how a track is put together.

    One potential way would be to model the individual elements of a 7-element display as separate .dof's, then have the script show/remove them appropriately (eg. a 5 is top, middle, bottom, upper left, lower right). Or just have 10 different dofs for 0 through 9.

    I guess I'll have to fool with scripts to see what it actually works out to.
    The relevant commands I guess are
    rcar = get car (int)
    x = get rcar velocity x
    / etc. for y, z
    speed = sqrt(x^2+y^2+z^2)
    / convert units, since speed is likely in m/s
    / separate out the 3 digits (hundreds, tens, ones)
    rnode = get node trackdir + "/" + "tens" + digit + ".dof"
    / eg. "carlswood_nt/tens0.dof"
    hide rnode
    show rnode
    wait 1000
    / so it waits a second before showing another speed

    I think this would be sufficient to work the display. But I haven't tried it ingame, and there's a lot of looping I glossed over, as well as how to write it efficiently (eg. store previous values, so it only has to hide 1 number and reveal 1 number, instead of checking all 10 are in correct mode every time)
  7. In theory you could make a 10 sided cylinder with each face 0...9

    Then simply rotate them within the 'enclosure'

    It would end up being fairly large though, it might look odd. It might be better to try order them instead, so they are all occupying the same place except one which is brough forward a little!? May be depth issues then though.


  8. You mean like digital speedo or shift light in car view? when it rotates, etc
  9. That is indeed how you can script a speedtrap (hiding nodes ...)

    Great to see someone using the scripting language :)
    Requests for how to expand functionality are always welcome.
  10. Stereo

    Premium Member

    The most obvious expansion to me (probably a major effort to implement) would be to allow *.ini files to use shared variables.

    So eg. you could have special.ini:gfx.sun.diffuse=$float1 $float2 $float3, and run a custom script to set up the lighting changing (script the sun going behind clouds, where diffuse and sun intensity drops quite a bit temporarily, for example, or if the time of day is available, run entirely custom lighting)
    Or more related to this topic, track.shd:shader_speedtrap.layer0.file= $filenamestring, though in this case you'd probably want some limitations on the values it can take (eg. have the script required to list off all the textures it will want at the beginning in some sort of definition, so they're loaded when you start the track)