Note to future people: if you want correct lighting on the cube, you need to have 4 unique vertices per face, and set the normals to be pointing out of the cube. So the top face would have 4 verts all with (0,1,0) normals, the bottom would have 4 verts with (0,-1,0) normals, etc. If you only use 8 verts for the whole cube, the lighting gets smoothed out over the faces, which you can see at the end of the video
@@thomaseubank1503 after dicking around too much you need a normal per vertice declared by the triangle. I guess it would be easier to fiddle with OpenGL at this point
Or much easier, just add surface_tool.set_smooth_group(-1) right after surface_tool.begin(). It turns smoothing off, so you don't have to manually set normals.
Try not to abbreviate variable names. If you teach this yourself, you will write code, that others are having a hard time to read. It's perfectly ok, to name surftool surfaceTool and a_mesh meshArray
Also if I'm not mistaken if someone adds mesh_instance.create_trimesh_collision() it will add a collider. Have to name it the name of the mesh not my mesh_instance have I named mine. Unless Godot 4 changed that
After you assign the array mesh to the mesh instance just call "create_trimesh_collision()" on the mesh instance it should work fine but for terrain you have a heightmap shape you should use instead IF your planning the generate terrain
Quality/Quantity of Godot videos best in gaming industry, better than that of Unity. I dream of the day when UNREAL decides to document completely. C# could not be as efficient as C++. The entire thing about GODOT is feasibility by the INDE , the other 2: UNITY, UNREAL might not be able to say the same for the INDE nor for the big teams. The open source of GODOT provides a long term dream by itself for the serious developer. Godot makes it possible to plan rather than make something first and then let's see attitude in the other 2.
In the video the complete code is illegible... The code to create the triangle: @tool extends MeshInstance3D @export var update = false func _ready(): gen_mesh() func _process(delta:float): if update: gen_mesh() func gen_mesh(): var a_mesh = ArrayMesh.new() var vertices := PackedVector3Array([ Vector3(0,0,0), Vector3(20,0,0), Vector3(20,0,20), ]) var indices := PackedInt32Array([0,1,2]) var array = [] array.resize(Mesh.ARRAY_MAX) array[Mesh.ARRAY_VERTEX] = vertices array[Mesh.ARRAY_INDEX] = indices a_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES,array) mesh = a_mesh You have to save the scene, then in the menu choose SCENE > RELOAD SAVED SCENE And finally, there is a triangle....
Is it possible to create or edit a mesh and adding/removing bones for a 3DSkeleton in Godot in Runtime? Like in Spore or with Creature Creator (made in unity), dragging a Node and creating new vertices with a corresponding bone (or any other useful Node)?
AHHHHG!!!!! what did you hide at 5:55 ????? you move too fast and didn't explain what "and we (pass that array??)" means or show what was typed or what the auto complete was. Also mesh = a_mesh just throws error Parser Error: Identifier "mesh" not declared in the current scope. If I add var mesh in the scope the preceding line then throws error Invalid type in function 'add_surface_from_arrays' in base 'ArrayMesh'. Cannot convert argument 2 from Object to Array. Seriously terrible tutorial - rushed, and poorly explained.
Sorry about that it was: a_mesh.add_surface_from_arrays(Mesh.PRIMATIVE_TRIANGLES,array) Its the array I assign the vertices and indices to at line 29 to 32.
I remember I did this exact exercise years ago at university except it was with opengl.
Note to future people: if you want correct lighting on the cube, you need to have 4 unique vertices per face, and set the normals to be pointing out of the cube. So the top face would have 4 verts all with (0,1,0) normals, the bottom would have 4 verts with (0,-1,0) normals, etc. If you only use 8 verts for the whole cube, the lighting gets smoothed out over the faces, which you can see at the end of the video
So I'd need 16 vector2? I don't get how I should set it up
@@freevbucks8019 Yeah I need more clarification too. I also am not fully sure if I understand how to set up which way the face is.
@@thomaseubank1503 after dicking around too much you need a normal per vertice declared by the triangle. I guess it would be easier to fiddle with OpenGL at this point
Or much easier, just add surface_tool.set_smooth_group(-1) right after surface_tool.begin(). It turns smoothing off, so you don't have to manually set normals.
Try not to abbreviate variable names. If you teach this yourself, you will write code, that others are having a hard time to read. It's perfectly ok, to name surftool surfaceTool and a_mesh meshArray
reload save scene at some point stop working for me and shape remain unchanged
I am trying to see if I can make a Doom style level editor in Godot 4. This was super helpful, thanks!
Also if I'm not mistaken if someone adds mesh_instance.create_trimesh_collision() it will add a collider. Have to name it the name of the mesh not my mesh_instance have I named mine. Unless Godot 4 changed that
After you assign the array mesh to the mesh instance just call "create_trimesh_collision()" on the mesh instance it should work fine but for terrain you have a heightmap shape you should use instead IF your planning the generate terrain
You can also do it from the editor dropdown as well if you used the generator script as a tool script.
Quality/Quantity of Godot videos best in gaming industry, better than that of Unity. I dream of the day when UNREAL decides to document completely. C# could not be as efficient as C++. The entire thing about GODOT is feasibility by the INDE , the other 2: UNITY, UNREAL might not be able to say the same for the INDE nor for the big teams. The open source of GODOT provides a long term dream by itself for the serious developer. Godot makes it possible to plan rather than make something first and then let's see attitude in the other 2.
Very helpful thank you. I might have some questions later lol
Sure, let me know what you need help with.
This is really cool. But I don't understand how UV mapped in godot why blender involved here and how material is applied using UV
I was just using blender to demonstrate what i was doing in Godot with the UVs
In the video the complete code is illegible...
The code to create the triangle:
@tool
extends MeshInstance3D
@export var update = false
func _ready():
gen_mesh()
func _process(delta:float):
if update:
gen_mesh()
func gen_mesh():
var a_mesh = ArrayMesh.new()
var vertices := PackedVector3Array([
Vector3(0,0,0),
Vector3(20,0,0),
Vector3(20,0,20),
])
var indices := PackedInt32Array([0,1,2])
var array = []
array.resize(Mesh.ARRAY_MAX)
array[Mesh.ARRAY_VERTEX] = vertices
array[Mesh.ARRAY_INDEX] = indices
a_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES,array)
mesh = a_mesh
You have to save the scene, then in the menu choose SCENE > RELOAD SAVED SCENE
And finally, there is a triangle....
Is it possible to create or edit a mesh and adding/removing bones for a 3DSkeleton in Godot in Runtime?
Like in Spore or with Creature Creator (made in unity), dragging a Node and creating new vertices with a corresponding bone (or any other useful Node)?
I would like to ask what could be the applications with this? Great tutorial btw.
You could use it to destroy terrains for instance
can you put the code in the comments for this. i put everything exactly as you typed but it still gives me errors, so i have no idea what im doing
Ive added the code to the description. But its for infinite terrain.
@Chevifier thanks, tho I wish it were the Code for this vid, I'll still see if I can use it to make something
any source code?
any problem if I try to replicate this in godot 3.5.x?
Maybe a few function differences but for the most part the process is the same
Why not use C# instead of gdscript? Isn't performance better with C#?
It definitely is better. But most users use the Regular Godot Engine and not the DotNet version.
You are my God by GODOT ;-)
promosm 💖
AHHHHG!!!!! what did you hide at 5:55 ?????
you move too fast and didn't explain what "and we (pass that array??)" means or show what was typed or what the auto complete was. Also mesh = a_mesh just throws error Parser Error: Identifier "mesh" not declared in the current scope. If I add var mesh in the scope the preceding line then throws error Invalid type in function 'add_surface_from_arrays' in base 'ArrayMesh'. Cannot convert argument 2 from Object to Array.
Seriously terrible tutorial - rushed, and poorly explained.
Sorry about that it was:
a_mesh.add_surface_from_arrays(Mesh.PRIMATIVE_TRIANGLES,array)
Its the array I assign the vertices and indices to at line 29 to 32.
it doesnt work on my end for some reason@@Chevifier
For future reference, pause the video and use the buttons to go frame by frame
@@bioman1hazard607 check if you have PackedFloat32Array instead of PackedInt32Array, it should be PackedInt32Array