Jump to content
boformer

Custom Animation Loader (CAL): Mesh Animations for Buildings

40 posts in this topic Last Reply

Highlighted Posts

  • Original Poster
  • Posted:
    Last Online:  
     

    The mod is almost ready, currently only supports buildings.

    I would like to release it simultaneously with some animated buildings, so I can link them in the description.

    Would anyone be interested in creating an animated building? It can be any kind of building, the limitation is that the animation must be repeating.

    I can assist if you are using Blender.

    I got a few ideas:

    Merry go round

    Ferris wheel

    Some kind of industrial asset with moving conveyor belts or rotating fans

    Tube man

    Excavator

    Skyscraper with outside elevators

    Crowd of people (Beach scene)

    Playground

    Swimming pool with swimmers

    Construction crane

    Harbour crane

    Water fountain

    Escalator

    Horse race track

    Rotating billboard

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    OO, very cool stuff!

    If anyone is short on ideas, one of those louvered billboards that rotates between ~3 different images would be pretty nifty. Or a kinetic art installation. Or a wacky flailing arm inflatable tube man. :D

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    I created a video that shows the asset creation workflow.

    The mod is also ready, you can download it and the tutorial files on the STEX. It supports buildings with bone animations.

    It's not yet published on the steam workshop because I want to publish it along with a few buildings. It's your turn! :D

     

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Important:

    There was a 0Harmony.dll file missing in the tutorial files that caused the mod to fail on load.

    I've added it to the zip file. So to the 7 people that already downloaded it: Please do it again!

    Also, it helps to try the mod in --noWorkshop mode (so far I've not checked if there are any incompatibilities with other mods)!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    This is super exciting! I guess a moving harbor crane is high on my list of things to do when I get back to asset creation now. :D 

    • Like 1

    My workshop items

    Catch my latest project and future plans on my Patreon page

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    This is great! How complex can the skeletons be? Would it be able to support things like IK handles?

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    32 minutes ago, nosh59 said:

    This is great! How complex can the skeletons be? Would it be able to support things like IK handles?

    To be honest, I'm quite new to this so I had to google what IK handle means, and I still don't fully understand it :D

    The limit is basically what can be imported into Unity Editor 5.6.6f2 (the version used by the game). It supports things like humanoid avatars and complex skeletons. It's definitely possible to have complex connected skeletons instead of two single bones like in my example.

    CO uses the system to animate their citizens and animals, also things like the bouncy castle.

    I've been working on an air dancer to show off what the mod can do (video). I had some trouble importing it into Unity because of the hack I used to change the length of the body bones (scale in one direction), but I think that's just my fault.

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    2 hours ago, boformer said:

    To be honest, I'm quite new to this so I had to google what IK handle means, and I still don't fully understand it :D

    The limit is basically what can be imported into Unity Editor 5.6.6f2 (the version used by the game). It supports things like humanoid avatars and complex skeletons. It's definitely possible to have complex connected skeletons instead of two single bones like in my example.

    CO uses the system to animate their citizens and animals, also things like the bouncy castle.

    I've been working on an air dancer to show off what the mod can do (video). I had some trouble importing it into Unity because of the hack I used to change the length of the body bones (scale in one direction), but I think that's just my fault.

     

    Yeah, most programs don't like it when a bone is scaled in only one direction. But thanks! This is really promising! Can't wait to start making my own animations!

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, nosh59 said:

    Yeah, most programs don't like it when a bone is scaled in only one direction. But thanks! This is really promising! Can't wait to start making my own animations!

    Looking forward to see what you are making :)

     

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    A little addition, might be interesting for people who like industry:

    The CargoStationAI, used for cargo harbours and cargo train stations, supports advanced animations with different states (State animation parameter):

    • 0: Idle
    • 1: Loading1- The primary vehicle (train or ship) is stopped and in loading position
    • 2: Loading2 - The primary vehicle is no longer in loading position (?)
    • 3: SecondaryLoading - A vehicle of a different type than the building (possibly a truck) is in loading position

    These parameters are used internally to control the cargo station/harbour cranes.

    • Like 3

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    The mod will be released this weekend. If you still want to make something animated, now is the time. I will link all animated buildings in the mod description ;)

     

    • Like 2

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Ronyx also made something:

     

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Update:

    * Buildings with animations now get a special workshop tag when published, so you can find them easily.
    * Added compatibility for Loading Screen Mod Test
    * Added better support for loading from pause menu
    * Better error messages for content creators

    Also, there is now a written guide made by Ronyx: http://cslmodding.info/mod/custom-animation-loader/

    And here is the source: https://github.com/boformer/CustomAnimationLoader

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Idle question more than anything; it looks like the animation starts playing when the building is built. What about when loading from a save? Would two of the same building start playing the animation at the same time and wind up being synced up? Taking Ronyx's example from above, the two animations are the same but they are not in sync because of the time they were placed. If that city was loaded from the menu would those two animations be playing in sync?

    I could see occasions where one would prefer that the animations are not synced up. If they did start playing together when a city is loaded, would it be difficult to force animations to begin at a random frame to prevent that? Minor detail, but just a thought I had.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    41 minutes ago, Ryno917 said:

    Idle question more than anything; it looks like the animation starts playing when the building is built. What about when loading from a save? Would two of the same building start playing the animation at the same time and wind up being synced up? Taking Ronyx's example from above, the two animations are the same but they are not in sync because of the time they were placed. If that city was loaded from the menu would those two animations be playing in sync?

    I could see occasions where one would prefer that the animations are not synced up. If they did start playing together when a city is loaded, would it be difficult to force animations to begin at a random frame to prevent that? Minor detail, but just a thought I had.

    They will not be in sync. Basically when animated assets come into view, their "active" or "inactive" state starts playing at a random keyframe.

    You can test this with the bouncy castle or merry-go-round ingame.

    You would need a custom building AI to make them synced.

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Cool! I spotted that you are planning to do drawbridges and similar stuff with this as well. I can't wait for it! Yesterday was released a turntable pack in the workshop and it's just begging to be animated.

    How do (or would) you approach that? Do you want to create custom DrawbridgeAI? I would love to know how to create custom service buildings but don't know how to load them in the game afterwards.

    The drawbridges, turntables etc. require overriding vehicle behavior method which cannot be done without breaking the compatibility with TMPE. Thus there needs to be some kind of native support from it. I don't know if anybody knows the guy behind the TMPE, but he seems to be inactive recently. There is a guy who took over his work and is maintaining it. (You probably know about it).

    It all can be done with some kind of virtual junctions. For that three things are needed:

    a) The ability to save and load timed traffic light (TTL) setup to/from assets. (Interchange creators would probably appreciate this as well!)

    b) Call from TMPE to the asset when TTL step changes so that the animation is triggered

    c) Ship paths with traffic light junctions

    Something like: STEP 1: Bridge is down, cars are going, STEP 2: Cars stop, call to building to draw the bridge, 3: Bridge up, 4: Bridge going down

    The users could even edit the length of the steps 1 and 3...

    There are people with definitely help with that, i have some ideas how to make point a) but I am struggling with finishing anything :D

    In any case, I am very interested in this! And I am very curious how everything is made. :)

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, Strdate said:

    How do (or would) you approach that? Do you want to create custom DrawbridgeAI? I would love to know how to create custom service buildings but don't know how to load them in the game afterwards.

    The approach that is used by current mods is to replace the AI when the asset is loaded, which is pretty straightforward because assets can still be used without the mod (you would publish your building as Unique Building or Park).

    CAL already copies the AI from one GameObject to the other. It would be a breeze to instantiate a different AI instead:

    https://github.com/boformer/CustomAnimationLoader/blob/master/CustomAnimationLoader/AssetAnimationLoader.cs#L185-L186

    In my opinion it is important that the AI replacement happens before the prefab is initialized and especially before the simulation starts. CAL uses a very early hook (where the prefab GameObjects are deserialized from the .crp file). That's required because it completely replaces the return GameObject.

    I think it would make sense to add this new bridge AI to CAL itself because it's tightly coupled to animations.

    -----

    You would need an invisible road network that spans over the bridge. For the ship path: It could either be canals or a normal ship path. Canals might be easier to handle.

    It would probably be easier if both network segments were integrated building paths (m_paths), because that makes it easier to access them from the AI.

    As you said, it would be some kind of virtual junction. You could use Building.m_flags to store the current state of the building.

    I'm not sure if timed traffic lights would be needed. Maybe just some kind of cooldown timer ("open the bridge at max every 30 seconds if there is a ship").

    The CargoStationAI might be a good resource.

    -----

    If you want to work on this, I can add you to the GitHub repo. I can help with everything animation-related, but I don't have the time to look into traffic AIs.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Thanks for the explanation. But you don't create your own custom class there, do you - you just initialize/edit existing AI classes...?

    I've already spent some time looking how traffic manager works and that is the place I would like to start with this if possible. I see a great potential for custom animations regarding the transportation everywhere - railway crossings + barriers in general, ship locks... Draw bridges sound the best. It all requires traffic logic. Thanks for the offer! For now I really don't have anything to contribute with, if it was on the agenda I can always create a pull request.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I'm wondering if this could be useful to animate textures (not sure if I'm making sense). For example a small brook or tiny river network with a seamless running water texture that flows? This way assets like those fake tiny rivers can look alive. Or even a pond with little ripples. Just a thought.

     

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, Strdate said:

    Thanks for the explanation. But you don't create your own custom class there, do you - you just initialize/edit existing AI classes...?

    You can just subclass an existing AI (BuildingAI or CommonBuildingAI if you want to start from scratch).

    The CAL mod just copies an AI component from one GameObject to the other.

    I'm currently working on a test mod to see how custom building AIs work.

    1 hour ago, Mr_Maison said:

    I'm wondering if this could be useful to animate textures (not sure if I'm making sense). For example a small brook or tiny river network with a seamless running water texture that flows? This way assets like those fake tiny rivers can look alive. Or even a pond with little ripples. Just a thought.

    You can do that with the AnimUV shader. Apparently you can use it for buildings without extra mods (just ModTools scripts in asset editor), and you can go up to 30 or 60 FPS: https://cslmodding.info/shader/animuv/

    Maybe ask @Ronyx69 for details.

    CAL is just mesh animations, though you could probably combine both.

    • Like 2

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    By TOKACHI269:

     

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    An idea I had was to use "animation" to basically swap out mesh faces in order to create illumination maps in the 0-120 RGB range that would only light up at night. I can make the animation swap the faces the way I want to when activating and deactivating the building using a park template, but I am stumped at how to proceed in making the swap happen at nightfall and daybreak.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    18 hours ago, jc21539 said:

    An idea I had was to use "animation" to basically swap out mesh faces in order to create illumination maps in the 0-120 RGB range that would only light up at night. I can make the animation swap the faces the way I want to when activating and deactivating the building using a park template, but I am stumped at how to proceed in making the swap happen at nightfall and daybreak.

    That would require a special AI (a mod). And it would probably be easier to make a mod that directly modifies the rendering code to turn off lights during the day, without animation.

    Just to confirm. When you disable a building with 0-120 illumination, the lights turn off, right?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    44 minutes ago, boformer said:

    That would require a special AI (a mod). And it would probably be easier to make a mod that directly modifies the rendering code to turn off lights during the day, without animation.

    Just to confirm. When you disable a building with 0-120 illumination, the lights turn off, right?

    Yes they do

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I also tried an air dancer before I even found this thread but I wasn't happy with the animation. Yours is similar to mine but better. I created a mesh that was a tube subdivided a bunch of times, and then added bones to each tube section, and then was posing each bone for each keyframe (the bones were connected though, so it was kind of like working my way up the tube for each keyframe) - very time consuming. I tried IK but it didn't give that folding effect that I wanted and that you also achieved. Is there an easier way than what I'm doing?

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    2 hours ago, jc21539 said:

    I also tried an air dancer before I even found this thread but I wasn't happy with the animation. Yours is similar to mine but better. I created a mesh that was a tube subdivided a bunch of times, and then added bones to each tube section, and then was posing each bone for each keyframe (the bones were connected though, so it was kind of like working my way up the tube for each keyframe) - very time consuming. I tried IK but it didn't give that folding effect that I wanted and that you also achieved. Is there an easier way than what I'm doing?

    Air dancer is super super hard. I tried to do it with less bones, using bone scaling (the bones which are scaled do not have any attached vertices).

    I placed keyframes from this video behind my model to get the movement right.

    The issue with this is that it doesn't import correctly into Unity. Everything with bone scales and fast movemets gets messed up. It has something to do with the animation curves. I later found out that it is possible to edit those curves in Unity, but that's a lot of work.

    Here are the source files (Blender 2.80): https://1drv.ms/u/s!AqhZUaWJLR1PgZljDn2u2-4BuXGrBA

     

     

    • Like 1

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections