Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update English Version #10

Merged
merged 14 commits into from
Jun 25, 2023
2 changes: 1 addition & 1 deletion Docs/English/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ A trigger is a spatial area with a specific shape, which is able to detect parti

## Emitter

Emitter is an object that can continuously emit bodies.
An emitter is an object that can continuously emit bodies.

[Introduction](BasicComponents/Emitter.md)

Expand Down
175 changes: 76 additions & 99 deletions Docs/English/Tutorials/Tutorial.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,119 @@
# Soft2D-Tutorial

> 这是 Soft2D for Unity 的教程,它可以帮助你快速上手 Soft2D 插件。
> This is a tutorial for Soft2D for Unity, which can help you quickly get started with it.

## 基础设置
## Basic Settings

> 在本节教程中,我们会介绍如何导入 Soft2D 插件至 Unity 项目中,并完成 Soft2D 的基础设置。
> In this tutorial, we will introduce how to import Soft2D for Unity into a Unity project and complete the basic setup.

Soft2D 插件支持两种方式导入 Unity 项目中,它们分别是 Unity Asset Store Github 页面。
You can import Soft2D for Unity through Unity Asset Store and Github.

- Unity Asset Store
- 在 Unity Asset Store 页面访问 Soft2D 插件: [Soft2D for Unity](https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041)
- 点击 **Add to My Assets** 将插件添加到你的Unity账号中;
- 返回 Unity 编辑器,通过 Windows->Package Manager 打开 **Package Manager** 窗口;
- 在 Package Manager 窗口选择 **My Assets** 选项卡,找到 Soft2D 插件,并点击 **Download** 按钮将其下载到本地。
- Visit Soft2D for Unity in Unity Asset Store: [Soft2D for Unity](https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041);
- Click the **Add to My Assets** to add the plugin to your Unity account;
- Return to the Unity Editor and open the **PackageManager** window by selecting Windows->Package Manager.
- Select the **My Assets** tab in the **PackageManager** window, locate the Soft2D plugin, and click the **Download** button.

- Github
- 在 Github 仓库页面访问 Soft2D 插件: [Soft2D for Unity](https://github.com/taichi-dev/soft2d-for-unity);
- 在 **Releases** 页面获取适当版本的插件文件并下载下来;
- 直接将下载下来的 **Soft2D.unitypackage** 文件拖拽到编辑器的 **Project** 视图中;
- Unity 编辑器会弹出一个导入设置窗口,确认无误后点击 **Import** 按钮。
- Visit Soft2D for Unity in Github: [Soft2D for Unity](https://github.com/taichi-dev/soft2d-for-unity);
- Get the appropriate version of the plugin on the **Release** page and download it;
- Unzip it anywhere in your Unity Assets folder (except the Editor, Plugins or Resources directories).

当你导入完成后,插件会自动弹出一个启动窗口。由于当前插件只支持 Vulkan 和 Metal 图形 API,请按照窗口流程设置当前项目使用的图形 API。
After the import is complete, the plugin will automatically display a startup window. Please follow the window process to set up the current project.

视频链接:[BasicSetup]()
Video: [BasicSetup]()

## 快速开始
## Quick Start

> 在本节教程中,我们会介绍如何使用 Soft2D 插件创建一个简单的场景,实现 Soft2D 的模拟功能。
> In this tutorial, we will introduce how to create a simple scene by Soft2D for Unity and implement Soft2D simulation features.

- 创建一个新的场景。在 Hierarchy 窗口右键,通过 Soft2D->Soft2DManager 创建一个 **Soft2DManager** 物体。Soft2DManager 是用来控制并渲染
当前场景的 Soft2D 粒子的脚本。 它的具体介绍和参数内容可以[点击这里](../BasicComponents/Soft2DManager.md)查看。
- 通过 Soft2D->Body->Body 创建一个 **Body** 物体。Body 是用由一组内部粒子组成的一个物体。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Body.md)查看。
- 最后,因为创建的 Body 物体并不在 Soft2D 的模拟范围内(初始设置是左下角在原点的 1x1 正方形),我们需要把物体移动到模拟范围内(比如(0.5,0.8))。
- 为了在运行后有较好的视觉体验,你可以调整摄像头至相应的大小和位置。
- Create a new Unity scene. Right-click in the Hierarchy window and create a **Soft2DManager** object through Soft2D->Soft2DManager. Soft2DManager is a script used to control and render Soft2D particles in the current scene. You can [click here](../BasicComponents/Soft2DManager.md) to view its detailed introduction.
- Create a **Body** object through Soft2D->Body->Body. A body is a continuum to be simulated, which is composed of a group of particles. You can [click here](../BasicComponents/Body.md) to see its detailed introduction.
- Finally, since the created Body object is not within the simulation range of Soft2D (the initial setting is a 1x1 square with the bottom left corner at the origin), we need to move the object into the simulation range. (e.g.: (0.5,0.8)).
- To have a better visual experience after running, you can adjust the camera to the appropriate size and position.

完成上述操作后运行当前场景,你就能看到一个长方形的水的模拟效果了:

[img.png]()

视频链接:[QuickStart](../../GIFs/Body.mp4)
Video: [QuickStart](../../GIFs/Body.mp4)

## CustomBody

> 在本节教程中,我们会介绍如何创建一个 CustomBody,以及它的特性和功能。

CustomBody 和上一章的 Body 都属于 Soft2D 的 `S2Body` 类型。但 Body 只能设置成 Box/Circle/Capsule 等固定的形状,而在 CustomBody 中,
用户可以自定义粒子的数量和每个粒子的位置。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Body.md)查看。下面是 CustomBody 的创建和使用流程:

- 创建一个新的场景并通过 Soft2D->Soft2DManager 创建一个 **Soft2DManager** 物体;
- 通过 Soft2D->Body->CustomBody 创建一个 **CustomBody** 物体;
- 在 CustomBody 物体的 Inspector 窗口内修改粒子的数量和位置:
- 在 `E Custom Body` 脚本下找到 Particles Local Positions 选项,向里面输入三个粒子位置数据:(0,0),(0.05,0),(0.025,0.05);
- 把 CustomBody 物体移动到模拟范围内(比如(0.5,0.8))。
> In this tutorial, we will introduce how to create a CustomBody, as well as its features and functions.

完成上述操作后运行当前场景,你就能看到一个三角形的 CustomBody 的模拟效果了:
Both CustomBody and Body are belong to the `S2Body` type in Soft2D. However, Body can only be set to fixed shapes (e.g.: Box/Circle/Capsule), while in CustomBody, users can customize the number of particles and the position of each particle. You can [click here](../BasicComponents/Body.md) to view its detailed introduction.

[img.png]()
The following is the process of creating and using **CustomBody**:
- Create a **Soft2DManager** object through Soft2D->Soft2DManager in a new Unity scene;
- Create a **CustomBody** object through Soft2D->Body->CustomBody;
- Modify the quantity and position of particles within the **Inspector** window of the **CustomBody** object:
- Locate the **Points Positions** option and input three `Vector2` into it: (0,0), (0.05,0), (0.025,0.05).
- Move the **CustomBody** object into the simulation range. (e.g.: (0.5,0.8)).

视频链接:[CustomBody](../../GIFs/CustomBody.mp4)
Video: [CustomBody](../../GIFs/CustomBody.mp4)

## MeshBody

> 在本节教程中,我们会介绍如何创建一个 MeshBody,以及它的特性和功能。
> In this tutorial, we will introduce how to create a MeshBody, as well as its features and functions.

MeshBody 也属于 Soft2D 的 `S2Body` 类型。我们可以将一张带有网格的 2D 贴图输入至 MeshBody 内,而 MeshBody 会为网格上的每个顶点生成一个粒子,
而且粒子之间也有着网格那样的拓扑关系。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Body.md)查看。下面是 MeshBody 的创建和使用流程:
MeshBody also belongs to the S2Body type of Soft2D. We can input a 2D texture with a mesh into MeshBody. MeshBody will generate a particle for each vertex, and the particles will have the same topology as the mesh. You can [click here](../BasicComponents/Body.md) to view its detailed introduction.

- 创建一个新的场景并通过 Soft2D->Soft2DManager 创建一个 **Soft2DManager** 物体;
- 通过 Soft2D->Body->CustomBody 创建一个 **MeshBody** 物体;
- 然后,我们需要为一个 2D 贴图创建网格:
- 在预设的 2D 贴图的 Inspector 窗口内点击 **Sprite Editor** 按钮进入贴图编辑器窗口;
- 在左上角将 Sprite Editor 改为 Skinning Editor,在左边新生成的窗口中选择 **Auto Weights** 让 Unity 自动生成网格;
- 点击左下角的 **Generate All** ,再点击上方的 **Apply** 保存设置;
- 此时 2D 贴图的网格已经创建完毕,你可以直接关闭贴图编辑器窗口。
- 在 MeshBody 物体下找到 `E Mesh Body` 脚本,把 2D 贴图挂载至 **Mesh Sprite** 下,并通过 **Mesh Scale** 调整它的大小;
- 把 MeshBody 物体移动到模拟范围内(比如(0.5,0.8))。
The following is the process of creating and using **MeshBody**:
- Create a **Soft2DManager** object through Soft2D->Soft2DManager in a new Unity scene;
- Create a **MeshBody** object through Soft2D->Body->CustomBody;
- Then we need to generate mesh for the 2D texture:
- Click **Sprite Editor** button
- Click the **Sprite Editor** button in the Inspector window of the preset 2D texture to enter the **Sprite Editor** window.
- Change Sprite Editor to Skinning Editor in the top left corner, and select **Auto Weights** in the newly generated window on the left to make Unity automatically generate the mesh;
- Click **Generate All** button, and click **Apply** button above to save settings;
- At this point, the mesh has been generated completely.
- Find the E Mesh Body script under the MeshBody object and attach the 2D texture to the **Mesh Sprite**. Adjust its scale by **Mesh Scale**;
- Move the **MeshBody** object into the simulation range. (e.g.: (0.5,0.8)).

完成上述操作后运行当前场景,你就能看到一个有着卡通小车网格的 MeshBody 的模拟效果了:

[img.png]()

视频链接:[MeshBody](../../GIFs/MeshBody.mp4)
Video: [MeshBody](../../GIFs/MeshBody.mp4)

## Emitter

> 在本节教程中,我们会介绍 Emitter 的创建方法和功能。

Emitter 是一个能自由控制发射 Body 的发射器。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Emitter.md)查看。下面是 Emitter 的创建和使用流程:
> In this tutorial, we will introduce how to create an Emitter, as well as its features and functions.

- 创建一个新的场景并通过 Soft2D->Soft2DManager 创建一个 **Soft2DManager** 物体;
- 通过 Soft2D->Emitter 创建一个 **Emitter** 物体;
- 把 Emitter 物体移动到模拟范围内(比如(0.5,0.8));
- 将物体的 `E Emitter` 脚本下勾选 Emit On Awake,这样发射器就会在场景运行之初就开始发射预设 Body ;
- 此时我们可以通过修改参数给 **Emitter** 发射的物体换个造型:
- 将物体的 `E Emitter` 脚本下把 Material Type 修改为 **Elastic**;
- 将 Shape Type 修改为 **Box**,把 Half Width 和 Half Height 改成 0.05;
- 把 Base Color 换个颜色(比如橙色)。
An emitter is an object that can continuously emit bodies. You can [click here](../BasicComponents/Emitter.md) to view its detailed introduction.

完成上述操作后运行当前场景,你就能看到一个不停发射橙色正方弹性体的 Emitter 的模拟效果了:
The following is the process of creating and using **Emitter**:
- Create a **Soft2DManager** object through Soft2D->Soft2DManager in a new Unity scene;
- Create an **Emitter** object through Soft2D->Emitter;
- Move the **Emitter** object into the simulation range. (e.g.: (0.5,0.8)).
- Toggle **Emit On Awake** in `E Emitter` script.In this way, the **Emitter** will start emitting preset bodies at the beginning of the scene's execution;
- At this point, we can change the style of the Body emitted by **Emitter**:
- Change the Material Type to **Elastic**;
- Change the Shape Type to **Box**;
- Change Half Width and Half Height to 0.05;
- Change **Base Color** (such as orange).

[img.png]()

视频链接:[Emitter](../../GIFs/Emitter.mp4)
Video: [Emitter](../../GIFs/Emitter.mp4)

## Collider

> 在本节教程中,我们会介绍 Collider 的创建方法和功能。

Collider 是一个可以与 Soft2D 粒子产生碰撞的物体。因为在 Soft2D 内创建的 Collider 无法与 Unity 的物体发生交互,所以我们将 Soft2D 的
Collider 与 Unity 的 Collider2D 绑定在了一起。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Collider.md)查看。
我们将使用上一章创建 Emitter 的场景来介绍 Collider 的创建和使用流程:

- 通过 Soft2D->Collider 创建一个 **Collider** 物体;
- 把 Collider 物体移动到模拟范围内(比如(0.5,0.8))。
> In this tutorial, we will introduce how to create a Collider, as well as its features and functions.

完成上述操作后运行当前场景,你就能看到 Body 与 Collider 碰撞的模拟效果了:
A collider is an obstacle within the world that blocks the motion of bodies. Since **Collider** in Soft2D cannot interact with Unity objects, we have bound Soft2D's Collider with Unity's Collider2D. You can [click here](../BasicComponents/Collider.md) to view its detailed introduction.

[img.png]()
We will use the scene from the Emitter chapter to introduce the process of creating and using Collider:
- Create a **Collider** object through Soft2D->Collider;
- Move the **Collider** object into the simulation range. (e.g.: (0.5,0.8)).

> 你可以使用 [测试工具](../Advance/DebugTools.md) 来查看 Collider 在 Soft2D 内的位置和状态。
> You can use [Debug Tools](../Advance/DebugTools.md) to check Collider's position in Soft2D.

视频链接:[Collider](../../GIFs/Collider.mp4)
Video: [Collider](../../GIFs/Collider.mp4)

## Trigger

> 在本节教程中,我们会介绍 Trigger 的创建方法和功能。
> In this tutorial, we will introduce how to create a Trigger, as well as its features and functions.

Trigger 是一个可以与 Soft2D 粒子产生交互的触发器。它可以被进入 Trigger 作用范围的粒子触发,并对粒子做出相应修改。它的具体介绍和参数内容可以[点击这里](../BasicComponents/Trigger.md)查看。
我们将使用上一章创建 Collider 的场景来介绍 Collider 的创建和使用流程:
A trigger is a spatial area with a specific shape, which is able to detect particles passing through it. You can [click here](../BasicComponents/Trigger.md) to view its detailed introduction.

We will use the scene from the Collider chapter to introduce the process of creating and using Trigger:
- Remove the **Collider** object.
- Create a **Trigger** object through Soft2D->Trigger;
- Move the **Trigger** object into the simulation range. (e.g.: (0.5,0.8)).
- Create a new script and name it `TriggerExample.cs`, copy the following code into the script:

- 为了演示方便,我们先把 Collider 物体移除;
- 通过 Soft2D->Trigger 创建一个 **Trigger** 物体;
- 把 Collider 物体移动到模拟范围内(比如(0.5,0.8));
- 新建一个脚本,起名为 `TriggerExample.cs` ,将下面的代码复制进该脚本:
```csharp
using System;
using Taichi.Soft2D.Generated;
Expand All @@ -155,17 +136,13 @@ public class TriggerExample : MonoBehaviour
trigger.InvokeCallbackAsync(ManipulateTrigger1);
}
}

```
- 在场景内新建一个空物体,将 `TriggerExample.cs` 挂载在该空物体上;
- 将 Trigger 物体挂载在 `TriggerExample.cs` 的 **Trigger** 变量上。

完成上述操作后运行当前场景,你就能看到 Body 内粒子触发 Trigger 的效果了:

[img.png]()
- Create an empty GameObject, load `TriggerExample.cs` into this GameObject;
- Attach the **Trigger** object to the variable named "Trigger" in the `TriggerExample.cs` script.

> 你可以使用 [Debug Tools 工具](../Advance/DebugTools.md) 来查看 Trigger 在 Soft2D 内的位置和状态。
> You can use [Debug Tools](../Advance/DebugTools.md) to check Trigger's position in Soft2D.

> 自定义编写触发器修改粒子的教程可以在[这里](../Advance/CustomTrigger.md)看到。
> You can [click here](../Advance/CustomTrigger.md) to view the tutorial about the Soft2D custom shader.

视频链接:[Trigger](../../GIFs/Trigger.mp4)
Video: [Trigger](../../GIFs/Trigger.mp4)
2 changes: 1 addition & 1 deletion Docs/Simplified_Chinese/Concepts/Material.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- 物理材质类型
- 支持流体、沙子、弹性体和雪这几种类型。
- 密度
- 物质的[密度](https://en.wikipedia.org/wiki/Density)单位为 kg/m^3。常见的材料如水的密度为1000。
- 物质的[密度](https://en.wikipedia.org/wiki/Density)单位为 kg/m^3。常见的材料如水的密度为1000。
- 杨氏模量
- 物质的[杨氏模量](https://en.wikipedia.org/wiki/Young%27s_modulus)。单位为 MPa。如类似于果冻的材料,其杨氏模量约为 0.01Mpa ~ 1MPa 之间。
- > 较大的杨氏模量会导致模拟爆炸。此时降低 Soft2DManager 中的 时间子步长 ([见 Soft2DManager 文档](../BasicComponents/Soft2DManager.md)) 可以避免模拟爆炸,但是会导致模拟性能显著下降。
Expand Down
2 changes: 1 addition & 1 deletion Docs/Simplified_Chinese/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 介绍

Soft2D 是一个基于 Taichi AOT 系统的 2D 实时多材料物理引擎,可以模拟流体、弹性体、雪和沙子等材料。Soft2D for Unity 插件为 Soft2D 提供了高层封装,并为用户提供了一系列易用的的接口,可以让用户方便地在 Unity 中实现各种物理模拟和渲染效果。
- Soft2D 是一个实时 2D 多材料连续体物理引擎,可以模拟流体、弹性体、雪和沙子等材料。Soft2D for Unity 插件为 Soft2D 提供了高层封装,并为用户提供了一系列易用的的接口,可以让用户方便地在 Unity 中实现各种物理模拟和渲染效果。

# 前置要求

Expand Down
Loading