FileMesh
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
L'oggetto FileMesh applica una mesh texturizzata a un BasePart quando è parented ad esso. Le sue proprietà sono ereditate dall'oggetto SpecialMesh .
Cos'è un FileMesh?
FileMeshes consentono di applicare a un BasePart le maglie caricate dall'utente.La mesh che viene applicata dipende dalla ProprietàFileMesh.MeshId.Una texture può essere applicata anche a questa mesh utilizzando FileMesh.TextureId .
Sebbene non sia una classe astratta, e possa essere utilizzata da sviluppatori, tutte le proprietà FileMesh sono ereditate dall'oggetto SpecialMesh.Un SpecialMesh si comporta identicamente all'oggetto FileMesh quando il suo SpecialMesh.MeshType è impostato su 'FileMesh'.Sebbene entrambi gli oggetti siano funzionali, l'oggetto SpecialMesh è la classe supportata ufficialmente.
Per ulteriori informazioni sull'utilizzo delle maglie, vedi la pagina SpecialMesh .
Campioni di codice
In this code sample a BasePart is instanced with a FileMesh. The DataModelMesh.Scale and DataModelMesh.Offset properties of the FileMesh are then animated using TweenService.
local TweenService = game:GetService("TweenService")
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("FileMesh") -- advised to use SpecialMesh instead
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
local box = Instance.new("SelectionBox")
box.Adornee = part
box.Parent = part
part.Parent = workspace
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()
Sommario
Proprietà
L'ID mesh è l'ID del contenuto della mesh che deve essere visualizzata.
L'ID della texture è l'ID del contenuto della texture che deve essere applicata alla Mesh, maglia.
Lo spostamento di una mesh determina la posizione relativa da BasePart.Position di un BasePart che la mesh verrà visualizzata.
La scala di una mesh determina le dimensioni della mesh rispetto alle sue dimensioni originali.
Cambia il tono della Strutturadi una Mesh, maglia, utilizzato con FileMesh.TextureId .
Metodi
Proprietà
MeshId
L'ID mesh è l'ID del contenuto della mesh che deve essere visualizzata.
L'ID del contenuto per una mesh viene generato quando un sviluppatore carica una mesh su Roblox.
Campioni di codice
In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.
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
TextureId
L'ID della Strutturaè l'ID del contenuto dell'immagine che deve essere applicata per la texture delle maglie.Quando la proprietà TextureId è impostata su una Stringavuota, non verrà applicata alcuna texture alla Mesh, maglia.
Come posso cambiare la texture di una Mesh, maglia?
Usando la ProprietàTextureId, la texture di una mesh può essere cambiata senza dover ricaricare la Mesh, maglia.Per farlo, sarà necessario caricare una nuova immagine su Roblox con la Strutturadesiderata.Il file immagine texture originale può essere ottenuto esportando la mesh utilizzando l'opzione 'Esporta selezione' in Roblox Studio.Il file immagine verrà salvato insieme al file .obj esportato.
La nuova texture può quindi essere ri-caricata su Roblox come Decal e il suo ID contenuto può essere applicato alla mesh utilizzando la ProprietàTextureId.
Come posso creare una Mesh, magliatextureata?
Una mesh può essere textureggiata solo se la mesh è stata mappata in UV.La mappatura UV si riferisce alla pratica di proiettare una mappa di texture su una Mesh, maglia.Questo non può essere fatto utilizzando Roblox Studio e deve essere fatto utilizzando un'applicazione di modellazione 3D esterna come Blender.
Campioni di codice
In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.
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