1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Like RaceDepartment on Facebook.

Car movables

Discussion in 'Racer Physics and Technical' started by MitchVL, Feb 23, 2011.

  1. This is for racer v0.8.33 and up !!!

    Movables in Racer are objects that are dynamic, so they can move, bounce, ...
    There are 4 types of movables in Racer:
    - Physics object
    - Skinned mesh with bone animation
    - Skinned mesh with bone physics (ragdoll)
    - Skinned mesh with bone physics AND bone animation

    for more information, take a look at: http://www.racer.nl/reference/animation.htm


    Car movables are just like movables on a track.
    The only difference is that their position is locked to the the car. So you can have all kinds of fun with it.
    Convertible roofs, passengers, ...

    Movables with physics dont make much sense since they will not follow the car's position (unless they have a joint connection with the car, but that requires scripting).
    Only the animated movables will follow the car !

    The best way to create your car-movable (skinned object) is to follow the steps to add a movable on a track (http://racer.nl/tutorial/animation.html ), and when all goes well, paste all the data to your car.

    Follow the steps to add movables to a track described in the tutorial.
    Now copy all the data from the track's geometry.ini to car.ini.

    copy the tree of the movable and paste it in car.ini.
    The name of the tree changes to model< n > and the tree must be located under 'graphics.movable'

    for example:
    Code:
    ; geomtrey.ini of a random track with a movables entry
    objects
    {
      danceguy02
      {
        file=danceguy02.dof
        flags=1024
        type=4
        trans_movable_to_zero=0
        rot_dyn
        {
          x=0.000000
          y=0.000000
          z=0.000000
          w=1.000000
        }
        offset_dyn
        {
          x=-93.354500
          y=1.264354
          z=-196.168533
        }
        group=0
      }
    }
    
    copy the above and paste it in car.ini
    Code:
    graphics
    { 
      movable
      {
        model0
        {
          file=danceguy02.dof
          trans_movable_to_zero=0
          type=4
          offset_dyn
          {
            x=0.0
            y=2.0
            z=0.0
          }
        }
      }
    }
    
    Now add the following script in <cardir>/scripts/paint
    create a file movable.rsx and paste this code in the file

    Code:
    wait 5000
    
    set kill after run 1
    
    rcar $car=get local car
    rmovable $mov = get $car movable 0
    command $mov do "play 0"
    
    Add your shader data to car.shd .. and voila ! You should have (in my case) a dancing guy on the top of the roof of a lambo.

    screenshot035.jpg

    Hoora !
     
  2. Epic stuff !! :wink:

    Just a question tho, what would the 'type' admit as values & what exactly does it stand for ? You're switching from a value of 3 to 4 when bringing it to car.ini...
     
  3. Oh ! the type is just something that Tracked takes care off. Don't mind that !
    I was just toggling between types for debugging help.
    It's for defining the type of movable

    Editted !
     
  4. I dont mind how it will work on convertible cars or for other movables, but I am curious :D
     
  5. Cool stuff there Mitch! :)
    I'm still having trouble getting retractable headlights to work. I've been pulling my hair out trying to figure out how to get the headlights to translate their position then rotate at their local center point. In other words the headlights are modeled so that the headlights pivot point is 0,0,0 once I translate this with the command "set ($lites) rotation float[3]{0,0.314159,0}" the headlights will rotate about the cars origin.

    While I'm at it, why do we need to work in radians? I understand it from a programming standpoint, but it's just another thing to look up each time.

    Thanks
    Alex Forbin
     
  6. Well, to solve your rads problem...why not just have a float3 that has your degrees in it and multiply that by pi/180?

    Which brings me to another point I wanted to bring up... In the data/scripts folder, can we have a utils.rsx or similar that we can then reference - for things like deg to rad. I'm unsure if the scripts will compile properly if they're referenced from outside a [cardir]/scripts/XXX/ folder...
     
  7. you can include files

    try something like

    import "test/test.rsx"

    or even

    import "../test/test.rsx"

    The files that you import can not be in the same folder as the script file.
    Otherwise the import file will be compiled separately as well !
     
  8. Ah, yeah, that's what I was wondering...
    If we said import "../../../scripts/utils.rsx" if that would compile properly.
    You know...if we got access to some cg vars (or could make them) then I have a pretty nice DOF shader that we could make into a photomode thing... Press X for photomode and then different buttons could affect different vars.
     
  9. Good idea, I hadn't thought of that.

    Alex Forbin
     
  10. how about standard key framed animation export? I think it's easier to make animated rigid objects then setting them up via scripting. Anyway, nice work Mitch!