C
C
chikotilov2020-06-07 07:56:21
Unity
chikotilov, 2020-06-07 07:56:21

Unity, how to dynamically calculate the fullness of an object (bottle)?

Hello! I have a bottle on the stage, various details fall into it from above, but they are sometimes of a random size, to the right of the UI Slider bottle, in which I would like to implement the display of fullness, i.e. for example, 3-4 parts fell into the bottle and we show on the slider that the fullness is 4%. How can this be implemented? Please help, thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
i__egor, 2020-06-07
@chikotilov

I would let a lot of rays in the bottle, they were small (like dots), evenly over the grid (for example, 100x100x100), I would take it into account if it is inside the bottle. you will get "A" of such rays, you will find out how many of them came into contact with the details - "B", divide B / A - here are the ratios of filling the bottle with details

F
freeExec, 2020-06-07
@freeExec

Render the profile of the bottle into textures and see at what height the color of the detail will appear. Or render a depth map from a neck view, and then calibrate the system.
In general, each figure has bounds, find the top one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question