DataModelMesh

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
不可浏览

数据模型网格是一个抽象类,从而网格类下降。

网格类是对象,当作为父级到 BaseParts 时,将零件的外观更改为预定义网格的外观请注意,它们仅更改零件的外观,而不是零件的物理/碰撞边界。想要将网格应用到改变零件碰撞的零件上的开发人员应该使用 MeshParts

注意 MeshPartCharacterMesh 类不从 DataModelMesh 下降。

概要

属性

属性

Offset

读取并联

网格的偏移决定了网格在显示时与 BasePart.Position 的距离,网格将显示在哪个 BasePart

如何使用网格偏移值

抵消属性改变网格在相对位置渲染的关系。例如,偏移 0、5、0 会导致网格显示在 BasePart 的位置上 5 格。

BasePart的位置不会改变,这意味着零件的物理碰撞箱仍将保持在同一位置。这在下面的图像中得到了展示,其中绿色轮廓(a SelectionBox)显示了BasePart的边界。

网格偏移值的其他用途

网格偏移属性有很多有趣的用途。

  • 抵消和 可以使用相对便宜的方式进行动画,因为引擎不需要进行任何物理/碰撞计算,因为 不移动。
  • 更改网格和其碰撞边界之间的关系(由 BasePart 决定)

代码示例

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.Scale and DataModelMesh.Offset properties of the SpecialMesh are then animated using TweenService.

Mesh Offset and Scale

local TweenService = game:GetService("TweenService")
-- instance a part and a mesh
local part = Instance.new("Part")
part.Size = Vector3.new(4, 8, 4)
part.Position = Vector3.new(0, 4, 0)
part.Anchored = true
part.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid://1086413449"
mesh.TextureId = "rbxassetid://1461576423"
mesh.Offset = Vector3.new(0, 0, 0)
mesh.Scale = Vector3.new(4, 4, 4)
mesh.Parent = part
-- selection box to show part extents
local box = Instance.new("SelectionBox")
box.Adornee = part
box.Parent = part
-- parent part to workspace
part.Parent = workspace
-- animate offset and scale with a tween
local tween = TweenService:Create(
mesh,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0),
{ Scale = Vector3.new(1, 1, 1), Offset = Vector3.new(0, 3, 0) }
)
tween:Play()

Scale

读取并联

网格的尺寸决定了网格相对于原始尺寸的大小。

如何使用网格缩放

使用的网格类型不同,缩放属性的工作方式略有不同。注意 BasePart 的大小仍然不变,这意味着零件的物理碰撞箱仍然相同。

网格缩放示范

上述行为可以在以下示范图像中看到。

对“砖块”、“楔子”和“球体”网格的部件尺寸相对线性缩放。

对“文件网格”网格的原始上传网格相对线性缩放

对“圆柱”网格的非标准约束缩放

网格缩放的其他用途

网格偏移属性有很多有趣的用途。

代码示例

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.Scale and DataModelMesh.Offset properties of the SpecialMesh are then animated using TweenService.

Mesh Offset and Scale

local TweenService = game:GetService("TweenService")
-- instance a part and a mesh
local part = Instance.new("Part")
part.Size = Vector3.new(4, 8, 4)
part.Position = Vector3.new(0, 4, 0)
part.Anchored = true
part.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid://1086413449"
mesh.TextureId = "rbxassetid://1461576423"
mesh.Offset = Vector3.new(0, 0, 0)
mesh.Scale = Vector3.new(4, 4, 4)
mesh.Parent = part
-- selection box to show part extents
local box = Instance.new("SelectionBox")
box.Adornee = part
box.Parent = part
-- parent part to workspace
part.Parent = workspace
-- animate offset and scale with a tween
local tween = TweenService:Create(
mesh,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0),
{ Scale = Vector3.new(1, 1, 1), Offset = Vector3.new(0, 3, 0) }
)
tween:Play()

VertexColor

读取并联

垂直颜色 决定了 TextureFileMesh 的色调变化。请注意,这个属性是一个 Vector3 而不是一个 Color3;要转换,请使用 Color3.R , Color3.GColor3.B 属性。

虽然这个属性允许对纹理进行基本修改,但完全更改纹理可提供更多控制。见 MeshPart 获取更多详情。

方法

活动