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

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

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.
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:constructor()
	NewScene.super.constructor(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 nodes, scenes = menori.glTFLoader.load('example_assets/players_room_model/', 'scene')
	local model_node_tree = menori.ModelNodeTree(nodes, scenes)

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

	self.y_angle = 0
end

function NewScene:render()
	love.graphics.clear(0.3, 0.25, 0.2)

	love.graphics.setDepthMode('less', true)
	self:render_nodes(self.root_node, self.environment)
	love.graphics.setDepthMode()
end

function NewScene:update_camera()
	self.y_angle = self.y_angle + 0.5
	local q = quat.from_euler_angles(math.rad(self.y_angle), math.rad(25), 0)
	self.camera:set_direction(q * vec3(10, 0, 0))
	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.
User avatar
Gunroar:Cannon()
Party member
Posts: 655
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:
-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
User avatar
uriid1
Prole
Posts: 9
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 :)
togFox
Party member
Posts: 448
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.
User avatar
rozenmad
Prole
Posts: 8
Joined: Tue Jun 05, 2018 3:15 am
Location: Moscow

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
siberian
Prole
Posts: 14
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: 8
Joined: Tue Jun 05, 2018 3:15 am
Location: Moscow

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests