Groverburger's 3D Engine (G3D) New and Improved!

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

Groverburger's 3D Engine (G3D) New and Improved!

Post by groverburger » Mon Feb 11, 2019 11:13 am

Image

groverburger's 3D Engine (g3d) is my take on simplifying love 11's new 3d capabilities into a ready-to-use library for simple 3d games.

Get the latest version of g3d and a simple tutorial on the Github page here:
https://github.com/groverburger/g3d

g3d's demo in action:
Image

The entire code for the demo is only 30 lines:

Code: Select all

-- written by groverbuger for g3d
-- august 2020
-- MIT license

require "g3d"

function love.load()
    Earth = Model:new("assets/sphere.obj", "assets/earth.png", {0,0,4}, nil, {-1,1,1})
    Moon = Model:new("assets/sphere.obj", "assets/moon.png", {5,0,4}, nil, {-0.5,0.5,0.5})
    Background = Model:new("assets/soccerball.obj", "assets/skybox.png", {0,0,0}, nil, {500,500,500})
end

function love.mousemoved(x,y, dx,dy)
    FirstPersonCameraLook(dx,dy)
end

function love.update(dt)
    Timer = Timer and Timer + dt or 0
    Moon:setTranslation(math.cos(Timer)*5, 0, math.sin(Timer)*5 +4)
    Moon:setRotation(0,-1*Timer,0)
    FirstPersonCameraMovement(dt)
end

function love.draw()
    Earth:draw()
    Moon:draw()
    love.graphics.setWireframe(true)
    Background:draw()
    love.graphics.setWireframe(false)
end
Features:
- 3D Model rendering
- .obj file loading
- Basic first person movement and camera controls
- Perspective and orthographic projections
- Functions for simple collision handling
- Simple, commented, and organized

Installation:
Download g3d from Github and add the g3d folder to your project. Require the folder in your main.lua file.

Here's an example of what can be done with this engine.
This is a Minecraft clone I've been working on. I abstracted the engine I used for this project and that is what became G3D.
https://github.com/groverburger/lovecraft
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 Sep 11, 2020 6:14 am, edited 7 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 » Mon Feb 11, 2019 2:59 pm

Impressive work m8

User avatar
pgimeno
Party member
Posts: 2311
Joined: Sun Oct 18, 2015 2:58 pm

Re: groverburger's Super Simple 3D Engine

Post by pgimeno » 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).

User avatar
groverburger
Prole
Posts: 16
Joined: Tue Oct 30, 2018 9:27 pm

Re: groverburger's Super Simple 3D Engine

Post by groverburger » Mon Feb 11, 2019 11:49 pm

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: 2311
Joined: Sun Oct 18, 2015 2:58 pm

Re: groverburger's Super Simple 3D Engine

Post by pgimeno » 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.

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 » 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!

User avatar
groverburger
Prole
Posts: 16
Joined: Tue Oct 30, 2018 9:27 pm

Re: groverburger's Super Simple 3D Engine

Post by groverburger » Fri Feb 15, 2019 10:44 pm

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: 130
Joined: Sat Feb 06, 2016 9:42 pm

Re: groverburger's Super Simple 3D Engine

Post by monolifed » Fri Feb 15, 2019 11:13 pm

You can use this free texture pack:
https://opengameart.org/node/91360

User avatar
groverburger
Prole
Posts: 16
Joined: Tue Oct 30, 2018 9:27 pm

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

Post by groverburger » Mon Apr 01, 2019 7:45 am

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 » Wed May 15, 2019 6:24 am

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: Bing [Bot], Nelvin and 5 guests