Hi everyone, I’d like to know if there is an easy way to create with JME a circular and rectangular bar typically used in video games to create interactions with objects that require a long press of a key to complete the action or for GUI elements such as energy or loading bars.
You can also do this with pure geometry, though the math & logic to handle all the vertices will be much trickier than copying a simple built-in shader & adapting its logic to manage the ring shape.
Is there an option to use a single texture color & change the UV Map coordinates accordingly so that when the progress at it’s half then the cylinder face is half textured ?
i think about circle one(well first one too), it can be done “really easy way” in shader.
you just need have “full circle texture” and in shader drop pixels based on percentage value provided.
if you dont have shader knowledge(but i suggest try make one) then you could always try make it using custom mesh solution(see wiki).
But still, most “elegant” solution would be to use shader IMO. Then you can even make really custom things, not just circle (for example heralth like in diablo game, or custom bar shapes)
I agree with @oxplay2 that the shader would be the cleanest way. I use to have geometry based progress bars, but got rid of them when I figured out how to do it in a simple shader. I made a circle progress bar in the shader by using an alpha map that matches my progress bar texture:
and then I can smoothly change the texture in the shader for the blue part of the alpha map based on the progress percentage, while leaving the non-blue areas alone. When the progress bar fills up, I also make the red area on the border flash yellow:
But if you wanted to do something that is C- shaped like your original post’s screenshot (or anything that isn’t a simple circle that grows from the center), then you’d also need a grayscale gradient texture. Something like this to represent the percentages for each pixel in the texture:
Thank you all for your help and your ideas. As I said before, I don’t know how to use shaders yet, but I could learn. I would like to see a shader example of the techniques you proposed in the JME supported format. I’m sure many curious like me would appreciate this opportunity to find out more. @oxplay2@yaRnMcDonuts@danielp@Ali_RS
also it would require some cleanup, as it was “quick-made”
but its for you to start play with it, and try shaders yourself.
for example:
color = clamp(color, 1, 1);
this was not needed, it can be just color=vec4(1), since color was discarded anyway for other pixels.
Or you can use “darker” color, maybe it will have better effect. so just skip(remove) this line.
here is also some usefull info:
edit:
also remember, you have a good reference of ready2use JME shaders: