1. 程式人生 > >RealFlow線上教程翻譯(2)——Foam with SPH Fluids(基於平滑粒子流體動力學演算法(SPH)的流體泡沫)

RealFlow線上教程翻譯(2)——Foam with SPH Fluids(基於平滑粒子流體動力學演算法(SPH)的流體泡沫)

(以下英文部分及圖片皆來源於RealFlow官方文件:http://support.nextlimit.com/display/rf2014docs/Foam+with+SPH+Fluids)

注:SPH (Smoothed Particle Hydrodynamics)是平滑粒子流體動力學方法是縮寫。是指近20多年來逐步發展起來的一種無網格方法,該方法的基本思想是將連續的流體(或固體)用相互作用的質點組來描述,各個物質點上承載各種物理量,包括質量、速度等,通過求解質點組的動力學方程和跟蹤每個質點的運動軌道,求得整個系統的力學行為。

    The creation of foam and spray from particle simulations is an often-used approach. RealFlow provides two common approaches to generate this type of fluid: Python scripting and RealFlow's “Graphs” system. In this example you will learn how to create spray particles from a turbulent fluid with the “Filter” daemon.

    在粒子模擬中建立foam(泡沫)與spray(水花、浪花)是很常見的操作。RealFlow提供兩種常用的方法來生成這類流體:Python指令碼和RealFlow的 “Graphs”(影象)系統。在本例中,你將學會使用“Filter” 場(過濾場,即粒子觸發某條件後轉換其所屬發射器的場)(注:deamon在RF中一般指力場或範圍作用場)在湍流(或晃動流體)中建立浪花粒子的方法。


The result of the tutorial. The image has been rendered with RealFlow's implementation of Maxwell Render and the "MultiPoint" option to create more foam particles.

                                                                             教程結果。該影象使用RealFlow的Maxwell渲染器渲染,為實現更過泡沫的效果,使用了“MultiPoint”選項。

Here is the nodes list:

  • 1 “Cube” object
  • 1 “Square” emitter
  • 1 “Container” emitter
  • 1 “Gravity” daemon
  • 1 “k Volume” daemon
  • 1 “Surface Tension” daemon
  • 1 “Filter” daemon
教程中用到的node列表:
  • 一個“立方體”幾何體物件
  • 一個“正方形”發射器
  • 一個“容器”發射器(此處用來盛放泡沫粒子)
  • 一個“重力”場
  • 一個“體積消除”場(注:該場作用為將該場體積範圍之外(或之內)的粒子回收)
  • 一個“表面張力”場
  • 一個“過濾器”場

All scene elements can be added from RealFlow's “Edit”menu:

  • Add > Objects | Emitters | Daemons
  • RealFlow nodes can be moved, scaled, and rotated with the WR, and E keys.

  • Imported objects from SD files have to be unlocked before they can be transformed with Selected object > Node Params > Node > SD ↔ Curve

  • Viewport perspective is changed with the 123, and 4 keys.

  • Shading modes are toggled with the 789, and 0 keys.

所有場景元素可以在 “Edit”選單中新增:
  • Add > Objects | Emitters | Daemons
  • 可以通過WR, 和E鍵對node進行移動,縮放和旋轉。

  • 通過SD檔案匯入的物件在修改前需通過Selected object > Node Params > Node > SD ↔ Curve  操作解除鎖定。

  • 通過1234鍵切換視口透檢視。

  • 通過7890鍵對陰影模式進行切換。

The Setup(設定)

  • Add a cube object and rescale until you get a long basin. This node (“Cube01”) will hold the fluid.

  • 新增一個立方體物件並調整大小直到得到一個長方形容器,該容器用來盛放流體。
  • Add a “Square” emitter and place it near one end of the cube.

  • 新增一個“Square” 發射器並將其置於之前建立的立方體的一端。
  • A “Container” node will be used to store the foam particles.

  • 一個“Container” 節點用於存放泡沫粒子
  • Place a “k Volume” to delete (eventually) escaping particles.

  • 放置一個“k Volume”用於刪除(最終)逃逸粒子。
  • The “Gravity” daemon introduces a force.

  • 新增“Gravity” 場引入重力
  • With a “Surface Tension” daemon the fluid looks more “liquid”, because it amplifies the particles' tendency to form drops.

  • 新增“Surface Tension”(表面張力)場使流體看起來更像液體,因為它增強了粒子聚整合為液滴的趨勢。
  • Create a “Filter” daemon.

  • 建立“Filter” 場


Adjusting the “Square01” Emitter(調整“Square01” 發射器)

   To get a sufficient amount of randomness and turbulence, some emitter parameters are animated. For this purpose we will use two basic expressions based on sine functions. These simple formulas will help to increase and decrease the parameters' values periodically, creating a randomized look.

   為實現足夠的隨機性與波動性,修改了一些emitter引數。為實現這個目標,我們使用基於正弦函式的兩個基本方程。這些基本的公式將會幫助週期的增加與減少引數值,從而實現更加隨機的效果。

Finally, a few more adjustments are necessary(一些調整是需要的):

  • Increase the number of emitted particleswith Node Params > Particle > Resolution> 75.0
  • 通過Node Params > Particle > Resolution > 75.0增加發射器粒子數量。
  • Scale the emitter to create a rectangular shape (rough values are 0.5 and 2.0 for the horizontal values, and 1.0 for the vertical axes. Move the emitter upwards, but please make sure that it is not outside the “Cube01” object.
  • 縮放發射器尺寸來建立一個長方形(寬長比0.5,水平方向2.0,垂直方向1.0),向上移動發射器,但應保證其在“Cube01”之內
  • Instead of a constant particle stream, a fixed volume is used in this scene. Enter a value greater than 0 underNode Params > Square > Volume. Click on “Reset” to see the volume. The parameter's value should be set to value so that the particles nearly touch the “Cube01” node's bottom.
  • 本場景中使用固定體積流而不是定常粒子流。在Node Params > Square > Volume中輸入一個大於0的引數。點選“Reset”來看volume值。該引數的值應該被設定成能夠使粒子接觸“Cube01”的底部。
  • By default, the particles are emitted in a regular pattern. Add some randomness underNode Params > Square > V random (H random) > 1.0 (1.0)
  • 預設情況下,粒子按照規律模式發射。通過Node Params > Square > V random (H random) > 1.0 (1.0)增加一些是隨機性。
  • Node Params > Node > Color > choose a blue color(將顏色改為藍色


Adjusting the “Container01” Node(調節“Container01”)

    The “Container” node is not an emitter in a traditional sense. It is simply a place where particles can be added. With these particle-shifting methods you always have to make sure that the source emitter (here: “Circle01”) and the container have exactly the same “Resolution” values, because otherwise you will see exploding particles. Here are the settings:

   “Container”節點在傳統意義上不是一個發射器,只是一個可以新增粒子的地方。(注:此案例中僅將其理解為一個容器更為恰當)使用粒子轉換方法(指filter)需確保源發射器(這裡是“Circle01”)與本容器(此處指“Container01”)有相同的“Resolution”(解析度)值,否則會出現爆炸粒子。以下是具體設定:

  • Node Params > Particles > Resolution > 75.0

  • To make the foam float, change its density: Node Params > Particles > Density > 900.0

  • 為使泡沫能夠漂浮,修改其密度:Node Params > Particles > Density > 900.0
  • Node Params > Node > Color > choose white(將泡沫顏色改為白色

     The decreased “Density” will make the foam float on top of the fluid, and the colours help to separate the foam from the fluid visually.

    “Density”引數的減小將會使泡沫漂浮於流體之上,顏色的修改使我們能夠在視覺上分辨出泡沫和流體。


Adjusting the “k Volume” Daemon(調節“k Volume” 場)

    The “k Volume” daemon is just a box that can be rescaled and adjusted to enclose a certain volume. In this case, the daemon's box will be slightly smaller than the “Cube01” node. Note the “Scale” settings from “Cube01”, add 0.01 to each value, and transfer them to the “Scale” parameters of the daemon, e.g.:

    “k Volume” daemon 僅僅是一個用來封閉某個確定空間的可調節的箱體,它應比“Cube01”略微小一些。檢視“Cube01”的“Scale”引數值,在每個相應值上增加0.01,並將它們賦給“k Volume”的“Scale”值。

  • Cube01 > Scale > 6.0, 3.0, 3.0

  • k Volume01 > Scale > 6.01, 3.01, 3.01

    This tight fit is necessary, because in this scene, new foam particles will be created and they will most probably leave the cube. To delete them immediately, the “k Volume” daemon must be very close to the cube's borders.

    這些微小的修改是必要的,因為在此場景中,新的泡沫粒子會被建立並且它們很可能會離開cube容器,為了能夠立即刪除它們,“k Volume”必須非常緊密的貼合“Cube01”的邊界。

Adjusting the “Filter” Daemon(調節“Filter”場)

  • Source Emitters > Square01(設定源發射器)

  • Target Emitter (True) > Container01(設定目標發射器)

  • Condition > On Particle Collision(設定過濾條件)(注:相當於觸發條件)

  • Split > Yes(過濾後是否生成新的粒子)

  • @ # child > 3

    When a particle collides with the cube object it is transferred from “Square01” to “Container01”, and removed from the source emitter simultaneously. With the “Split” option, the filter creates 3 additional particles per filtered foam particles. This way it is possible to increase the amount of foam and get a denser look.

    粒子與立方體容器碰撞後即從“Square01”轉變為“Container01”,與此同時立即從源發射器中移除。通過 “Split”選項,filter會在最初每個filter泡沫粒子基礎上再新增3個額外粒子。該方法增加了粒子數量並使模擬結果看起來更稠密。(注:以上設定使粒子在碰撞容器壁後從Square01中轉到Container01中,即從原晃動液體轉為泡沫)


Adjusting the “Surface Tension” Daemon(調節“Surface Tension” )

    This daemon acts globally on all of the scene's emitters. This means that it will affect both the “Square01” emitter and the particles in the “Container01” node. To get nicely shaped drops and strings, use the following settings:

    該daemon作用於全域性的emitter。這意味著它會同時影響 “Square01” emitter和 “Container01” node 中的粒子。為得到形態更好的液滴和流,使用以下設定:

  • Surface_Tension01 > Node_Params > Surface Tension > Strength > 100

  • Balanced > Yes

The Simulation(模擬)

    Click on “Simulate” to see the results. Play with the “Volume” settings of the “Square” emitter to get splashes of varying strength. You can also also add a second “Filter” daemon and filter against the particles' “Pressure” value to introduce a second criteria for the creation of foam.

    點選“Simulate”觀看結果。調節“Square” emitter的“Volume”引數得到不同強度的水花。還可以新增第二個“Filter” daemon ,filter粒子的“Pressure”值以引入建立泡沫的第二準則。

    Another idea is to work with a second “Filter” and another “Container” emitter to transfer foam back into water, for example after a certain age or when a particle's speed falls below a speed threshold.

    另一個想法是使用第二個“Filter”和另一個“Container” emitter,從而使泡沫迴歸water,比如在某個時長後或當粒子的速度低於某個特定值後。