Method, device, equipment and storage medium for rendering liquid in container

By combining the control points at the rim and the control points at the liquid surface in the open container model, the problem of liquid rendering in open containers not conforming to physical laws was solved, and accurate liquid rendering effects were achieved.

CN114581590BActive Publication Date: 2026-04-10BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2022-03-11
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies are prone to rendering errors that do not conform to the laws of physics when rendering liquids in open containers.

Method used

By acquiring the liquid model, the open container model, and the liquid surface control points, the cup rim control points on the open container model are determined, and the liquid model is rendered in combination with the liquid surface control points, thus avoiding rendering errors caused by relying solely on the liquid surface control points.

Benefits of technology

This method ensures that the rendering of liquid models in open container models conforms to physical laws, avoids rendering errors, and guarantees the accuracy of liquid rendering effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114581590B_ABST
    Figure CN114581590B_ABST
Patent Text Reader

Abstract

The method, device, equipment and storage medium for rendering liquid in a container are provided. The method comprises the following steps: acquiring a liquid model, an open container model and a liquid surface control point; determining a cup opening control point on the open container model; and rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point. By using the above technical solution, the rendering of the liquid model in the open container model conforms to the physical law, and rendering errors are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of computer, and particularly, to a rendering method, device and equipment of liquid in a container and a storage medium. BACKGROUND

[0002] Currently, when using a shader to realize the rendering effect of liquid in a container, a liquid surface control point is usually used to control the height of the liquid surface, so that the part of the container higher than the liquid surface is not displayed.

[0003] In the prior art, for an open container, the rendering effect of liquid in the open container is realized by using the above method, which may cause the rendering result to be inconsistent with the physical law, for example, the rendering error generated when the open container in Figure 1 is tilted. SUMMARY

[0004] Embodiments of the present disclosure provide a rendering method, device and equipment of liquid in a container and a storage medium to realize the rendering of the liquid model in the open container model in accordance with the physical law and avoid rendering errors.

[0005] In a first aspect, embodiments of the present disclosure provide a rendering method of liquid in a container, comprising:

[0006] obtaining a liquid model, an open container model and a liquid surface control point;

[0007] determining a cup opening control point on the open container model;

[0008] rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point.

[0009] In a second aspect, embodiments of the present disclosure further provide a rendering device of liquid in a container, comprising:

[0010] an obtaining module configured to obtain a liquid model, an open container model and a liquid surface control point;

[0011] a determining module configured to determine a cup opening control point on the open container model;

[0012] a rendering module configured to render and display the liquid model in the open container model according to the liquid surface control point and the cup opening control point.

[0013] In a third aspect, embodiments of the present disclosure further provide an electronic device, comprising:

[0014] one or more processors;

[0015] a storage device configured to store one or more programs,

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the rendering method of liquid in a container as described in embodiments of the present disclosure.

[0017] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the rendering method of liquid in a container as described in embodiments of the present disclosure.

[0018] The rendering method of liquid in a container, the device, the equipment and the storage medium provided by the embodiments of the present disclosure, by acquiring a liquid model, an open container model and a liquid surface control point; determining a cup mouth control point on the open container model; according to the liquid surface control point and the cup mouth control point, rendering and displaying the liquid model in the open container model. The above technical solution can be used to realize the rendering of the liquid model in the open container model in accordance with the physical law, and avoid rendering errors. BRIEF DESCRIPTION OF DRAWINGS

[0019] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent as various embodiments of the present disclosure are disclosed in detail with reference to the drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals refer to the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.

[0020] Figure 1 is a schematic diagram of an incorrect liquid rendering result in an open container in the prior art;

[0021] Figure 2 is a flowchart of a rendering method of liquid in a container provided by the embodiments of the present disclosure;

[0022] Figure 3 is a schematic diagram of an incorrect liquid rendering result provided by the embodiments of the present disclosure;

[0023] Figure 4 is a schematic diagram of a correct liquid rendering result provided by the embodiments of the present disclosure;

[0024] Figure 5 is a schematic diagram of a liquid surface control principle provided by the embodiments of the present disclosure;

[0025] Figure 6 is a flowchart of another rendering method of liquid in a container provided by the embodiments of the present disclosure;

[0026] Figure 7 is a flowchart of volume control provided by the embodiments of the present disclosure;

[0027] Figure 8is a structural schematic diagram of a rendering device for a liquid in a container provided by an embodiment of the present disclosure.

[0028] Figure 9 is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] Embodiments of the present disclosure will be described in more detail with reference to the drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It should be understood that the drawings of the present disclosure and the embodiments are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0030] It should be understood that each step recited in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.

[0031] The term “comprising” and variations thereof as used herein are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions will be given in the description below.

[0032] It should be noted that the concepts of “first”, “second”, etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0033] It should be noted that the modification of “one”, “multiple” mentioned in the present disclosure is illustrative and not limiting, and those skilled in the art should understand that unless otherwise explicitly indicated in the context, it should be understood as “one or more”.

[0034] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.

[0035] Figure 2is a flowchart of a method for rendering liquid in a container provided by an embodiment of the present disclosure. The embodiment of the present disclosure can be applicable to the case of rendering liquid in an open container. The method can be executed by a device for rendering liquid in a container provided by an embodiment of the present disclosure. The device can be implemented in software and / or hardware, and can be integrated in an electronic device in general. The method of the embodiment of the present disclosure specifically includes:

[0036] S110, obtaining a liquid model, an open container model, and a liquid surface control point.

[0037] The liquid model and the open container model are pre-established three-dimensional models. The top of both models is open, and both the inner and outer surfaces of the models contain primitive information. A primitive is a basic unit of an image, including points, lines, surfaces, and the like in a three-dimensional model. The shape of the open container model is not fixed in this embodiment. It can be a cup shape as shown in Figure 1 , or a regular cylinder, a regular cone, or other irregular shapes. The shape of the liquid model can be consistent with the shape of the open container model that it adapts to.

[0038] The position of the liquid surface control point in the liquid model is pre-set by a user, which is used to control the height of the liquid surface of the liquid model. The liquid surface is a plane passing through the liquid surface control point and perpendicular to the direction of gravity. The liquid model is usually rendered in two parts, the liquid surface and the liquid below the liquid surface, to create the effect of a water surface.

[0039] S120, determining a cup mouth control point on the open container model.

[0040] In this embodiment, since the container holding the liquid is an open container, if only the liquid surface control point is used to control the height of the liquid surface of the liquid model in the open container model, in some cases, for example, when the open container model is tilted, it may cause the liquid rendering result to be inconsistent with the physical law, such as the liquid rendering effect shown by the dashed line in Figure 3 . This is because only the information of the liquid model itself (the liquid surface control point) and the global information (the direction of gravity) are considered, but the environmental information (the open container holding the liquid) is not considered. Therefore, another cup mouth control point needs to be determined on the open container model to determine the liquid surface of the liquid model together with the liquid surface control point, to avoid the case of incorrect liquid rendering.

[0041] Optionally, determining the cup mouth control point on the open container model can include: selecting the lowest point on the cup mouth of the open container model as the cup mouth control point according to the tilt angle of the open container model.

[0042] In this embodiment, since the liquid in the open container will inevitably flow in the tilting direction when the open container model is tilted, eventually flowing out from the rim of the container, the lowest point of the rim in the tilting direction can be used as the second control point, namely the rim control point, to assist the liquid surface control point in determining the liquid surface. This ensures that the rendered liquid surface of the liquid model will not be higher than the lowest point on the rim, guaranteeing that the liquid rendering effect conforms to physical laws. In the local coordinate system of the open container model, the tilt angle of the open container model can be understood as the angle between the vector from the origin to the rim control point and a specified coordinate axis on the rim plane, where the tilting direction of the container is consistent with the direction of this vector.

[0043] The local coordinate system refers to a coordinate system that remains unchanged relative to the open container model. When the open container model moves or rotates, the local coordinate system will also move or rotate accordingly. For example, to facilitate the calculation of the coordinates of the control points at the rim of the cup, the local coordinate system of the open container model is established with the center of the rim as the origin, the normal direction of the rim plane as the y-axis, and two mutually perpendicular directions on the rim plane as the x-axis and z-axis.

[0044] S130. Render and display the liquid model in the open container model according to the liquid level control point and the cup opening control point.

[0045] In this embodiment, to avoid Figure 3 The rendered liquid model has a cross-section at the sloping rim of the container. The liquid level is determined using both rim control points and surface control points. A discard operation, which removes unwanted primitive fragments, is used to display only the portion of the liquid model below the surface—that is, the portion below both the rim and surface control points. The remaining liquid model portions are not displayed, resulting in the following image. Figure 4 The correct liquid rendering result is shown.

[0046] Optionally, rendering and displaying the liquid model in the open container model based on the liquid surface control point and the cup rim control point may include: taking the lowest point among the liquid surface control point and the cup rim control point as the target control point in the world coordinate system; and rendering and displaying the liquid model in the open container model based on the target control point and the direction of gravity.

[0047] In this context, three-dimensional space has a world coordinate system, in which all objects can move and rotate. The world coordinate system is the same for all objects in the space and does not change.

[0048] In the embodiment, since the local coordinate systems of the liquid model and the open container model are independent of each other, in order to ensure that only the part of the liquid model under both the cup control point and the liquid control point can be displayed, the position coordinates of the liquid control point and the cup control point in the local coordinate system are converted into position coordinates in the world coordinate system, and the positions of the two are compared, and the lowest position is selected as the target control point, that is, the final liquid control point. Further, the plane in the liquid model passing through the target control point and perpendicular to the direction of gravity is taken as the liquid surface of the liquid, and the part of the liquid model under the liquid surface is displayed, and the remaining part of the liquid model is discarded.

[0049] As shown in Figure 4 , in the case of a stationary container, since the cup control point is lower than the liquid control point in the world coordinate system, the liquid in the container will eventually flow out from the cup control point until the liquid surface corresponding to the liquid control point drops to the liquid surface corresponding to the cup control point. Since the liquid model to be rendered is the liquid model after the liquid stops flowing out, by taking the lower cup control point as the target control point to determine the liquid surface, it can be ensured that only the part of the liquid model under both the cup control point and the liquid control point can be displayed.

[0050] Optionally, rendering and displaying the liquid model in the open container model according to the target control point and the direction of gravity can include: calculating a first vector from the target control point to the vertex of each pixel point in the liquid model; calculating a dot product between the first vector and the direction of gravity; displaying the pixel point in the liquid model corresponding to the dot product greater than 0.

[0051] In the embodiment, when calculating the displayable part of the liquid model according to the target control point, since the target control point is inside the liquid model and the direction of gravity is always perpendicular to the liquid surface downward, the angle between the vertex of the pixel point in the liquid surface and the direction of gravity is equal to 90 degrees, so the angle between the vertex of each pixel point of the part of the liquid model under the liquid surface and the direction of gravity is less than 90 degrees.

[0052] As an example, taking the open container model as an example without inclination, as shown in Figure 5 , the target control point can be taken as the origin, and the direction of gravity of the model is defined as perpendicular downward, that is, the normal direction of the liquid surface is downward, denoted as The vector from the target control point to the vertex of each pixel point of the liquid model is denoted as Then, for When , the vector corresponding to the pixel point is under the liquid surface and can be displayed, and when , the vector The corresponding pixel point is located in the liquid surface or above the liquid surface and cannot be displayed.

[0053] The method for rendering liquid in a container provided by the embodiments of the present disclosure includes the following steps: obtaining a liquid model, an open container model and a liquid surface control point; determining a cup opening control point on the open container model; and rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point. By using the above technical solution, the embodiments can render the liquid model in the open container model in accordance with physical laws and avoid rendering errors.

[0054] Figure 6 is a flowchart of another method for rendering liquid in a container provided by the embodiments of the present disclosure. The solution in the embodiments can be combined with one or more optional solutions in the above embodiments. The embodiments provide specific steps of selecting the lowest point on the cup opening of the open container model as the cup opening control point, specific steps of rendering and displaying the liquid flowing out of the cup opening, and specific steps of updating the liquid surface control point according to the volume of the liquid model displayed in the open container model. Accordingly, as shown in Figure 6 the method for rendering liquid in a container provided by the embodiments can include the following steps:

[0055] S210, obtaining a liquid model, an open container model and a liquid surface control point.

[0056] S220, selecting the lowest point on the cup opening of the open container model as the cup opening control point according to the inclination angle of the open container model.

[0057] In the embodiments, since the open container model is used, when only the information and global information of the liquid model are considered and the environmental information is not considered, the liquid in the container cannot be correctly rendered in accordance with the physical laws. In order to add the environmental information, a cup opening control point is determined on the open container model according to the inclination angle of the open container model, so as to use the cup opening control point and the liquid surface control point to jointly determine the liquid surface of the liquid model, thereby avoiding the error of the liquid rendering.

[0058] Optionally, selecting the lowest point on the cup opening of the open container model as the cup opening control point can include: in the local coordinate system of the open container model, selecting the point with the maximum projection of the vector from the coordinate origin to the point of the cup opening on the gravity vector as the cup opening control point.

[0059] In the embodiment, since the local coordinate system of the open container is relatively unchanged with the open container model, the coordinates of each point on the cup mouth of the open container model in the local coordinate system are fixed and unchanged, and thus the lowest point on the cup mouth cannot be directly determined according to the local coordinate values of the points on the cup mouth when the open container model is tilted. On the other hand, since there are many points on the cup mouth, if the lowest point on the cup mouth is determined by comparing the z-axis values of each point on the cup mouth in the world coordinate system, each point needs to be mapped from the local coordinate to the world coordinate, and then the z-axis coordinate values are compared, which results in a large amount of calculation and a long time consumption in the calculation process of the cup control point. Considering that in the local coordinate system, the direction of gravity is always vertically downward regardless of the tilt of the open container model, and the projection of the vector from the coordinate origin to the lowest point on the cup mouth on the gravity vector is the largest, in order to reduce the amount of calculation and shorten the time consumption in the calculation process of the cup control point, the problem of solving the local coordinate of the cup control point can be converted into solving a point A on the cup mouth of the open container model, and the projection of the point A on the gravity vector is the largest.

[0060] The projection of one vector a on another vector b is a quantity, which is positive when the angle φ between the two vectors is acute, negative when the angle φ between the two vectors is obtuse, and 0 when the angle φ between the two vectors is a right angle.

[0061] Taking the cup mouth of the open container model as a circular shape with a radius r as an example, in order to facilitate calculation, the local coordinate system of the open container model is established with the center of the cup mouth as the coordinate origin, the normal direction of the cup mouth plane as the y-axis, and two directions perpendicular to each other on the cup mouth plane as the x-axis and the z-axis, and thus the local coordinate of the point A can be expressed as: A=(rcosθ, 0, rsinθ), and in the homogeneous space θ is the angle between the x-axis and the z-axis, and the gravity vector is Then the point that satisfies the maximum value of is the cup control point.

[0062] Let the point A in the world coordinate system be A', and the transformation matrix from the local coordinate system to the world coordinate system be M w Then: Then

[0063] Then,

[0064]

[0065] Let Then f(x)=rcosθ*P+rsinθ*Q, ​

[0066] Take the derivative of f(x), and get f'(x) = -r sinθ*P + r cosθ*Q, let f'(x) = 0, and find the extreme value of f(x) under θ, then:

[0067] Finally, we can get Since there are two θs that satisfy the condition, we can substitute θ into the coordinates of point A' in the world coordinate system, and select the point with a lower z-axis value as the cup control point.

[0068] It should be noted that for other cup shapes, as long as their parametric equations can be expressed, the cup control point can be calculated according to the above method, and the method has good generalization and low calculation cost.

[0069] S230, according to the liquid control point and the cup control point, rendering and displaying the liquid model in the open container model.

[0070] In this embodiment, the lowest point in the liquid control point and the cup control point is selected as the target control point, and then the plane in the liquid model that passes through the target control point and is perpendicular to the gravity direction is taken as the liquid surface, or the dot product between the vector from the target control point to each vertex of the liquid model and the gravity vector is calculated to determine the final liquid surface. The part of the liquid model below the liquid surface is displayed, and the remaining part of the liquid model is discarded, and only the part of the liquid model that is below both the liquid control point and the cup control point can be displayed.

[0071] Optionally, after rendering and displaying the liquid model in the open container model according to the liquid control point and the cup control point, it further includes: in the world coordinate system, calculating the position coordinates of the liquid after flowing out of the cup according to the position coordinates of the cup control point, and rendering and displaying the liquid flowing out of the cup.

[0072] In this embodiment, since the flow-out position of the liquid from the cup can be determined according to the cup control point, the liquid flow-out effect can be added to the cup, such as a water flow vertically flowing down from the cup control point. In order to facilitate obtaining the position coordinates of the liquid after flowing out of the open container, the position coordinates of the liquid falling down can be determined by sequentially reducing the coordinate values of the cup control point in the gravity direction in the world coordinate system, and the liquid flowing out of the cup is rendered and displayed.

[0073] Optionally, after rendering and displaying the liquid model in the open container model according to the liquid level control point and the cup control point, the method further comprises: calculating the current volume of the liquid model displayed in the open container model according to the liquid level control point and the cup control point; and updating the position of the liquid level control point through negative feedback adjustment according to the difference between the current volume and the volume before the rendering.

[0074] In this embodiment, in order to display the change of the liquid model in the open container model over time, the liquid level control point can be updated according to the inclination angle of the open container model and the volume of the displayed liquid model. As shown in Figure 7 After initializing the liquid level control point and the liquid volume and calculating the cup control point according to the inclination angle of the container, the current volume of the liquid model that can be displayed in the container model is calculated according to the variables required by the volume calculation formula obtained according to the liquid level control point and the cup control point. The volume calculation formula can be obtained according to the shape of the container. Then, the current volume is compared with the volume calculated last time, and the position of the liquid level control point is updated through negative feedback adjustment according to the difference between the two volumes.

[0075] The rendering method for liquid in a container provided by the embodiments of the present disclosure can effectively avoid rendering errors of the liquid model in the container model when the open container model is inclined, and make the liquid rendering effect serve the physical law, by obtaining a liquid model, an open container model, and a liquid level control point; selecting the lowest point on the cup of the open container model as a cup control point according to the inclination angle of the open container model; and displaying the part of the liquid model that is below both the liquid level control point and the cup control point.

[0076] Figure 8 FIG. 1 is a structural schematic diagram of a rendering device for liquid in a container provided by an embodiment of the present disclosure. The device can be realized in the form of software and / or hardware, and can be generally integrated in an electronic device. As shown in Figure 8 The rendering device for liquid in a container provided by the embodiments of the present disclosure can comprise an obtaining module 810, a determining module 820, and a rendering module 830, wherein,

[0077] The obtaining module 810 is configured to obtain a liquid model, an open container model, and a liquid level control point.

[0078] The determining module 820 is configured to determine a cup control point on the open container model.

[0079] The rendering module 830 is configured to render and display the liquid model in the open container model according to the liquid level control point and the cup control point.

[0080] The container liquid rendering device provided by the embodiment of the present disclosure comprises the following steps: obtaining a liquid model, an open container model and a liquid surface control point; determining a cup opening control point on the open container model; and rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point. By using the technical scheme, the rendering of the liquid model in the open container model conforms to the physical law, and rendering errors can be avoided.

[0081] In the above scheme, the determining module 820 can be configured to select a lowest point on the cup opening of the open container model as the cup opening control point according to the inclination angle of the open container model.

[0082] In the above scheme, the determining module 820 can be configured to select a point with the maximum projection of a vector from the coordinate origin to the point on the cup opening on the gravity vector as the cup opening control point from the points on the cup opening of the open container model in the local coordinate system of the open container model.

[0083] In the above scheme, the rendering module 830 can comprise a selecting unit configured to select a lowest point in the cup opening control point and the liquid surface control point as a target control point in the world coordinate system; and a display unit configured to render and display the liquid model in the open container model according to the target control point and the gravity direction.

[0084] In the above scheme, the display unit can be configured to calculate a first vector from the target control point to a vertex of each pixel point in the liquid model; calculate a dot product between the first vector and the gravity direction; and display the pixel point in the liquid model corresponding to the dot product greater than 0.

[0085] Further, the container liquid rendering device provided by the embodiment can further comprise a second rendering module configured to calculate the position coordinates of the liquid after flowing out of the cup opening according to the position coordinates of the cup opening control point in the world coordinate system after rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point, and render and display the liquid flowing out of the cup opening.

[0086] Further, the container liquid rendering device provided by the embodiment can further comprise a liquid surface control point updating module configured to calculate the current volume of the liquid model displayed in the open container model according to the liquid surface control point and the cup opening control point after rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup opening control point; and update the position of the liquid surface control point by negative feedback adjustment according to the difference between the current volume and the volume before the rendering.

[0087] The container liquid rendering apparatus provided by the embodiments of the present disclosure can execute the container liquid rendering method provided by any of the embodiments of the present disclosure, and has the corresponding function modules and advantages of executing the container liquid rendering method. Technical details not described in the embodiments can be found in the container liquid rendering method provided by any of the embodiments of the present disclosure.

[0088] Reference is made below to Figure 9 which shows a structural diagram of an electronic device (e.g., a terminal device or a server) 600 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. Figure 9 The electronic device shown is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.

[0089] As shown in Figure 9 , the electronic device 600 can include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage device 606. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0090] Generally, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage device 606 including, for example, a magnetic tape, a hard disk, and the like; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 9 The electronic device 600 is shown with various devices, but it should be understood that all of the shown devices are not required to be implemented or possessed. More or fewer devices can be alternatively implemented or possessed.

[0091] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication device 609, or installed from the storage device 606, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of embodiments of the present disclosure are performed.

[0092] It should be noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is carried. Such a propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that can be used to carry or store program code for use by or in connection with an instruction execution system, apparatus, or device. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to wire, cable, RF (radio frequency), or any suitable combination thereof.

[0093] In some embodiments, the client, server, or other computing machines utilized by the system can communicate over any known or future developed network protocol, such as the HyperText Transfer Protocol (HTTP), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current or future developed network.

[0094] The computer-readable medium described above can be included in the electronic device described above; alternatively, the computer-readable medium can exist as a standalone entity.

[0095] The computer-readable medium described above carries one or more programs that, when executed by the electronic device, cause the electronic device to acquire a liquid model, an open container model, and a liquid surface control point; determine a cup opening control point on the open container model; and render and display the liquid model in the open container model according to the liquid surface control point and the cup opening control point.

[0096] Computer program code for carrying out operations of the present disclosure can be written in any one or more of a number of programming languages or combinations of languages including an object-oriented programming language such as Java, Smalltalk, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network ("LAN") or a wide area network ("WAN"), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0097] The computer program product of the first aspect can include one or more non-transitory computer-readable media storing instructions to configure a processor to perform the steps of the method of the first aspect. The computer program product of the first aspect can include a computer-readable medium storing instructions to configure a processor to perform the steps of the method of the first aspect.

[0098] The modules or units related in the embodiments of the present disclosure can be implemented by software, or by hardware, or by a combination of software and hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.

[0099] The functions described in this description above can be implemented in part or in whole in hardware, firmware, software, or any combination thereof. For example, one or more application specific integrated circuits (ASICs) can be programmed to perform selected tasks in hardware, while one or more processors can be programmed to perform selected tasks in software. In some embodiments, the functions described in this description above can be implemented in a combination of hardware, firmware, and / or software.

[0100] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium can include a tangible, non-transitory memory, such as a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0101] According to one or more embodiments of the present disclosure, example 1 provides a method for rendering a liquid in a container, comprising:

[0102] acquire a liquid model, an open container model and a liquid surface control point;

[0103] determine a cup control point on the open container model;

[0104] render and display the liquid model in the open container model according to the liquid surface control point and the cup control point.

[0105] According to one or more embodiments of the present disclosure, in example 2, the method according to example 1, the determination of the cup control point on the open container model comprises:

[0106] selecting a lowest position point on the cup of the open container model as the cup control point according to the tilt angle of the open container model.

[0107] According to one or more embodiments of the present disclosure, in example 3, the method according to example 2, the selection of the lowest position point on the cup of the open container model as the cup control point comprises:

[0108] selecting a point with the maximum projection of the vector from the coordinate origin to the point on the cup on the gravity vector as the cup control point from the points on the cup of the open container model in the local coordinate system of the open container model.

[0109] According to one or more embodiments of the present disclosure, in example 4, the method according to example 1, the rendering and display of the liquid model in the open container model according to the liquid surface control point and the cup control point comprises:

[0110] selecting the lowest position point in the liquid surface control point and the cup control point as a target control point in the world coordinate system;

[0111] rendering and displaying the liquid model in the open container model according to the target control point and the gravity direction.

[0112] According to one or more embodiments of the present disclosure, in example 5, the method according to example 4, the rendering and display of the liquid model in the open container model according to the target control point and the gravity direction comprises:

[0113] calculating a first vector from the target control point to the vertex of each pixel point in the liquid model;

[0114] calculating the dot product between the first vector and the gravity direction;

[0115] displaying the pixel point in the liquid model corresponding to the dot product greater than 0.

[0116] According to one or more embodiments of the present disclosure, example 6 provides the method of any one of examples 1-5, after rendering and displaying the liquid model in the open container model according to the liquid control point and the spout control point, further comprising:

[0117] calculating, in the world coordinate system, the position coordinates of the liquid after flowing out of the spout according to the position coordinates of the spout control point, and rendering and displaying the liquid flowing out of the spout.

[0118] According to one or more embodiments of the present disclosure, example 7 provides the method of example 1, after rendering and displaying the liquid model in the open container model according to the liquid control point and the spout control point, further comprising:

[0119] calculating the current volume of the liquid model displayed in the open container model according to the liquid control point and the spout control point;

[0120] performing negative feedback adjustment according to the difference between the current volume of the liquid model and the volume before this rendering, and updating the position of the liquid control point.

[0121] According to one or more embodiments of the present disclosure, example 8 provides a device for rendering liquid in a container, comprising:

[0122] an obtaining module configured to obtain a liquid model, an open container model, and a liquid control point;

[0123] a determining module configured to determine a spout control point on the open container model;

[0124] a rendering module configured to render and display the liquid model in the open container model according to the liquid control point and the spout control point.

[0125] According to one or more embodiments of the present disclosure, example 9 provides an electronic device, comprising:

[0126] one or more processors;

[0127] a storage device configured to store one or more programs,

[0128] when the one or more programs are executed by the one or more processors, the one or more processors implement the method for rendering liquid in a container as described in any one of examples 1-7.

[0129] According to one or more embodiments of the present disclosure, example 10 provides a computer-readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the method for rendering liquid in a container as described in any one of examples 1-7.

[0130] The above description is only preferred embodiments of the present disclosure and a description of the principles of the technology applied. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by the combinations of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the technical solutions formed by the mutual replacement of the above features and the technical features with similar functions disclosed in the present disclosure (but not limited to) can be formed.

[0131] Further, while operations are depicted in a particular order, this should not be understood as requiring such order nor the order that is illustrated. Rather, multi-tasking and parallel processing can be advantageous in certain circumstances. Likewise, while a number of specific implementation details have been included in the above discussion, these should not be construed as limiting the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable sub-combination.

[0132] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims

1. A method of rendering a liquid in a container, characterized in that, The method comprises the following steps: acquiring a liquid model, an open container model and a liquid surface control point; selecting a lowest position point on a cup mouth of the open container model as a cup mouth control point according to an inclination angle of the open container model; rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup mouth control point; the step of selecting the lowest position point on the cup mouth of the open container model as the cup mouth control point comprises the following steps: in a local coordinate system of the open container model, selecting a point with the maximum projection of a vector from an origin point to the point on the cup mouth on a gravity vector as the cup mouth control point; the local coordinate system is a coordinate system that remains unchanged relative to the open container model; the step of rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup mouth control point comprises the following steps: in a world coordinate system, taking the lowest position point in the liquid surface control point and the cup mouth control point as a target control point; taking a plane in the liquid model that passes through the target control point and is perpendicular to the gravity direction as a liquid surface, and displaying the liquid model below the liquid surface; after the step of rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup mouth control point, the method further comprises the following steps: obtaining variables required by a volume calculation formula according to the liquid surface control point and the cup mouth control point, and calculating a current volume of the liquid model displayed in the open container model; performing negative feedback adjustment according to a difference between the current volume of the liquid model and a volume before this rendering, and updating a position of the liquid surface control point; wherein the volume calculation formula is obtained approximately according to a shape of the open container model.

2. The method of claim 1, wherein, after the step of rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup mouth control point, the method further comprises the following steps: in the world coordinate system, calculating position coordinates of the liquid after the liquid flows out of the cup mouth according to the position coordinates of the cup mouth control point, and rendering and displaying the liquid flowing out of the cup mouth.

3. An apparatus for rendering a liquid in a container, characterized in that The method comprises the following steps: an acquiring module is configured to acquire a liquid model, an open container model and a liquid surface control point; a determining module is configured to select a lowest position point on a cup mouth of the open container model as a cup mouth control point according to an inclination angle of the open container model; a rendering module is configured to render and display the liquid model in the open container model according to the liquid surface control point and the cup mouth control point; the determining module is further configured to select a point with the maximum projection of a vector from an origin point to the point on the cup mouth on a gravity vector as the cup mouth control point in a local coordinate system of the open container model; the local coordinate system is a coordinate system that remains unchanged relative to the open container model; the rendering module comprises the following steps: a selecting unit is configured to take the lowest position point in the liquid surface control point and the cup mouth control point as a target control point in a world coordinate system; a taking unit is configured to take a plane in the liquid model that passes through the target control point and is perpendicular to the gravity direction as a liquid surface, and display the liquid model below the liquid surface; The display unit displays a plane passing through the target control point and perpendicular to the direction of gravity as a liquid surface in the liquid model, and displays the liquid model below the liquid surface; The liquid surface control point updating module, after rendering and displaying the liquid model in the open container model according to the liquid surface control point and the cup control point, obtains variables required by a volume calculation formula according to the liquid surface control point and the cup control point, calculates the current volume of the liquid model displayed in the open container model, and updates the position of the liquid surface control point through negative feedback adjustment according to the difference between the current volume and the volume before this rendering; the volume calculation formula is approximately obtained according to the shape of the open container model.

4. An electronic device, comprising: The electronic device includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the rendering method of the liquid in the container as claimed in any one of claims 1-2.

5. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the rendering method of the liquid in the container as claimed in any one of claims 1-2.

Citation Information

Patent Citations

  • Method and device for simulation display of liquid in container

    CN104423850A