Groverburger's 3D Engine (g3d) v1.5.2 Release

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Groverburger's 3D Engine (g3d) v1.5.2 Release

Post by groverburger »

Image

groverburger's 3D engine (g3d) simplifies LÖVE's 3d capabilities to be as simple as possible.

Get the latest version of g3d and check out the wiki on the Github page here:
https://github.com/groverburger/g3d

Features:
- 3D Model rendering
- .obj file loading
- Basic first person movement and camera controls
- Perspective and orthographic projections
- Easily create your own custom vertex and fragment shaders
- Basic collision functions
- Simple, commented, and organized
- Fully documented, check out the g3d wiki!

Image

The entire code for the demo is only 30 lines:

Code: Select all

-- written by groverbuger for g3d
-- may 2021
-- MIT license

local g3d = require "g3d"
local earth = g3d.newModel("assets/sphere.obj", "assets/earth.png", {0,0,4})
local moon = g3d.newModel("assets/sphere.obj", "assets/moon.png", {5,0,4}, nil, {0.5,0.5,0.5})
local background = g3d.newModel("assets/sphere.obj", "assets/starfield.png", {0,0,0}, nil, {500,500,500})
local timer = 0

function love.mousemoved(x,y, dx,dy)
    g3d.camera.firstPersonLook(dx,dy)
end

function love.update(dt)
    timer = timer + dt
    moon:setTranslation(math.cos(timer)*5, 0, math.sin(timer)*5 +4)
    moon:setRotation(0, math.pi - timer, 0)
    g3d.camera.firstPersonMovement(dt)
    if love.keyboard.isDown("escape") then love.event.push("quit") end
end

function love.draw()
    earth:draw()
    moon:draw()
    background:draw()
end

Need help on getting started? Want to know how 3D works in Love2D? Check out the wiki documentation on g3d's Github!
Wiki documentation link here: https://github.com/groverburger/g3d/wiki


Games made with g3d:

Hoarder's Horrible House of Stuff by alesan99
Image

Lead Haul by YouDoYouBuddy
Image

This project started when I worked on a Minecraft clone in Love back in 2019. I took the 3D engine I made for that project, and that eventually became g3d! This project's 3D code is old and horrible. Don't look at it!
Image

Feedback and suggestions are greatly appreciated!
g3d is offered under the MIT license. Check the LICENSE file on Github for more details.
Last edited by groverburger on Fri May 06, 2022 6:34 am, edited 16 times in total.
St. Cosmo
Prole
Posts: 8
Joined: Wed Nov 07, 2018 6:53 pm

Re: groverburger's Super Simple 3D Engine

Post by St. Cosmo »

Impressive work m8
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: groverburger's Super Simple 3D Engine

Post by pgimeno »

Wow and wow. That's a very impressive work. Map generator including strata and trees, collision handling, very decent lighting with light propagation. Great job.

The FOV is a bit wide, which can cause a bit of dizziness. But that's an easy adjustment :)

The name was already used for a 2D game (also here but that's just an early test). As hinted in that thread, that name suggests darker contents, which is a bit of a problem.

Another problem is the lack of any license text and copyright statement in the repository. Legal stuff is damn boring to handle, but needs to be sorted out correctly if you want it to be of any use to others. Also, are the assets yours? Are they under the same license? Unless they are yours or public domain, that is a problem as well, because there are no credits or license statement for them in the repo. In case they are not free, note there are free assets in the Minetest repo (CC BY-SA, see license for details).
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: groverburger's Super Simple 3D Engine

Post by groverburger »

St. Cosmo wrote: Mon Feb 11, 2019 2:59 pm Impressive work m8
pgimeno wrote: Mon Feb 11, 2019 6:54 pm Wow and wow. That's a very impressive work. Map generator including strata and trees, collision handling, very decent lighting with light propagation. Great job.

The FOV is a bit wide, which can cause a bit of dizziness. But that's an easy adjustment :)

The name was already used for a 2D game (also here but that's just an early test). As hinted in that thread, that name suggests darker contents, which is a bit of a problem.

Another problem is the lack of any license text and copyright statement in the repository. Legal stuff is damn boring to handle, but needs to be sorted out correctly if you want it to be of any use to others. Also, are the assets yours? Are they under the same license? Unless they are yours or public domain, that is a problem as well, because there are no credits or license statement for them in the repo. In case they are not free, note there are free assets in the Minetest repo (CC BY-SA, see license for details).
Thanks for the compliments and feedback!
I was sure the name Lovecraft was already taken. If that causes too many problems, I may change it in the future.

I'll be upfront that I currently know very little about legal stuff and licensing or how to apply it to my creations. I want SS3D to be free for anyone to use in their creations and even sell without problems. The engine.lua file was created entirely by me so that shouldn't be too much of an issue.

In Lovecraft, the things I used but didn't create myself are all the textures and gui sprites (all stolen from Minecraft directly), and CPML. I should give credit to CPML and I could change the textures to Minetest textures as you said, but Lovecraft is intended to be an open-source hobby project so I don't think Microsoft would cause me any problems regardless.
I'll do some research on the topic. Thanks again for your feedback.
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: groverburger's Super Simple 3D Engine

Post by pgimeno »

It's not really hard, a quick way is to just include a LICENSE.md or .txt in the repository with the copyright and the license text, and mention in every file that the license can be found there.

In the CPML directory you already include one: https://github.com/groverburger/lovecra ... LICENSE.md but that's the CPML license only, obviously. You can use it as a guide, but note that the authors have forgotten to comply with the BSD 2-clause license: https://github.com/Nition/UnityOctree/b ... er/LICENCE which also requires the license text to be reproduced. I've filed an issue about that in the CPML tracker.
User avatar
drikdrok
Prole
Posts: 36
Joined: Sun Mar 15, 2015 9:53 am
Contact:

Re: groverburger's Super Simple 3D Engine

Post by drikdrok »

Awesome stuff! This will be my goto library if I ever want to make a 3D game with Löve!

Can't wait for lighting and .obj import. Perhaps you could add collision handling too!
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: groverburger's Super Simple 3D Engine

Post by groverburger »

pgimeno wrote: Tue Feb 12, 2019 12:44 am It's not really hard, a quick way is to just include a LICENSE.md or .txt in the repository with the copyright and the license text, and mention in every file that the license can be found there.

In the CPML directory you already include one: https://github.com/groverburger/lovecra ... LICENSE.md but that's the CPML license only, obviously. You can use it as a guide, but note that the authors have forgotten to comply with the BSD 2-clause license: https://github.com/Nition/UnityOctree/b ... er/LICENCE which also requires the license text to be reproduced. I've filed an issue about that in the CPML tracker.
Thanks for the support! I'll make sure to do that when I migrate SS3D to github.
drikdrok wrote: Fri Feb 15, 2019 9:09 pm Awesome stuff! This will be my goto library if I ever want to make a 3D game with Löve!

Can't wait for lighting and .obj import. Perhaps you could add collision handling too!
Thanks for the compliments and feedback! I have some simple diffuse lighting working but it's not polished yet, it should be making its way into SS3D sometime soon. CPML has some really handy 3d line to triangle intersection functions that work well for collisions. I'll put collision handling on the todo list, but in the meantime here's a simple collision function I was testing using CPML.

The ray.direction represents where the object will be next frame, and the function tests if the line from where the object is now to where it is next frame intersects with any model in the CollisionList. It may still have some bugs.

Code: Select all

-- check for collisions, put add models you want to have collisions to the CollisionList
for i=1, #CollisionList do
    local pos = cpml.vec3.new(self.x,self.y,self.z)
    local ray = {}
    ray.position = cpml.vec3.new(0,0,0)
    ray.direction = cpml.vec3.new(0,self.ySpeed,0)

    local triangle = {}
    triangle[1] = cpml.vec3.new(CollisionList[i].verts[1]) - pos
    triangle[2] = cpml.vec3.new(CollisionList[i].verts[2]) - pos
    triangle[3] = cpml.vec3.new(CollisionList[i].verts[3]) - pos

    local intersection, distance = cpml.intersect.ray_triangle(ray, triangle)

    if intersection ~= false then
        print(intersection)

        if intersection:len() <= ray.direction:len() then
            -- COLLISION DETECTED!
        end
    end
end
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: groverburger's Super Simple 3D Engine

Post by monolifed »

You can use this free texture pack:
https://opengameart.org/node/91360
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's Super Simple 3D Engine - v1.2

Post by groverburger »

Proper licensing added to the repositories. Lovecraft and SS3D are both now under the MIT license.
skapunch
Prole
Posts: 1
Joined: Tue May 14, 2019 11:43 pm

Re: Groverburger's Super Simple 3D Engine - v1.2

Post by skapunch »

Hello there! I am a newbie.Thank you for sharing the 3D Engine.
i run the demo on my laptop (Onboard Intel HD Graphics 3000) and here are the results ( the 2nd pictures in which i commented out the FloorModel).At first i thought it was because of the driver and the dependencies (i tried running the demo on my desktop, which also uses an onboard and it works) so I tried updating my laptop's driver to the lastest and installing all the VC redists, Directx, etc. but the result is still the same. Any thought on this issue?

Image

Image
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests