Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
mark_doberenz
Advisor
Advisor
0 Kudos

I've had a few people ask whether it's possible to show a fill level in a tank and a recent request made me want to put a formal example together in case it would help anyone else out.

This method uses a texture image and an animated UV layout to get the desired effect. There may be other ways to do this, but this one's the best/only option I know about.

IMPORTANT FILE ATTACHMENT NOTE:

Download the attachment which is a zip file. Inside it, there is a capsule_files.txt file. This file is actually a zip file, so extract it and rename it to capsule_files.zip and unzip it so you will have the files referenced below. Sorry for the weird attachment, but it's the only way I could attach more than three files this post.

  1. Start of by creating an empty scene using the File -> New menu option.
  2. Then, Create -> Create Primitive -> Capsule
    1. The Primitive objects are a nice way to build up an object from more basic objects, but we will just use the capsule for this example.
  3. Modify the properties of the Capsule by double-clicking on it
  4. Select the Object tab in the Properties window that appears
  5. Change the following values using the up/down arrows at the end of their respective line
    1. Slices: 24
    2. Stacks: 15
  6. Leave the Properties window open
  7. Make sure the capsule is selected and right-click on it and press Tools -> Convert to Polygon Mesh
    1. This will allow us to create a different UV layout which is required for the effect to work
    2. Notice in the Properties window, the information for the object changes because we removed all the Primitive information. It's now a dumb mesh object.
  8. Press Close to close the Properties window
  9. Press the F key to switch to the Front view
    1. Download the 01_capsule_mesh.rh file to start from this point
  10. Turn on the Decal Mapping toolbar
  11. Press the Settings button on the Decal Mapping toolbar (the last icon that looks like a Play button)
  12. Uncheck the Apply to Visible Mesh Faces Only
    1. This is so that the texture will get applied to the back of the capsule also
  13. Press the OK button to close the Settings window
  14. Download the capsule.png image
  15. Press the Load Texture Image button on the Decal Mapping toolbar (the first icon)
  16. Select the capsule.png image you just downloaded
  17. Resize the image using the handles and use the middle-mouse wheel to zoom in on the capsule so that the capsule sits entirely inside the light-blue area as closely as possible.
  18. Once it's lined up, press the Stamp Decal button (the second icon)
    1. The capsule should now be the nice light-blue color
    2. Download the 02_capsule_mapped.rh file to start from this point
  19. While holding down the SHIFT key on the keyboard, double-click on the capsule to open its Material Properties window
  20. Select the Maps tab of the Material Properties window
  21. To test our map, change the Offset V value on the right-hand side to -0.5 and you will see it turn dark-blue
    1. What we want to do now is set up an Animation which controls the Offset V value so we can animate the fill level
  22. Set the Offset V value back to 0
  23. Turn on the Animation and Animation Controls Panels
  24. Create a new Sequence using the Create Sequence button of the Animation panel (the first icon that looks like a movie frame)
  25. Right-click on the new Sequence-1 sequence and select Properties
  26. Rename the Sequence to be Capsule
  27. Change the FPS value to 100 which will also change the End value to 100
    1. This is so that we will have a smooth transition between values of 0 and 100
    2. This may seem strange since normal animation FPS values are 30. However, we are using 0-100 to make it easier to set the value from a web page using the API. See the capsule.html file for an example of this.
    3. Imagine getting a fill level from an external system between 0 and 100. Since the animation length is 100 frames, just set the frame value to the value received from the external system and you're done.
  28. Press OK to close the Sequence Properties window
  29. Hold down the SHIFT key and on the Animation Controls Panel, press the Record Keyframes (the red icon with a key on it)
    1. This will turn the Animation slider Red and move the slider to the last frame (100)
  30. Using the Material Properties window, change the Offset V value to -0.5
  31. Press the Record Keyframes button again to turn it off
  32. Press the Close button on the Material Properties window to close it.
  33. Now, drag the animation slider back and forth to fill and unfill the capsule.
    1. Download the 03_capsule_animated.rh file to see the final product
  34. The final thing would be to create an HTML app to demonstrate it. Run the capsule.html file to see an example.
    1. The capsule.html file also shows how to access the animations of a scene and to change their CurrentTime value
10 Comments