3D draw help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

marioSuper21
Hoopster
Hoopster
Posts: 40
Joined: Thu Jul 31, 2025 8:43 am
Pronouns: he

3D draw help

Postby marioSuper21 » Mon Sep 01, 2025 6:22 pm

I wanted to learn how to draw a 3D object but I couldn't or nothing would happen.

Code: Select all

local lib3d = require("lib3d")

local model = lib3d.loadMesh(Misc.resolveFile("specific.obj"))

local image = Graphics.loadImageResolved("texture.png")
local material = lib3d.Material(nil, {texture = image}, nil, {UNLIT = true, TONEMAP = false, ALPHAMODE = lib3d.macro.ALPHA_DITHER})

function onDraw()
    local mesh = lib3d.Mesh{
        meshdata = model,
        material = material,

        scale = vector(64,64,64)*1,
        position = vector(camera.x + camera.width * 0.5, camera.y + 0.5 * camera.height * 0.5, 0),
    }
    
    mesh.active = true
end

MrDoubleA
Edward
Edward
Posts: 396
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: 3D draw help

Postby MrDoubleA » Tue Sep 02, 2025 4:43 pm

  • Make a mesh once rather than inside of onDraw, and just change its position in onDraw
  • You're not setting the camera's position
  • It depends entirely on the model, but that scale value could potentially be so large that it would just clip into the camera

marioSuper21
Hoopster
Hoopster
Posts: 40
Joined: Thu Jul 31, 2025 8:43 am
Pronouns: he

Re: 3D draw help

Postby marioSuper21 » Tue Sep 02, 2025 5:25 pm

I did not understand. Explain it to me in code.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari