def new_uninitialized_gdobj(gdtype): # TODO: use dict to optimize this ? # It seems Godot encode Variant as type nil... if gdtype == lib.GODOT_VARIANT_TYPE_NIL: return godot_variant_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_BOOL: return godot_bool_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_INT: return godot_int_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_REAL: return godot_real_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_STRING: return godot_string_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_VECTOR2: return godot_vector2_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_RECT2: return godot_rect2_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_VECTOR3: return godot_vector3_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_TRANSFORM2D: return godot_transform2d_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_PLANE: return godot_plane_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_QUAT: return godot_quat_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_AABB: return godot_aabb_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_BASIS: return godot_basis_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_TRANSFORM: return godot_transform_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_COLOR: return godot_color_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_NODE_PATH: return godot_node_path_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_RID: return godot_rid_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_OBJECT: return godot_object_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_DICTIONARY: return godot_dictionary_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_ARRAY: return godot_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY: return godot_pool_byte_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_INT_ARRAY: return godot_pool_int_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_REAL_ARRAY: return godot_pool_real_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_STRING_ARRAY: return godot_pool_string_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY: return godot_pool_vector2_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY: return godot_pool_vector3_array_alloc() elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY: return godot_pool_color_array_alloc() else: raise TypeError( "Unknown Variant type `%s` (this should never happen !)" % gdtype)
def build_from_rows(cls, row0, row1, row2): cls._check_param_type('row0', row0, Vector3) cls._check_param_type('row1', row1, Vector3) cls._check_param_type('row2', row2, Vector3) gd_ptr = godot_basis_alloc() lib.godot_basis_new_with_rows(gd_ptr, row0._gd_ptr, row1._gd_ptr, row2._gd_ptr) return cls.build_from_gdobj(gd_ptr, steal=True)
def __init__(self): # TODO: allow rows as param ? self._gd_ptr = godot_basis_alloc() x = godot_vector3_alloc() lib.godot_vector3_new(x, 1, 0, 0) y = godot_vector3_alloc() lib.godot_vector3_new(y, 0, 1, 0) z = godot_vector3_alloc() lib.godot_vector3_new(z, 0, 0, 1) lib.godot_basis_new_with_rows(self._gd_ptr, x, y, z)
def build_from_euler(cls, euler): gd_ptr = godot_basis_alloc() if isinstance(euler, Vector3): lib.godot_basis_new_with_euler(gd_ptr, euler._gd_ptr) elif isinstance(euler, Quat): lib.godot_basis_new_with_euler_quat(gd_ptr, euler._gd_ptr) else: raise TypeError("Param `euler` should be of type `%s`" % (Vector3, Quat)) return cls.build_from_gdobj(gd_ptr, steal=True)
def __init__(self): # TODO: allow rows as param ? self._gd_ptr = godot_basis_alloc()
def build_from_axis_and_angle(cls, axis, phi): cls._check_param_type('axis', axis, Vector3) cls._check_param_float('phi', phi) gd_ptr = godot_basis_alloc() lib.godot_basis_new_with_axis_and_angle(gd_ptr, axis._gd_ptr, phi) return cls.build_from_gdobj(gd_ptr, steal=True)
def _copy_gdobj(gdobj): return godot_basis_alloc(gdobj[0])