SpecialMesh

Hiển Thị Bản Đã Lỗi Thời

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.

Vật thể SpecialMesh áp dụng một lưới cho một BasePart tùy thuộc vào thuộc tính MeshType. Nhiều tùy chọn có sẵn.

  • Gạch - Một hình khối, tương đương với một BlockMesh
  • Hình trụ - Một hình trụ, giống như một Part với một Part.Shape của 'Hình trụ'
  • FileMesh - Một người dùng đã tải lên Mesh, tương đương với FileMesh mà một kết cấu có thể được áp dụng bằng cách sử dụng thuộc tính FileMesh.TextureId
  • Đầu - Một hình dạng đầu nhân vật
  • Cầu - Hình dạng cầu, tương tự như một Part với một Part.Shape của 'Bóng' nhưng có thể thay đổi tự do trên tất cả các trục
  • Góc cạnh - Một hình dạng góc cạnh, giống như một WedgePart
  • Thân - Một khối có các bên dốc, do sẽ bị loại bỏ

Lưu ý, mỗi SpecialMesh.MeshType sẽ có quy mô khác nhau khi sử dụng DataModelMesh.Scale, để biết thêm thông tin về điều này, vui lòng xem trang trên DataModelMesh.Scale .Vật phẩm SpecialMesh cũng tiết lộ thuộc tính DataModelMesh.Offset.

Quan trọng là phải nhớ rằng khi sử dụng một SpecialMesh, chỉ có sự xuất hiện của một phần thay đổi.Mô hình va chạm của phần vẫn giống như nhau.Ví dụ, một nhân vật sẽ không thể đi bộ đúng cách trên một khối lưới vì không có sự xem xét về hình học lưới.

SpecialMesh vs MeshPart so với

Hiện tại có hai cách sử dụng một khối lượng lưới được tạo bởi nhà phát triển.Họ đang sử dụng một SpecialMesh với SpecialMesh.FileType đến 'FileMesh', hoặc bằng cách sử dụng MeshPart.Mặc dù, trên toàn bộ, đối tượng MeshPart đã vượt qua SpecialMesh có một số sự khác biệt mà các nhà phát triển nên nhận thức.

  • BasePart.Material hiển thị đúng trên lưới khi sử dụng một MeshPart và không phải khi sử dụng một SpecialMesh
  • MeshParts bao gồm thuộc tính MeshPart.CollisionFidelity , có nghĩa là mô hình va chạm của một MeshPart có thể được đặt thành tương tự với hình học của lưới.Các đối tượng SpecialMesh bằng cách trái ngược, sử dụng mô hình va chạm cha BaseParts
  • Lưới của một MeshPart thước trên tất cả các trục dựa trên tính chất Size của MeshPart , lưới của một SpecialMesh không
  • Vật phẩm SpecialMesh bao gồm các thuộc tính OffsetScale trong khi MeshParts không
  • Thuộc tính MeshId của một SpecialMesh có thể được thay đổi bởi một Script hoặc LocalScript trong thời gian chạy.Thuộc tính MeshId của một MeshPart không thể.

Mẫu mã

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()

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.

Mesh VertexColor

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.VertexColor = Vector3.new(1, 1, 1)
mesh.Parent = part
-- parent part to workspace
part.Parent = workspace
-- create tweens
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local blackTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 0) })
local redTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 0, 0) })
local greenTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 1, 0) })
local blueTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 1) })
local resetTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 1, 1) })
-- animate
while true do
blackTween:Play()
blackTween.Completed:Wait()
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
resetTween:Play()
resetTween.Completed:Wait()
task.wait()
end

Tóm Tắt

Thuộc Tính

Thuộc Tính kế thừa từ FileMesh
  • MeshId:ContentId
    Đọc Song Song

    MeshId là ID nội dung của mesh sẽ được hiển thị.

  • TextureId:ContentId
    Đọc Song Song

    TextureId là ID nội dung của kết cấu sẽ được áp dụng cho lưới.

Thuộc Tính kế thừa từ DataModelMesh
  • Đọc Song Song

    Offset của một khối lượng quyết định vị trí tương đối từ BasePart.Position của một BasePart mà khối lượng sẽ được hiển thị tại.

  • Đọc Song Song

    Tỉ lệ của một khối lượng quyết định kích thước của khối lượng so với kích thước ban đầu của nó.

  • Đọc Song Song

    Thay đổi màu sắc của bề mặt khối lượng, được sử dụng với FileMesh.TextureId .

Thuộc Tính

Đọc Song Song

Mesh mà đối tượng SpecialMesh áp dụng cho BasePart phụ thuộc vào thuộc tính MeshType. Nhiều lựa chọn có sẵn.

  • Gạch - Một hình khối, tương đương với một BlockMesh
  • Hình trụ - Một hình trụ, giống như một Part với một Part.Shape của 'Hình trụ'
  • FileMesh - Một người dùng đã tải lên Mesh, tương đương với FileMesh mà một kết cấu có thể được áp dụng bằng cách sử dụng thuộc tính FileMesh.TextureId
  • Đầu - Một hình dạng đầu nhân vật
  • Cầu - Hình dạng cầu, tương tự như một Part với một Part.Shape của 'Bóng' nhưng có thể thay đổi tự do trên tất cả các trục
  • Góc cạnh - Một hình dạng góc cạnh, giống như một WedgePart
  • Thân - Một khối có các bên dốc, do sẽ bị loại bỏ

Lưu ý, mỗi loại MeshType sẽ có quy mô khác nhau khi sử dụng DataModelMesh.Scale , để biết thêm thông tin về chủ đề này, vui lòng xem trang trên DataModelMesh.Scale .

Mẫu mã

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.

Mesh VertexColor

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.VertexColor = Vector3.new(1, 1, 1)
mesh.Parent = part
-- parent part to workspace
part.Parent = workspace
-- create tweens
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local blackTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 0) })
local redTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 0, 0) })
local greenTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 1, 0) })
local blueTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 1) })
local resetTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 1, 1) })
-- animate
while true do
blackTween:Play()
blackTween.Completed:Wait()
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
resetTween:Play()
resetTween.Completed:Wait()
task.wait()
end

Phương Pháp

Sự Kiện