GridMap orientation with set_cell_item

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By blum-o-matic

I don’t understand the orientation in the set_cell_item method:

set_cell_item ( int x, int y, int z, int item, int orientation=0 )

The documentation say:

Optionally, the item’s orientation can be passed.

For example: When i use 0 it is original. If i use 10 it is 180 degree rotated. In the source code of the engine there is p.rot used.

Maybe someone can me explain how to calculate the orientation?

:bust_in_silhouette: Reply From: blum-o-matic

It was hiding a bit in the docs but at the end i have found a way (180 degree rotation on y-axis):

 var myQuaternion = Quat(Vector3(0, 1, 0.0), deg2rad(180))
 var cell_item_orientation = Basis(myQuaternion).get_orthogonal_index())
 set_cell_item ( int x, int y, int z, int item, cell_item_orientation )

Code snippet… maybe this helps others. IMHO it should be pointed out in the docs :wink:

There’s an extra brackets in the code.

Line: 2
Col: 74

Check it.

sairam123 | 2020-10-22 19:33