[SOLVED] how to simply create a polygon(convex) mesh ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Asoth

Hello, I figured ou how to make an octahedral shape with collision shape :

func _ready():
var array_of_positions = [........]
self.shape = ConvexPolygonShape.new()

but cannot make it with mesh, even manually it is not possible, is there a reason for this ?
(i tried to draw lines with immediate geometry but look like way too complicated)

:bust_in_silhouette: Reply From: Whypay

If you have a mesh already, you can create the collision shape like this:

Click on a mesh instance in editor, and there will show up a button Mesh (in top line near Transform and View), where you can create Trimesh Static body and Convex static body.

In code, it looks like this:

var oMeshInstance = get_node("/root/scene" + sMesh)

thank you whypay for your answer, I see now what I was missing.
I don’t have a mesh, so is there a way to "make godot create based on just an array of points ?

I am just working on collisions now with simples convex and I just want to visualise them to check behaviour.

from an array of points, to get a mesh I would need to add an additional array of faces (3points), right ?
considering I have just convex polygon , does any available tool in godot can do it for me ? I don t care about material stuff

Asoth | 2018-09-27 22:53

What kind of mesh shape do you need?
If its a simple shape, you can first create a MeshInstance, then you add a Mesh (just click on Mesh in MeshInstance). You can choose from predefined shapes (e.g. QuadMesh, or CubeMesh). These can be modified with parameters (height, width etc.).
If you need some points, you can add a ArrayMesh, I suppose, and create your own faces (add_surface_from_arrays).
You can also import meshes from other 3d apps, like blender or 3ds max.

You can also make your collision shapes visible in Debug menu.

Whypay | 2018-09-28 06:25

it is octahedron shapes I want to render, which is not available in the suggested primitive mesh in the editor.

ArrayMesh only offer me to make Custom Aabb shape.
since it look really strait forward to make a convex polygon with CollisionShape node I expected the same from mesh.

Make collision shape visible is processed (I think) at the beginning and happens before I configure my polygon (by code). so it doesn’t work for me.

Since I only deal with basic polygons I wish I could not have to deal with other “mesh” software like blender.

if I use add_surface_from_arrays I have to define manually which vertices define each face , right ? I cannot just throw all my points and let godot define the faces.

Asoth | 2018-09-29 00:02

If you debug with “Visible collisoion shapes”, the collision shapes are visible once you create them - in the editor or by code. I use create_trimesh_collision() in code on level load, and the collsion shapes are visible for me.

You can create a sphere mesh, set Radial Segments to 4, and Rings to 1, then you have an octahedron.

Select your object, then click on the “Mesh” button in top menu and select “Create Trimesh Static Body”, this will add collsion shapes and rigid body.

Whypay | 2018-09-29 18:09