RealFlow在线教程翻译(5)——Shattered Glass (破碎的玻璃杯)

(以下英文部分及图片皆来源于RealFlow官方文档:http://support.nextlimit.com/display/rf2014docs/Your+First+Project)


    One of the most famous RealFlow scenes is a shattering glass after being hit by a bullet. The idea behind this setup is very interesting, because it is a combination of fluids, rigid bodies, and slow motion effects. In this tutorial you will learn how to recreate this simulation with RealFlow's built-in tools. Please note that this simulation is split into two parts: in the first simulation a resting and calm fluid is created. Then, the interaction between the fluid and the smashing glass is done in a separate action.

     RF的一个著名场景是玻璃杯被子弹击中破碎。相关设置背后的想法非常有趣,因为该场景是流体、刚体与慢运动效果的组合。在本教程中,你将学到如何使用RF的内置工具来创建该仿真。请注意该仿真被分成两个部分:首先创建一个静止的fliud,然后单独创建该fliud与打碎的玻璃杯的相互作用。

The result of the workshop rendered with Maxwell Render.

使用Maxwell渲染的结果

 

Here is the nodes list for the first part – the relaxed fluid:(第一部分的节点列表 — 静止液体:)

  • 1 glass object(玻璃杯对象)

  • 1 “Gravity” daemon(重力场)

  • 1 “k Volume” daemon(体积控制场)

  • 1 “k Speed” daemon(速度控制场)

  • 1 “Drag Force” daemon(阻力场)

 

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 W, R, 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 1, 2, 3, and 4 keys.

  • Shading modes are toggled with the 7, 8, 9, and 0 keys.

The Setup – Glass Filling(设置—填充玻璃杯)

    For this scene, the milk glass from the “Wetmap Creation” quick start tutorial is used. Please bear in mind that this tutorial is based on RealFlow's standard scale, and therefore the objects might appear rather big. The very first task is to fill the glass with milk:

    本场景使用Wetmap Creation快速使用指南中的牛奶杯。请注意该指南基于RF的基准尺寸,所以对象看起来可能很大。首要任务是先将杯子填满。

  • Import the glass with the Ctrl/Cmd + I command.

  • 使用Ctrl/Cmd + I导入杯子
  • If you want to reposition it unlock it under Node Params > Node > SD ↔ Curve.

  • 如果想移动它,在Node Params > Node > SD ↔ Curve 下解除锁定
  • With the M key the object can be moved.

  • 使用M键移动对象
  • Add “Circle” emitter from Edit > Add > Particle Emitter and place it inside the glass. It can be moved with the M key as well. If you have to rescale the emitter use the R key.

  • 添加Circle发射器,并将其置于杯子内。同样可以使用M键移动,使用R键缩放。
  • To get more particles, the emitter's “Resolution” value has to be increased under Node Params > Particles. The value depends on the size of the glass object and the scene's scale. For the fluid in the rendered image, a value of 30 has been used.

  • 为增加粒子数量,在Node Params > Particles下调整增加发射器的 Resolution 值。该值取决于杯子尺寸与场景尺寸。在上面的渲染图中该值为30。
  • Other settings are: Int Pressure = 0.5, Viscosity = 4.0, Surface Tension = 10

  • 其他设置为:Int Pressure = 0.5, Viscosity = 4.0, Surface Tension = 10
  • Under “Circle”, set “V/H random” to 1.0 each.

  • 将Circle子菜单中的V/H random值设为1.0

 

 

A very important thing to check is the glass object's “Liquid - Particle Interaction” panel:

一件非常重要的事是查看杯子对象的Liquid - Particle Interaction面板:

  • Change “Collision distance” to 0.01. This will bring the fluid particles closer to the object's surface.

  • 将Collision distance(碰撞距离)值设为0.01。这将使液体粒子更接近杯子对象表面。

 

Finally, some daemons are necessary:

  • Edit > Add > Daemons > Gravity | k Volume

  • k_Volume01 > Node Params > k Volume > Fit to object > select glass node

 

Now, the scene can be simulated:

现在可以对场景进行仿真了:

  • Click on the small lock icon to left of the timeline. With this action, RealFlow neither counts frames (no matter how long you simulate, the timeline slider will remain at 0), nor writes out any files. This mode is perfectly suited to fill the glass.

  • 点击时间轴左侧的小锁图标。该操作使RF不计算帧数(无论仿真运行多长时间,时间轴都停留在第0帧处),也不写入任何文件。该模式特别适合用来填充杯子。
  • Simulate.

 

 

If you think that the glass is properly filled (between one half and two thirds) stop the emission of particles:

如果觉得杯子填充得差不多了(在1/2至2/3之间)停止粒子发射:

  • Stop the simulation with another click on “Simulate”.

  • 再次单击Simulate停止仿真。
  • Highlight the “Circle01” and go to Node Params > Particles > Max Particles.

  • 高亮Circle01,转到Node Params > Particles > Max Particles
  • Also open the “Statistics” panel and look for “Existent Particles”.

  • 打开Statistics(统计)面板,寻找Existent Particles(现存粒子)
  • Let's say the value there is around 110,000. Under “Max particles” you enter 125,000 (or any other value greater than 110,000), and resume the simulation.

  • 这里现存粒子数(Existent Particles)大约是110000,少于最大粒子数(Max particles)125000,仿真继续。
  • The emission will stop automatically when the “Max Particles” limit has been reached.

  • 当Max Particles(最大粒子数)限制达到时粒子发射将自动停止
  • Let the simulation run for a few more minutes.

  • 让仿真再运行几分钟。

 

Relaxing the Fluid(使液体静止)

In the next step you create a calm fluid surface:

下一步创建静止液体表面:

  • Unlock the simulation with another click on the lock icon.
  • 再次点击lock图标解锁,继续仿真
  • If the emitter is not selected, click on it again.
  • 如果没有选择发射器,再次点击它
  • Node Params > Initial State > Use Initial State > Yes(使用初始状态)
  • Make Initial State
  • 创建初始状态




  • Click on the small triangle next to the “Reset” button and enable “Reset To Initial State”.(重置到初始状态)
  • Reset(重置)

 

 

For the relaxation process, two more nodes are required:

静止过程需要另外两个(关键控制帧)节点:

  • Add a “k Speed” daemon.(添加速度控制场)

  • Node Params > k Speed > Limit & Keep > Yes(限制速度)

  • Max speed > 1.0

  • Max speed > right-click > Add key(添加关键帧)

  • Shift the timeline slider to frame 200 (the fluid disappears).(将时间轴调至200帧)

  • Max speed > 0.01

  • Max speed > right-click > Add key(添加关键帧)

  • Reset (the fluid reappears).(重置,液体重现)

  • Add a “Drag Force” daemon.(添加阻力场)

  • Under Drag Force > Drag Strength create two keys with values of 0 (f = 0) and 75 (f = 200).(在第0帧与第200帧处分别设置阻力强度为0与75,作为关键控制帧)

  • Simulate. At frame 200 the fluid should be calm and relaxed.(开始仿真,200帧处液体应静止)

  • Create a new initial state for your final simulation as described above.(按上述操作,为最终仿真创建一个新的初始状态)

  • Reset.(重置)

 

The fluid's relaxed state.

液体静止状态

The Setup – Glass Shattering(杯子参数设置)

  • Remove the “k Speed” and “Drag Force” daemons.(移除速度控制场与阻力场)

  • Click on the small triangle next to the “Simulate” button and open “Options...”.(点击Simulate旁的小三角打开设置)

  • Under General > FPS Output enter 72, 75, or 90 (according to your film/TV system).(根据系统实际情况,设置每秒输出帧数)

  • Add a “Sphere” node – this object will serve as a bullet. In the viewport's “Front” mode (2) shift the bullet to the right.(插入一个球形节点作为子弹)

  • Add a “Cube” node, position it beneath the glass, and rescale it. Make it big, because it is the ground object.(插入一个立方体节点于杯子之下并放大作为地面)

  • Add a “Cone” node and rescale/reposition/rotate it until you get a setup similar to the image below. The “Cone01”object should be aligned with the bullet, because it is the zone of impact.(插入一个圆锥节点并调整至如下图位置与形状,作为撞击区域,该圆锥对象应该与子弹连成一线。)

 

Fragmenting the Glass(给杯子划分网格)

The bullet should hit the glass exactly where the cone is intersecting the glass. This is also the zone with the highest density of fragments:

子弹应该击中圆锥与杯子相交的部位,那里也是杯子网格划分最密的地方。

  • Select the glass node.(选择杯子节点)

  • Tools > Fracture Tool > Voronoi By Steering Geometry...(采用Voronoi算法划分)

  • Rough number of pieces > 130 (or any other number)(确定大概划分块数)

  • Click on the “...” button and choose “Cone01”.(选择圆锥)

  • Lowest/highest concentration rate > 0.007

  • Transition length > 0.2

  • OK

  • A new MultiBody with a “_fractured01” suffix appears.(出现一个带有_fractured01后缀的新组合体)

  • If you are happy with the results “Cone01” and the original glass node can be deleted.(如果对Cone01结果满意,可以将初始杯子节点删除)

    The last two parameters are used to control the transition from the impact zone to the outer areas of the glass. Both settings avoid that the glass will be broken into lots of very small, almost uniform, pieces. If you are not satisfied just delete the newly created object, and repeat the fracturing process with other values.

    最后的两个参数用于控制从撞击区域到杯子外部区域的过渡。所有的设置应避免杯子破碎成许多非常小的,几乎一致的碎片。如果不满意,删除新创建的对象,重复以上设置过程,重新设置参数即可。

 

The Rigid Body Parameters(刚体参数)

    In this step, the dynamics properties will be activated and adjusted. Let's start with the fractured glass node:

    本步骤将激活并调整动力学属性,现在开始处理碎杯子节点:

  • Node > Dynamics > Active rigid body(节点>动力学>激活刚体)

  • Rigid body > @ object friction > 0.5(摩擦力)

  • Rigid body > @ elasticity > 0.5(弹性力)

 

    Then the ground object (“Cube01”):(地面对象)

  • Node > Dynamics > Passive rigid body(从动刚体)

 

    Finally, the bullet (“Sphere01”). This node will be animated, but has rigid body features as well:(子弹也有刚体特征)

  • Node > Position > X (the first value from the trio)

  • Create a key-framed animation from right to left (or left to right) using the method from “Relaxing the Fluid”. The bullet should be fast to get a vivid splash: 20 m in 70-80 frames is a good value.

  • 使用“Relaxing the Fluid”中的方法创建一个关键帧动画(从左至右或相反)。为实现生动逼真的晃动,子弹的速度要快,70-80帧移动20m是较好的速度值。
  • Node > Dynamics > Passive rigid body(从动刚体)

    The combination of animation and rigid body properties is interesting, because the bullet's motion path and speed can be controlled, but it is able to interact with other rigid bodies. In this state, the bullet has infinite force.

    将动画与刚体属性结合起来非常有趣,因为子弹运动路径和速度可以控制,但是还可以与其他刚体相互作用。这里,子弹有无限动力。

Joining the Pieces(连接碎片)

    Currently, the fractured glass will fall apart and the fluid will pour out, because the pieces are not connected. There has to be a way to reconnect them, but these joints have to break when the bullet hits the glass. The solution is MultiJoints – all panels are located under the “MultiJoint01” element's “Node Params”:

    目前,杯子碎片将四处散落液体也将洒出,因为碎片不是相连的。需要重新连接碎片,但是当子弹击中杯子时原来的连接已经破坏。解决方法是“MultiJoints”(多连接)。

  • Edit > Add > Objects > MultiJoint

  • Creation > Objects A > fractured glass node

  • Creation > Objects B > fractured glass node

  • Forces > Force max mode > Constant limit

  • Collisions > Enable if break > Yes

  • Break > Break if distance exceeded > Yes(如果距离超出则破坏断开)

  • Creation > Create/Recreate

 

 

    The “Forces” panel contains a “@ Max force” parameter and adjusting this value is the most difficult part. The joints have to be strong enough to resist the glass body's own weight and the weight of the fluid. Start with a rather high value, e.g. 250,000 and trigger the simulation. Let it run for around 5-10 frames:

    Forces面板含有一个“@ Max force”参数,将该值调整合适最为困难。连接需要足够强以支持杯子与液体的自重。先试以较大值,如250000,进行仿真,运行约5-10帧。

  • If you can see orange or red joints then the forces are not strong enough and the links break. In this case you have to increase “@ Max force”.

  • 如果可以看到橘色或红色结点且由于结点力不够大以至连接破坏。这种情况应该增加 “@ Max force”值
  • Go to Statistics > @ Max force used since creation. This read-only field gives you a hint of the occurring forces, and can be used as a starting value.

  • 进入 统计>@创建以来使用的最大力。该只读域给出当前力的提示,可以用于初始值。
  • Do not use the displayed value 1:1, but add a 10-20% buffer and transfer the value to “@ Max force”.

  • 不要直接使用显示值,增加 10-20% 的裕度。
  • Reset and simulate again. If all joints are green and intact you can go on simulating. Otherwise you have to further increase “@ Max force”.

  • 重置并仿真。如果所有结点都为绿色且完好则可以继续仿真,否则需继续增加@ Max force值。
  • For the rendered image at the beginning of this tutorial, “@ Max force” has been set to 150,000 with a “@ Max force random” value of 100.

  • 本教程开头处的渲染图,@ Max force为150000,@ Max force random值为100。

 

The Simulation and Previews(仿真和预览)

    It is very likely that you will have to create different versions until you get the desired result – and these versions have to be compared. The easiest way to do this is to use RealFlow's preview engine:

    很可能需要尝试多次才能得到想要的结果,并且多个版本之间需要相互比较,最简单的方式是使用RF的预览引擎:

  • Adjust the point of view by rotating, zooming and panning the viewport.(调整视角)

  • You can add a camera, but this step is not mandatory.(可以添加相机但不是必须的)

  • Go to frame 0, and click on Playback > OpenGL.

  • RealFlow goes through the simulation and records the viewport frame by frame.(RF进行仿真并逐帧记录视角)

  • If the timeline slider stays at frame 0 please check if the maximum preview frame is not 0.(如果时间轴始终停在第0帧,检查最大预览帧数是否为0)

  • Once the frames have been recorded, a “Movie Player” window is opened automatically. After a few seconds you can watch the simulation in real-time.

  • 一旦帧被记录,会自动打开一个电影播放器,几秒之后可以看到实时仿真结果。
  • Click on the player's “Save” icon, and write the movie to disk.(点击播放器保存图标,将movie写到磁盘)

 


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要模拟出煤块破碎、掉落、传送这一过程,可以使用以下代码: ``` // 创建煤块 var coalGeometry = new THREE.BoxGeometry(5, 5, 5); var coalMaterial = new THREE.MeshStandardMaterial({color: 0x333333}); var coal = new THREE.Mesh(coalGeometry, coalMaterial); scene.add(coal); // 煤块被击中时触发的事件 function onHit() { // 煤块破碎效果 var coalPieces = 10; for (var i = 0; i < coalPieces; i++) { var pieceGeometry = new THREE.BoxGeometry(1, 1, 1); var pieceMaterial = new THREE.MeshStandardMaterial({color: 0x333333}); var piece = new THREE.Mesh(pieceGeometry, pieceMaterial); piece.position.copy(coal.position); piece.position.x += Math.random() * 2 - 1; piece.position.y += Math.random() * 2 - 1; piece.position.z += Math.random() * 2 - 1; scene.add(piece); // 煤块碎片掉落效果 var pieceTween = new TWEEN.Tween(piece.position) .to({y: -10}, 2000) .easing(TWEEN.Easing.Quadratic.Out) .onComplete(function() { scene.remove(piece); }) .start(); } // 煤块传送效果 var coalTween = new TWEEN.Tween(coal.position) .to({y: -10}, 2000) .easing(TWEEN.Easing.Quadratic.Out) .onComplete(function() { scene.remove(coal); }) .start(); } ``` 在上面的代码中,我们首先创建了一个煤块,并将其添加到场景中。当煤块被击中时,我们触发 `onHit` 函数,该函数会将煤块破碎成多个碎片,并且每个碎片都会掉落到地面上。同时,煤块本身也会被传送到地面下方,并最终从场景中移除。 在代码中,我们使用了 Tween.js 库来实现煤块掉落和传送的动画效果。同时,我们也可以通过调整 Tween.js 的参数来控制动画的速度、缓动等效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值