Manual


The CurveLineRenderer script allows to draw 2D line into 3D scene. A width of the line is constant - it's a main feature of the script.


To start using the script you must create a new project or open an existing one.

At first, create a new empty GameObject by click GameObject->Create Empty in the menu, or use Ctrl+Shift+N keys. This GameObject will be used for drawing a spline.



Fig. 1. Creating a GameObject by main menu

Next, you need attach the CurveLineRenderer script to the created GameObject by press "Add Component" into the Inspector and set "Scripts->CurveLineRenderer" or drag and drop a script file from Assets to GameObject. MeshFilter, MeshRenderer and MeshCollider scripts will be added automatically, because its scripts are needed for drawing the spline. 


Fig. 2. Adding script to GameObject


Now, the script is ready to be used, and you can set parameters of the script. See example of script parameters on the figure 3:

Fig. 3. Parameters of CurveLineRenderer script into the Inspector


Main parameter of the script is a type of smoothing of corners. There are two types of smoothing: Default (without smoothing) and Rounded (corners are rounded in an arc of given radius), see fig. 4:


Fig. 4. Type of smoothing of the spline: Default (left) and Rounded (right)

The 3rd type of smoothing named Splitted is available from version 1.1. For this type all segments are independent from other segments. See example of splitted line in fig. 4.1:


 Fig. 4.1. Type of smoothing of the spline: Splitted (added in version 1.1)

Width of the spline defines thickness of the spline. Parameters radius and roundedAngle are used only for Rounded type of spline. See the figure 5, where using of rounded Angle is shown:


Fig. 5. Using roundedAngle for smoothing corners: roundedAngle = 45 degrees (left) and roundedAngle = 10 degrees (right).

Normal orients the spline into 3D space. If the value of a parameter reverseSideEnabled is true, reverse side of the spline will be drawn. Vertices is a list of points of the spline. Changes of parameters can be carried out in edit mode or runtime. In runtime, changes take effect after calling the method Invalidate().

Limitations:


1. Parameters width, roundedAngle, radius should be positive otherwise spline will not be drawn. If normal is a zero vector or quantity of spline vertices less 2, spline will not be drawn too.

2. Script limits both minimum and maximum radius when smoothing of corners is enabled for Rounded type of spline. Radius can't be less then the half of spline width. Limit of maximum radius depends on the distance between the spline vertices, which form the corner. 

3. Segment between the first and the second vertex of the spline should not be parallel to the normal vector.



Комментариев нет:

Отправить комментарий