Road with borders using "animation fg" feature

Learn here how to create and use plugins.

Moderator: KoalaGuy

Post Reply
danekbel
Former danek_danevich
Reactions:
Posts: 2422
Joined: Thu May 05, 2016 9:33
Plugins: Show

Road with borders using "animation fg" feature

Post by danekbel » Wed Dec 13, 2017 0:52

Want to make that pretty road with borders?
preview.png
preview.png (266.26 KiB) Viewed 283 times
Then read the tutorial! :space

As you can see, cars aren't visible behind the borders. If you provide that borders directly to the road texture, cars would just ride over it, but, not now.

It became possible because of existing of animation fg feature.

REQUIREMENTS

For that borders, you should provide them as a animation. For our case, we need just two of them:
border_fg_left.png
border_fg_left.png (251 Bytes) Viewed 283 times
border_fg_right.png
border_fg_right.png (277 Bytes) Viewed 283 times
TEXTURE

The background is directly applied to the road frames:
frames.png
frames.png (3.72 KiB) Viewed 283 times
JSON

The important part is to figure out for which frames which animation has to be shown. Here a sketch where the needed fg animations are marked:
frames_where_borders_are_needed.png
frames_where_borders_are_needed.png (6.92 KiB) Viewed 283 times
And then some of magic in our code: :json

Code: Select all

[
  {
    "id":"$anim_road_bordered00_left00",
    "type":"animation",
    "frames":[{"bmp":"border_fg_left.png","handle y":8}]
  },
  {
    "id":"$anim_road_bordered00_right00",
    "type":"animation",
    "frames":[{"bmp":"border_fg_right.png","handle y":8}]
  },
  {
    "id":"$road_bordered00",
    "type":"road",
    "level":2,
    "frames":[{"bmp":"frames.png","w":32,"count":16}],
    "animation fg":[
      {"id":"$anim_road_bordered00_left00"},
      {"id":"$anim_road_bordered00_right00"}
    ],
    "frame animation fg indices":[
      [0,1],
      [0],
      [0,1],
      [0],
      
      [0,1],
      [0],
      [0,1],
      [0],
      
      [1],
      [],
      [1],
      [],
      
      [1],
      [],
      [1],
      []
    ]
  }
]
We have two images (animation objects) for the front left/right border. We can say for which of the 16 road frames which animation (or both or none of them) should be shown. That's what the long (maybe a bit scary) array is good for:

Code: Select all

    "frame animation fg indices":[
      [0,1],  // Show 0th and 1th animation for first frame, that means left & right border
      [0],  // Show only left border for second frame
      [0,1],  // Show left & right borders for third frame
      [0],  // Show only left border for fourth frame
      
      [0,1], // Show left & right ...
      [0],  // Show only left
      [0,1], // Show left & right
      [0],  // Show only left
      
      [1],  // Show right
      [],  // No front border
      [1],  // Show right
      [],  // No front border
      
      [1],  // Show only left
      [],  // No front border
      [1],  // Show only left
      []  // No front border
    ]
And voila! Our plug-in is finished.
bordered_road.zip
(11.77 KiB) Downloaded 20 times

Big thanks to @Lobby for texture, text and realisation of this feature itself.

User avatar
TheFennekin
Inhabitant of a Solar System
Reactions:
Posts: 1755
Joined: Thu Aug 24, 2017 11:17
Location: Here
Plugins: Show
Version: Beta
Phone: Samsung Galaxy Tab4

Re: Road with borders using "animation fg" feature

Post by TheFennekin » Wed Dec 13, 2017 0:57

Yes!
I miss you 😫
Plugin pack coming soon!

Post Reply

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest