Menori - LÖVE library for simple 3D and 2D rendering

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
rozenmad
Prole
Posts: 9
Joined: Tue Jun 05, 2018 3:15 am

Menori - LÖVE library for simple 3D and 2D rendering

Post by rozenmad »

Some time ago I've made a library for 2D and 3D rendering based on the idea of a scene graph for my projects. It's still not perfect, but I'm working on improving it.
Loading of 3D models in .gltf format is also supported.
On the github you can find documentation and simple example. I'll add more complex examples in the future.
I hope you find the library useful.

Documentation
Menori on Github

Image

Usage example:

Code: Select all

local menori = require 'menori'
local application = menori.Application

local ml = menori.ml
local vec3 = ml.vec3
local quat = ml.quat

local NewScene = menori.Scene:extend('NewScene')

function NewScene:init()
	NewScene.super.init(self)

	local aspect = menori.Application.w/menori.Application.h
	self.camera = menori.PerspectiveCamera(60, aspect, 0.5, 1024)
	self.environment = menori.Environment(self.camera)

	local gltf = menori.glTFLoader.load('example_assets/players_room_model/scene.gltf')
	local model_node_tree = menori.ModelNodeTree(gltf)

	self.root_node = menori.Node()
	self.root_node:attach(model_node_tree)

	self.y_angle = 0
end

local rstate = {clear = true, colors = {{0.2, 0.15, 0.1, 1}}}
function NewScene:render()
	self:render_nodes(self.root_node, self.environment, rstate)
end

function NewScene:update_camera()
	self.y_angle = self.y_angle + 0.5
	local q = quat.from_euler_angles(0, math.rad(self.y_angle), math.rad(-45))
	local v = vec3(0, 0, 8)
	self.camera.eye = q * v
	self.camera:update_view_matrix()
end

function NewScene:update()
	self:update_camera()
	self:update_nodes(self.root_node, self.environment)
end

function love.load()
	local w, h = 960, 480
	application:resize_viewport(w, h)

	application:add_scene('new_scene', NewScene())
	application:set_scene('new_scene')
end

function love.draw()
	application:render()
end

function love.update(dt)
	application:update(dt)
end
See main.lua for a more complete example.
Last edited by rozenmad on Mon May 09, 2022 8:57 pm, edited 2 times in total.
User avatar
Gunroar:Cannon()
Party member
Posts: 1143
Joined: Thu Dec 10, 2020 1:57 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by Gunroar:Cannon() »

Oh my purple smacked butter glob! That looks really good. And am I wrong thinking that's the room of a classic Pokémon game made 3d? Gold maybe? :ultrahappy:
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
uriid1
Prole
Posts: 10
Joined: Thu Jan 14, 2021 4:16 pm

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by uriid1 »

Wow! That's really cool :)
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by togFox »

It is cool. I like.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
rozenmad
Prole
Posts: 9
Joined: Tue Jun 05, 2018 3:15 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by rozenmad »

Thank you all. :)
Gunroar:Cannon() wrote: Tue Jun 01, 2021 7:20 pm Oh my purple smacked butter glob! That looks really good. And am I wrong thinking that's the room of a classic Pokémon game made 3d? Gold maybe? :ultrahappy:
It's from Pokemon FireRed.

By the way, I added a simple demo with this scene on my website using love.js:

DEMO
User avatar
siberian
Prole
Posts: 23
Joined: Sat Apr 06, 2019 1:42 pm

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by siberian »

There is a comment in file lighting.glsl

Code: Select all

// love2d use row major matrices by default, we have column major and need transpose it.
// 11.3 love has bug with matrix layout in shader:send().
vec4 position(mat4 transform_projection, vec4 vertex_position) {
      ...
}
What kind of bug?
User avatar
rozenmad
Prole
Posts: 9
Joined: Tue Jun 05, 2018 3:15 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by rozenmad »

siberian wrote: Thu Nov 25, 2021 4:33 am There is a comment in file lighting.glsl

Code: Select all

// love2d use row major matrices by default, we have column major and need transpose it.
// 11.3 love has bug with matrix layout in shader:send().
vec4 position(mat4 transform_projection, vec4 vertex_position) {
      ...
}
What kind of bug?

Code: Select all

Shader:send( name, data, matrixlayout, offset, size )
does not work properly in 11.3, it has been fixed, but in version 11.3 it will not work as it should.
User avatar
rozenmad
Prole
Posts: 9
Joined: Tue Jun 05, 2018 3:15 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by rozenmad »

A new version of the library has been released.
- revised documentation.
- the Material class has been added, as well as new methods to the Node class.
! If you use menori in your projects, be careful when updating the library, as there is no compatibility between different versions.
ashifolfi
Prole
Posts: 1
Joined: Fri May 27, 2022 12:01 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by ashifolfi »

How exactly did you make that gltf file used in the demo? I tried both direct exporting a cube from blender using a plugin and using an fbx to gltf converter and both of them caused a crash in Menori and I cannot figure out why.
Raph
Prole
Posts: 4
Joined: Sun Jul 24, 2022 5:41 am

Re: Menori - LÖVE library for simple 3D and 2D rendering

Post by Raph »

Never mind! I was looking in the wrong place in the documentation.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests