AC.SoftRulerController

软尺绘制(AgentComponent_VlabSoftRulerController)

1、初始化

int Init(string path)

简要说明

软尺绘制初始化

参数

参数名 类型 说明
path string 路径

返回值

类型 说明
int id

2、绘制

2.0 LineInfo

线段信息(C#)

/// <summary>
/// 侧面高度对应贴图像素
/// </summary>
public int LineTextureEdgeHeight = 20;
/// <summary>
/// 表面高度对应贴图像素
/// </summary>
public int LineTextureSurfaceHeight = 240;
/// <summary>
/// 每米对应贴图像素
/// </summary>
public int LineTexturePixelPerMeters = 11378;
/// <summary>
/// 纹理贴图大小
/// </summary>
public Vector2Int TextureSize = new Vector2Int(4096, 4096);
/// <summary>
/// 分段数
/// </summary>
public int SegmentsNum = 10;
/// <summary>
/// 直线宽度
/// </summary>
public float Width = 0.0177f;
/// <summary>
/// 直线厚度
/// </summary>
public float Thickness = 0.0005f;

lua需传入参数的(可选传入,也可使用默认值,参数均大于0)

参数名 类型 说明
LineTextureEdgeHeight int 侧面高度对应贴图像素
LineTextureSurfaceHeight int 表面高度对应贴图像素
LineTexturePixelPerMeters int 每米对应贴图像素
TextureSize_x int 纹理贴图大小(x方向)
TextureSize_y int 纹理贴图大小(y方向)
SegmentsNum int 分段数(决定绘制精度,建议不要太大)
Width float 直线宽度
Thickness float 直线厚度

例子:

p = {
    ["LineInfo"] = {
        ["LineTextureEdgeHeight"] = "20",
        ["LineTextureSurfaceHeight"] = "240",
        ["LineTexturePixelPerMeters"] = "11378",
        ["TextureSize_x"] = "4096",
        ["TextureSize_y"] = "4096",
        ["SegmentsNum"] = "10",
        ["Width"] = "0.0177",
        ["Thickness"] = "0.0005"
    }
}

2.1、void Draw(int id, float length, string abName, string matPath, LuaTable parameter, bool isAddMeshCollider = false)

简要说明

直线绘制,绘制的起点为贴图UV(0,0)处,即贴图左下角

参数

参数名 类型 说明
id int 调用init获得的id
length float 长度(大于0)
abName string ab包名(默认为器材名)
matPath string 材质路径
parameter LuaTable 软尺绘制参数
isAddMeshCollider bool 是否添加MeshCollider(可选参数)
parameter
参数名 类型 说明
LineInfo LineInfo 线段信息
StartPoint Vector3 起点
Direction Vector3 方向
LookForward Vector3 软尺面朝向

parameter参数实例

p = {
    ["StartPoint"] = Vector3(0 ,0, 0),
    ["Direction"] = Vector3(1, 0, 0),
    ["LookForward"] = Vector3(0, 1, 0),
    ["LineInfo"] = {
        ["LineTextureEdgeHeight"] = "20",
        ["LineTextureSurfaceHeight"] = "240",
        ["LineTexturePixelPerMeters"] = "11378",
        ["TextureSize_x"] = "4096",
        ["TextureSize_y"] = "4096",
        ["SegmentsNum"] = "10",
        ["Width"] = "0.0177",
        ["Thickness"] = "0.0005"
    }
}

Example

self.VlabSoftRulerController:Draw(ruleid, 0.05, "RuanChiElement","ElementResource/Model/Science/juanchi_lod0/Materials/rule_lod0", p,true)

2.2、void DrawCircle(int id, float radius, float startAngle, float offset, float heightOffset, int pointNum, int totalPointNum, string abName, string matPath, LuaTable parameter, bool isAddMeshCollider = false)

简要说明

圆环绘制,绘制的起点为贴图UV(0,0)处,即贴图左下角

参数

参数名 类型 说明
id int 调用init获得的id
radius float 半径(大于0)
startAngle float 0刻度起始角度
offset float 半径偏移
heightOffset float 高度偏移
pointNum int 每圈的参考点数(大于3,与SegmentsNum一同决定绘制精细度)
totalPointNum int 总参考点数(大于2)
abName string ab包名(默认为器材名)
matPath string 材质路径
parameter LuaTable 软尺绘制参数
isAddMeshCollider bool 是否添加MeshCollider(可选参数)
parameter
参数名 类型 说明
LineInfo LineInfo 线段信息

pmt = {
    ["LineInfo"] = {
        ["LineTextureEdgeHeight"] = "20",
        ["LineTextureSurfaceHeight"] = "240",
        ["LineTexturePixelPerMeters"] = "11378",
        ["TextureSize_x"] = "4096",
        ["TextureSize_y"] = "4096",
        ["SegmentsNum"] = "10",
        ["Width"] = "0.017",
        ["Thickness"] = "0.0005"
    }
}

Example

self.VlabSoftRulerController:DrawCircle(ruleid, 0.2, 0, 0.01, 0.01, 100, 110, "RuanChiElement", "ElementResource/Model/Science/juanchi_lod0/Materials/juanchi_lod0", pmt)

2.3、[Obsolete]void DrawBrokenLine(int id, float length, string abName, string matPath, LuaTable parameter, float bendingDistance, int curvePointNum, bool isAddMeshCollider = false)

简要说明

折线绘制(已过时,建议使用2.4)

参数

参数名 类型 说明
id int 调用init获得的id
length float 折线长度(大于0)
abName string ab包名(默认为器材名)
matPath float 材质路径
parameter LuaTable 软尺绘制参数
bendingDistance float 折角的半径
curvePointNum int 折角曲线精细度(需大于等于2)
isAddMeshCollider bool 是否添加MeshCollider(可选参数)
parameter
参数名 类型 说明
BreakPoint Vector3 折点
StartPoint Vector3 起点
EndPoint Vector3 终点
LineInfo LineInfo 线段信息

parameter参数实例

p = {
    ["StartPoint"] = Vector3(0 ,0, 0),
    ["BreakPoint"] = Vector3(0, 0.5, 0),
    ["EndPoint"] = Vector3(-0.5, 0.5, 0),
    ["LineInfo"] = {
        ["LineTextureEdgeHeight"] = "20",
        ["LineTextureSurfaceHeight"] = "240",
        ["LineTexturePixelPerMeters"] = "11378",
        ["TextureSize_x"] = "4096",
        ["TextureSize_y"] = "4096",
        ["SegmentsNum"] = "50",
        ["Width"] = "0.017",
        ["Thickness"] = "0.0005"
    }
}

2.4、void DrawBrokenLine(int id, string abName, string matPath, LuaTable lineParameter, bool isAddMeshCollider)

简要说明

折线绘制,绘制的起点为贴图UV(0,0)处,即贴图左下角

参数

参数名 类型 说明
id int 调用init获得的id
abName string ab包名(默认为器材名)
matPath string 材质路径
lineParameter LuaTable 软尺绘制参数
isAddMeshCollider bool 是否添加MeshCollider(可选参数)
lineParameter
参数名 类型 说明
length float 折线长度(大于0)
KeyPoints Vector2[] 关键点
LineInfo LineInfo 线段信息
bendingDistance float 折角的半径(大于0)
curvePointNum int 折角曲线精细度(需大于等于2)

lineParameter参数实例

p = {
    ["Length"] = "1",
    ["KeyPoints"] = {
        Vector2(0, 0),
        Vector2(0.25, 0),
        Vector2(0.25, 0.25),
        Vector2(0, 0.25),
        Vector2(0, 0)
    },
    ["BendingDistance"] = "0.02",
    ["CurvePointNum"] = "10",
    ["LineInfo"] = {
        ["LineTextureEdgeHeight"] = "20",
        ["LineTextureSurfaceHeight"] = "240",
        ["LineTexturePixelPerMeters"] = "11378",
        ["TextureSize_x"] = "4096",
        ["TextureSize_y"] = "4096",
        ["SegmentsNum"] = "50",
        ["Width"] = "0.1",
        ["Thickness"] = "0.0005"
    }
}

Example

self.VlabSoftRulerController:DrawBrokenLine(ruleid, "RuanChiElement","ElementResource/Model/Science/juanchi_lod0/Materials/juanchi_lod0", p,true)

3、重绘

3.1、void Redraw(int id, float length, LuaTable parameter)

简要说明

直线重绘

参数

参数名 类型 说明
id int 调用init获得的id
length float 长度(大于0)
parameter LuaTable 软尺绘制参数
parameter
参数名 类型 说明
StartPoint Vector3 起点
Direction Vector3 方向
LookForward Vector3 软尺面朝向

Example

self.VlabSoftRulerController:Redraw(ruleid, lenght, p)

3.2、void RedrawCircle(int id, float radius, float startAngle, float offset, float heightOffset, int pointNum, int totalPointNum)

简要说明

圆环重绘

参数

参数名 类型 说明
id int 调用init获得的id
radius float 半径(大于0)
startAngle float 0刻度起始角度
offset float 半径偏移
heightOffset float 高度偏移
pointNum int 每圈的参考点数(大于3,与SegmentsNum一同决定绘制精细度)
totalPointNum int 总参考点数(大于2)

Example

self.VlabSoftRulerController:RedrawCircle(ruleid, 0.5,0,0.2,0.2,500,1000)

3.3、[Obsolete]void RedrawBrokenLine(int id, float length, LuaTable parameter, float bendingDistance, int curvePointNum)

简要说明

折线绘制(已过时建议使用3.4)

参数

参数名 类型 说明
id int 调用init获得的id
length float 折线长度
parameter LuaTable 软尺绘制参数
bendingDistance float 折角的半径
curvePointNum int 折角曲线精细度(需大于等于2)
parameter
参数名 类型 说明
BreakPoint Vector3 折点
StartPoint Vector3 起点
EndPoint Vector3 终点

3.4、void RedrawBrokenLine(int id, LuaTable lineParameter)

简要说明

折线绘制

参数

参数名 类型 说明
id int 调用init获得的id
lineParameter LuaTable 软尺绘制参数
lineParameter
参数名 类型 说明
length float 折线长度
KeyPoints Vector2[] 关键点
bendingDistance float 折角的半径(大于0)
curvePointNum int 折角曲线精细度(需大于等于2)

lineParameter参数实例

p = {
    ["Length"] = "1",
    ["KeyPoints"] = {
        Vector2(0, 0),
        Vector2(0.25, 0),
        Vector2(0.25, 0.25),
        Vector2(0, 0.25),
        Vector2(0, 0)
    },
    ["BendingDistance"] = "0.02",
    ["CurvePointNum"] = "10"
}

Example

self.VlabSoftRulerController:RedrawBrokenLine(ruleid, p)