FileMesh

Mostrar obsoleto

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.

El objeto FileMesh aplica una malla texturizada a un BasePart cuando se le asigna. Sus propiedades se heredan por el objeto SpecialMesh.

¿Qué es un FileMesh?

Los FileMeshes permiten que las mallas subidas por el usuario se apliquen a un BasePart .La malla que se aplica depende de la propiedad FileMesh.MeshId.Una textura también se puede aplicar a esta malla usando FileMesh.TextureId .

Aunque no es una clase abstracta, y puede ser utilizada por los desarrolladores, todas las propiedades FileMesh se heredan por el objeto SpecialMesh.Un SpecialMesh se comporta de forma idéntica al objeto FileMesh cuando su SpecialMesh.MeshType está configurado como 'FileMesh'.Aunque ambos objetos son funcionales, el objeto SpecialMesh es la clase oficial admitida.

Para obtener más información sobre el uso de mallas, consulte la página SpecialMesh .

Muestras de código

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.

FileMesh Offset and Scale

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

Resumen

Propiedades

  • MeshId:ContentId
    Leer paralelo

    El MeshId es el ID del contenido del malla que se va a mostrar.

  • TextureId:ContentId
    Leer paralelo

    El ID de textura es el ID del contenido de la textura que se va a aplicar a la malla.

Propiedades heredados de DataModelMesh

Propiedades

MeshId

ContentId
Leer paralelo

El MeshId es el ID del contenido del malla que se va a mostrar.

El ID de contenido para una malla se genera cuando un desarrollador sube una malla a Roblox.

Muestras de código

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

TextureId

ContentId
Leer paralelo

El ID de textura es el ID del contenido de la imagen que se debe aplicar para usar la textura de malla.Cuando la propiedad TextureId se establece en una cadena vacía, no se aplicará ninguna textura a la malla.

¿Cómo puedo cambiar la textura de una malla?

Usando la propiedad TextureId, la textura de una malla se puede cambiar sin tener que volver a subir la malla.Para hacer esto, se necesitará subir una nueva imagen a Roblox con la textura deseada.El archivo de imagen de textura original se puede obtener exportando la malla usando la opción 'Exportar selección' en Roblox Studio.El archivo de imagen se guardará junto con el archivo .obj exportado.

Luego, la nueva textura se puede volver a subir a Roblox como una insignia y su ID de contenido se puede aplicar a la malla usando la propiedad TextureId.

¿Cómo puedo hacer una malla texturizada?

Una malla solo se puede texturizar si la malla se ha mapeado con UV.La cartografía UV se refiere a la práctica de proyectar un mapa de textura sobre una malla.Esto no se puede hacer usando Roblox Studio y tiene que hacerse usando una aplicación de modelado 3D externa como Blender.

Muestras de código

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

Métodos

Eventos