Page 18 of 22

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

Posted: Wed Oct 12, 2022 12:28 pm
by pbmn
[/quote]
What kind of animations? Texture animation or model animation? For the first one, you can update the texture of a model every frame to change its texture for animations. For the second, look into the Hoarder's Horrible House of Stuff project. I believe it uses bones in its models to animate the main character. If I'm not mistaken.
[/quote]

oh I've already got Billboarding to work and also model animations, it was through Inter Quake Models, just needed to add that plugin to Blender, export then load them in LOVE, it wasn't that bad, just a bit confusing at first. Thanks so much for the reply BTW!

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

Posted: Fri Jan 13, 2023 12:15 am
by vico
Hello!

Just start playing around with g3d trying to make a simple voxel game, i have a question about models: do i need to load a .obj file or is possible to render basic shapes (like a cube) via pure code?

I have plans to create a text-based format for models (like Minecraft does using .json-like format) and i dont want to use .obj at all.

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

Posted: Fri Jan 13, 2023 2:00 pm
by Nikki
groverburger has made a basic voxel game here, you can check the way chunks are meshed here
https://github.com/groverburger/g3d_vox ... remesh.lua

and I think (not a real user of g3d though) you can either load obj files or feed the data directly, at least that's what the docs are saying here:
https://github.com/groverburger/g3d/wik ... tion-scale

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

Posted: Mon Jan 16, 2023 8:34 am
by vico
Nikki wrote: Fri Jan 13, 2023 2:00 pm groverburger has made a basic voxel game here, you can check the way chunks are meshed here
https://github.com/groverburger/g3d_vox ... remesh.lua

and I think (not a real user of g3d though) you can either load obj files or feed the data directly, at least that's what the docs are saying here:
https://github.com/groverburger/g3d/wik ... tion-scale
Thanks for the tips.

I actually checked the code from g3d_voxel, but i find it too much "complex" against my current understanding of the platform to extract meaningful information from it; i still in the step of trying to draw individual shapes on the screen, then slowly proceed to code the chunk format and so on. So, i really want to see, like a individual example of how it works (eg. model = g3d.newModel(<stuff to render a cube using pure text and not .objs>, texture, translation, rotation, scale);).

The reason i'm reluctant to use .obj format for the models is because in long-term i want to use a way similar to how Minecraft store its models (JSON), so that's why i refrain to rely on .obj at this height of my learning; i fear i will become too dependant of .objs that later when i will start ditching it altogether in favour of .json models i will really struggle to remake the entire rendering code.

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

Posted: Mon Jan 16, 2023 2:18 pm
by Hydrogen Maniac
vico wrote: Mon Jan 16, 2023 8:34 am So, i really want to see, like a individual example of how it works (eg. model = g3d.newModel(<stuff to render a cube using pure text and not .objs>, texture, translation, rotation, scale);).
Building a model using code is pretty straight forward. The below code creates a model of a plane.

Code: Select all

local verts = {
	{0,1,0, 0,0},
	{0,0,0, 0,1},
	{1,1,0, 1,0},

	{0,0,0, 0,1},
	{1,0,0, 1,1},
	{1,1,0, 1,0},
}
model = g3d.newModel(verts, "pathtotexture.png")
Each vertex is composed like this: {x,y,z, u,v} and three vertices in a row creates a triangle.

Note that the model might appear flipped or at an angle depending on what g3d.camera.up is set to and that the models' normals are determined by the order of the vertices.

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

Posted: Mon Jan 16, 2023 2:32 pm
by Rigachupe
Is there a way to add something like a light point so the faces of rendered models would not look so flat on screen?

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

Posted: Mon Jan 16, 2023 3:21 pm
by vico
Hydrogen Maniac wrote: Mon Jan 16, 2023 2:18 pm
vico wrote: Mon Jan 16, 2023 8:34 am So, i really want to see, like a individual example of how it works (eg. model = g3d.newModel(<stuff to render a cube using pure text and not .objs>, texture, translation, rotation, scale);).
Building a model using code is pretty straight forward. The below code creates a model of a plane.

Code: Select all

local verts = {
	{0,1,0, 0,0},
	{0,0,0, 0,1},
	{1,1,0, 1,0},

	{0,0,0, 0,1},
	{1,0,0, 1,1},
	{1,1,0, 1,0},
}
model = g3d.newModel(verts, "pathtotexture.png")
Each vertex is composed like this: {x,y,z, u,v} and three vertices in a row creates a triangle.

Note that the model might appear flipped or at an angle depending on what g3d.camera.up is set to and that the models' normals are determined by the order of the vertices.
Interesting. How could i make a cube model in that way?
Also, i think i can plug in a json library to load and save the models. That would be very similar to how Minecraft (and maybe Minetest, idk) store the models. Maybe in the future i can also try to implement a way to load Optifine's CEM models, that are JSON files that describe more details for entity animations.

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

Posted: Mon Jan 16, 2023 4:04 pm
by Hydrogen Maniac
vico wrote: Mon Jan 16, 2023 3:21 pm Interesting. How could i make a cube model in that way?
Since a cube is just six planes put togheter you can simply add the remaining sides to the above code snippet like so:

Code: Select all

local verts = {
	-- top
	{0,1,1, 0,0},
	{0,0,1, 0,1},
	{1,1,1, 1,0},
	
	{0,0,1, 0,1},
	{1,0,1, 1,1},
	{1,1,1, 1,0},

	-- bottom
	{0,0,0, 1,0},
	{0,1,0, 1,1},
	{1,1,0, 0,1},

	{1,0,0, 0,0},
	{0,0,0, 1,0},
	{1,1,0, 0,1},

	-- side 1
	{0,0,1, 0,0},
	{0,0,0, 0,1},
	{1,0,1, 1,0},

	{0,0,0, 0,1},
	{1,0,0, 1,1},
	{1,0,1, 1,0},

	-- side 2
	{0,1,0, 1,1},
	{0,1,1, 1,0},
	{1,1,1, 0,0},

	{1,1,0, 0,1},
	{0,1,0, 1,1},
	{1,1,1, 0,0},

	-- side 3
	{0,0,0, 1,1},
	{0,0,1, 1,0},
	{0,1,1, 0,0},

	{0,1,0, 0,1},
	{0,0,0, 1,1},
	{0,1,1, 0,0},

	-- side 4
	{1,0,1, 0,0},
	{1,0,0, 0,1},
	{1,1,1, 1,0},

	{1,0,0, 0,1},
	{1,1,0, 1,1},
	{1,1,1, 1,0},
}
model = g3d.newModel(verts, "pathtotexture.png")
I wrote the above code with g3d.camera.up set to {0,0,1} so the uv's might look a little off with the default settings.

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

Posted: Mon Jan 16, 2023 4:17 pm
by Hydrogen Maniac
Rigachupe wrote: Mon Jan 16, 2023 2:32 pm Is there a way to add something like a light point so the faces of rendered models would not look so flat on screen?
You can add all kinds of lighting effects using shaders. Groverburger shared a simple lighting shader earlier in the thread that might be to your liking:
viewtopic.php?f=5&t=86350&start=130

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

Posted: Mon Jan 16, 2023 4:55 pm
by Rigachupe
Thank you Hydrogen Maniac. I figured it out from the link. :)

EDIT:
1) There seems to be some sort of FOV problem with camera.lua. I replaced the fov value math.pi/2 to math.rad(60) and it looks better.
2) Also in init.lua calling love.graphics.setMeshCullMode("back") would be great, because normally you do not want to draw back faces for polygons to speed things up.