Initial version
This commit is contained in:
commit
f1c7e80c51
30 changed files with 4508 additions and 0 deletions
145
godot/core/arrays.nim
Normal file
145
godot/core/arrays.nim
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import hashes
|
||||
import godotbase, poolarray, variant, strings
|
||||
|
||||
proc initArray(dest: var Array) {.
|
||||
importc: "godot_array_new", header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pca: PoolColorArray) {.
|
||||
importc: "godot_array_new_pool_coloarray",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pv3a: PoolVector3Array) {.
|
||||
importc: "godot_array_new_pool_vector3_array",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pv2a: PoolVector2Array) {.
|
||||
importc: "godot_array_new_pool_vector2_array",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; psa: PoolStringArray) {.
|
||||
importc: "godot_array_new_pool_string_array",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pra: PoolRealArray) {.
|
||||
importc: "godot_array_new_pool_real_array",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pia: PoolIntArray) {.
|
||||
importc: "godot_array_new_pool_int_array",
|
||||
header: "godot_array.h".}
|
||||
proc initArray(dest: var Array; pba: PoolByteArray) {.
|
||||
importc: "godot_array_new_pool_byte_array",
|
||||
header: "godot_array.h".}
|
||||
|
||||
proc initArray*(): Array {.inline.} =
|
||||
initArray(result)
|
||||
|
||||
proc initArray*(pca: PoolColorArray): Array {.inline.} =
|
||||
initArray(result, pca)
|
||||
|
||||
proc initArray*(pv3a: PoolVector3Array): Array {.inline.} =
|
||||
initArray(result, pv3a)
|
||||
|
||||
proc initArray*(pv2a: PoolVector2Array): Array {.inline.} =
|
||||
initArray(result, pv2a)
|
||||
|
||||
proc initArray*(psa: PoolStringArray): Array {.inline.} =
|
||||
initArray(result, psa)
|
||||
|
||||
proc initArray*(pra: PoolRealArray): Array {.inline.} =
|
||||
initArray(result, pra)
|
||||
|
||||
proc initArray*(pia: PoolIntArray): Array {.inline.} =
|
||||
initArray(result, pia)
|
||||
|
||||
proc initArray*(pba: PoolByteArray): Array {.inline.} =
|
||||
initArray(result, pba)
|
||||
|
||||
proc `[]=`*(self: var Array; idx: cint;
|
||||
value: Variant) {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_set", header: "godot_array.h".}
|
||||
proc `[]`*(self: Array; idx: cint): Variant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_get", header: "godot_array.h".}
|
||||
proc mget*(self: var Array; idx: cint): ptr Variant {.
|
||||
importc: "godot_array_operator_index", header: "godot_array.h".}
|
||||
|
||||
proc add*(self: var Array; value: Variant) {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_append", header: "godot_array.h".}
|
||||
proc clear*(self: var Array) {.importc: "godot_array_clear",
|
||||
header: "godot_array.h".}
|
||||
proc count*(self: Array; value: Variant): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_count", header: "godot_array.h".}
|
||||
proc isEmpty*(self: Array): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_empty", header: "godot_array.h".}
|
||||
proc erase*(self: var Array; value: Variant) {.
|
||||
importc: "godot_array_erase", header: "godot_array.h".}
|
||||
proc first*(self: Array): Variant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_front", header: "godot_array.h".}
|
||||
proc last*(self: Array): Variant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_back", header: "godot_array.h".}
|
||||
proc find*(self: Array; what: Variant;
|
||||
f: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_find", header: "godot_array.h".}
|
||||
proc findLast*(self: Array; what: Variant): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_find_last", header: "godot_array.h".}
|
||||
proc contains*(self: Array; value: Variant): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_has", header: "godot_array.h".}
|
||||
|
||||
proc godotHash*(self: Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_hash", header: "godot_array.h".}
|
||||
proc hash*(self: Array): Hash {.inline.} =
|
||||
hash(godotHash(self))
|
||||
|
||||
proc insert*(self: var Array; pos: cint;
|
||||
value: Variant) {.
|
||||
importc: "godot_array_insert", header: "godot_array.h".}
|
||||
proc reverse*(self: var Array) {.importc: "godot_array_invert",
|
||||
header: "godot_array.h".}
|
||||
proc popLast*(self: var Array): Variant {.
|
||||
importc: "godot_array_pop_back", header: "godot_array.h".}
|
||||
proc popFirst*(self: var Array): Variant {.
|
||||
importc: "godot_array_pop_front", header: "godot_array.h".}
|
||||
proc addLast*(self: var Array; value: Variant) {.
|
||||
importc: "godot_array_push_back", header: "godot_array.h".}
|
||||
proc addFirst*(self: var Array; value: Variant) {.
|
||||
importc: "godot_array_push_front", header: "godot_array.h".}
|
||||
|
||||
proc delete*(self: var Array; idx: cint) {.
|
||||
importc: "godot_array_remove", header: "godot_array.h".}
|
||||
proc setLen*(self: var Array; size: cint) {.
|
||||
importc: "godot_array_resize", header: "godot_array.h".}
|
||||
proc rfind*(self: Array; what: Variant;
|
||||
f: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_rfind", header: "godot_array.h".}
|
||||
proc len*(self: Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_size", header: "godot_array.h".}
|
||||
proc sort*(self: var Array) {.importc: "godot_array_sort",
|
||||
header: "godot_array.h".}
|
||||
proc sortCustom*(self: var Array; obj: var GodotObject;
|
||||
funcName: GodotString) {.
|
||||
importc: "godot_array_sort_custom", header: "godot_array.h".}
|
||||
|
||||
iterator items*(arr: Array): Variant =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator mitems*(arr: var Array): var Variant =
|
||||
for i in 0..<arr.len:
|
||||
yield arr.mget(i)[]
|
||||
|
||||
iterator pairs*(arr: Array): tuple[key: cint, val: Variant] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
iterator mpairs*(arr: var Array): tuple[key: cint, val: var Variant] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr.mget(i)[])
|
||||
140
godot/core/basis.nim
Normal file
140
godot/core/basis.nim
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, vector3, quat, strings
|
||||
|
||||
type
|
||||
Basis* {.importc: "godot_basis", header: "godot_basis.h", byref.} = object
|
||||
|
||||
proc initBasis(dest: var Basis) {.importc: "godot_basis_new",
|
||||
header: "godot_basis.h".}
|
||||
proc initBasis(dest: var Basis;
|
||||
xAxis: Vector3;
|
||||
yAxis: Vector3;
|
||||
zAxis: Vector3) {.
|
||||
importc: "godot_basis_new_with_rows", header: "godot_basis.h".}
|
||||
proc initBasis(dest: var Basis;
|
||||
euler: Quat) {.
|
||||
importc: "godot_basis_new_with_euler_quat", header: "godot_basis.h".}
|
||||
proc initBasis(dest: var Basis; axis: Vector3; phi: float32) {.
|
||||
importc: "godot_basis_new_with_axis_and_angle", header: "godot_basis.h".}
|
||||
proc initBasis(dest: var Basis; euler: Vector3) {.
|
||||
importc: "godot_basis_new_with_euler", header: "godot_basis.h".}
|
||||
|
||||
proc initBasis*(): Basis {.inline.} =
|
||||
initBasis(result)
|
||||
|
||||
proc initBasis*(xAxis, yAxis, zAxis: Vector3): Basis {.inline.} =
|
||||
initBasis(result, xAxis, yAxis, zAxis)
|
||||
|
||||
proc initBasis*(euler: Quat): Basis {.inline.} =
|
||||
initBasis(result, euler)
|
||||
|
||||
proc initBasis*(axis: Vector3, phi: float32): Basis {.inline.} =
|
||||
initBasis(result, axis, phi)
|
||||
|
||||
proc initBasis*(euler: Vector3): Basis {.inline.} =
|
||||
initBasis(result, euler)
|
||||
|
||||
proc toGodotString*(self: Basis): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_as_string", header: "godot_basis.h".}
|
||||
|
||||
proc `$`*(self: Basis): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc inverse*(self: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_inverse", header: "godot_basis.h".}
|
||||
proc transposed*(self: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_transposed", header: "godot_basis.h".}
|
||||
proc orthonormalized*(self: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_orthonormalized", header: "godot_basis.h".}
|
||||
proc determinant*(self: Basis): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_determinant", header: "godot_basis.h".}
|
||||
proc rotated*(self: Basis; axis: Vector3;
|
||||
phi: float32): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_rotated", header: "godot_basis.h".}
|
||||
proc scaled*(self: Basis; scale: Vector3): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_scaled", header: "godot_basis.h".}
|
||||
|
||||
proc setScale*(self: var Basis; scale: Vector3) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_set_scale", header: "godot_basis.h".}
|
||||
proc setRotationEuler*(self: var Basis;
|
||||
euler: Vector3) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_set_rotation_euler", header: "godot_basis.h".}
|
||||
proc setRotationAxisAngle*(self: var Basis; axis: Vector3; angle: float32) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_set_rotation_axis_angle", header: "godot_basis.h".}
|
||||
|
||||
proc scale*(self: Basis): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_scale", header: "godot_basis.h".}
|
||||
proc euler*(self: Basis): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_euler", header: "godot_basis.h".}
|
||||
|
||||
proc tdotx*(self: Basis; x: Vector3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_tdotx", header: "godot_basis.h".}
|
||||
proc tdoty*(self: Basis; y: Vector3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_tdoty", header: "godot_basis.h".}
|
||||
proc tdotz*(self: Basis; z: Vector3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_tdotz", header: "godot_basis.h".}
|
||||
|
||||
proc xform*(self: Basis; v: Vector3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_xform", header: "godot_basis.h".}
|
||||
proc xformInv*(self: Basis; v: Vector3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_xform_inv", header: "godot_basis.h".}
|
||||
|
||||
proc orthogonalIndex*(self: Basis): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_orthogonal_index", header: "godot_basis.h".}
|
||||
|
||||
proc godot_basis_get_elements(self: Basis;
|
||||
elements: var array[3, Vector3]) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_elements", header: "godot_basis.h".}
|
||||
|
||||
proc elements*(self: Basis): array[3, Vector3] {.inline.} =
|
||||
godot_basis_get_elements(self, result)
|
||||
|
||||
proc `[]`*(self: Basis; axis: range[0..2]): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_axis", header: "godot_basis.h".}
|
||||
proc `[]=`*(self: var Basis; axis: range[0..2];
|
||||
value: Vector3) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_set_axis", header: "godot_basis.h".}
|
||||
proc row*(self: Basis; row: cint): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_get_row", header: "godot_basis.h".}
|
||||
proc setRow*(self: var Basis; row: cint;
|
||||
value: Vector3) {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_set_row", header: "godot_basis.h".}
|
||||
proc `==`*(self: Basis; b: Basis): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_operator_equal", header: "godot_basis.h".}
|
||||
proc `+`*(self: Basis; b: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_operator_add", header: "godot_basis.h".}
|
||||
proc `-`*(self: Basis; b: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_operator_substract", header: "godot_basis.h".}
|
||||
proc `*`*(self: Basis; b: Basis): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_operator_multiply_vector", header: "godot_basis.h".}
|
||||
proc `*`*(self: Basis; b: float32): Basis {.
|
||||
noSideEffect,
|
||||
importc: "godot_basis_operator_multiply_scalar", header: "godot_basis.h".}
|
||||
76
godot/core/color.nim
Normal file
76
godot/core/color.nim
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, strings
|
||||
|
||||
type
|
||||
Color* {.importc: "godot_color", header: "godot_color.h", byref.} = object
|
||||
|
||||
proc initColor(dest: var Color; r, g, b, a: float32) {.
|
||||
importc: "godot_color_new_rgba", header: "godot_color.h".}
|
||||
proc initColor(dest: var Color; r, g, b: float32) {.
|
||||
importc: "godot_color_new_rgb",
|
||||
header: "godot_color.h".}
|
||||
|
||||
proc initColor*(r, g, b, a: float32): Color {.inline.} =
|
||||
initColor(result, r, g, b, a)
|
||||
|
||||
proc initColor*(r, g, b: float32): Color {.inline.} =
|
||||
initColor(result, r, g, b)
|
||||
|
||||
proc r*(self: Color): float32 {.
|
||||
importc: "godot_color_get_r", header: "godot_color.h".}
|
||||
proc `r=`*(self: var Color; r: float32) {.
|
||||
importc: "godot_color_set_r", header: "godot_color.h".}
|
||||
proc g*(self: Color): float32 {.
|
||||
importc: "godot_color_get_g", header: "godot_color.h".}
|
||||
proc `g=`*(self: var Color; g: float32) {.
|
||||
importc: "godot_color_set_g", header: "godot_color.h".}
|
||||
proc b*(self: Color): float32 {.
|
||||
importc: "godot_color_get_b", header: "godot_color.h".}
|
||||
proc `b=`*(self: var Color; b: float32) {.
|
||||
importc: "godot_color_set_b", header: "godot_color.h".}
|
||||
proc a*(self: Color): float32 {.
|
||||
importc: "godot_color_get_a", header: "godot_color.h".}
|
||||
proc `a=`*(self: var Color; a: float32) {.
|
||||
importc: "godot_color_set_a", header: "godot_color.h".}
|
||||
|
||||
proc h*(self: Color): float32 {.
|
||||
importc: "godot_color_get_h", header: "godot_color.h".}
|
||||
proc s*(self: Color): float32 {.
|
||||
importc: "godot_color_get_s", header: "godot_color.h".}
|
||||
proc v*(self: Color): float32 {.
|
||||
importc: "godot_color_get_v", header: "godot_color.h".}
|
||||
|
||||
proc toGodotString*(self: Color): GodotString {.
|
||||
importc: "godot_color_as_string", header: "godot_color.h".}
|
||||
proc `$`*(self: Color): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc toHtml*(self: Color; with_alpha: bool): GodotString {.
|
||||
importc: "godot_color_to_html", header: "godot_color.h".}
|
||||
|
||||
proc to32CInt(self: Color): cint {.
|
||||
importc: "godot_color_to_32", header: "godot_color.h".}
|
||||
proc toARGB32CInt(self: Color): cint {.
|
||||
importc: "godot_color_to_ARGB32", header: "godot_color.h".}
|
||||
|
||||
proc to32*(self: Color): uint32 {.inline.}=
|
||||
cast[uint32](to32CInt(self))
|
||||
proc toARGB32*(self: Color): uint32 {.inline.} =
|
||||
cast[uint32](toARGB32CInt(self))
|
||||
|
||||
proc gray*(self: Color): float32 {.
|
||||
importc: "godot_color_gray", header: "godot_color.h".}
|
||||
proc inverted*(self: Color): Color {.
|
||||
importc: "godot_color_inverted", header: "godot_color.h".}
|
||||
proc contrasted*(self: Color): Color {.
|
||||
importc: "godot_color_contrasted", header: "godot_color.h".}
|
||||
proc lerp*(self: Color; b: Color; t: float32): Color {.
|
||||
importc: "godot_color_linear_interpolate", header: "godot_color.h".}
|
||||
proc blend*(self: Color; over: Color): Color {.
|
||||
importc: "godot_color_blend", header: "godot_color.h".}
|
||||
|
||||
proc `==`*(self, b: Color): bool {.
|
||||
importc: "godot_color_operator_equal", header: "godot_color.h".}
|
||||
proc `<`*(self, b: Color): bool {.
|
||||
importc: "godot_color_operator_less", header: "godot_color.h".}
|
||||
81
godot/core/dictionary.nim
Normal file
81
godot/core/dictionary.nim
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import hashes
|
||||
import godotbase, arrays, variant, strings
|
||||
|
||||
type
|
||||
Dictionary* {.importc: "godot_dictionary",
|
||||
header: "godot_dictionary.h", byref.} = object
|
||||
|
||||
proc initDictionary(dest: var Dictionary;
|
||||
src: Dictionary) {.
|
||||
importc: "godot_dictionary_new_copy",
|
||||
header: "godot_dictionary.h".}
|
||||
|
||||
proc deinit(self: var Dictionary) {.
|
||||
importc: "godot_dictionary_destroy", header: "godot_dictionary.h".}
|
||||
|
||||
proc `=`(self: var Dictionary, other: Dictionary) {.inline.} =
|
||||
initDictionary(self, other)
|
||||
|
||||
proc `=destroy`(self: Dictionary) {.inline.} =
|
||||
unsafeAddr(self)[].deinit()
|
||||
|
||||
proc initDictionary(dest: var Dictionary) {.
|
||||
importc: "godot_dictionary_new", header: "godot_dictionary.h".}
|
||||
proc initDictionary*(): Dictionary {.inline.} =
|
||||
initDictionary(result)
|
||||
|
||||
proc len*(self: Dictionary): cint {.
|
||||
importc: "godot_dictionary_size", header: "godot_dictionary.h".}
|
||||
proc isEmpty*(self: Dictionary): bool {.
|
||||
importc: "godot_dictionary_empty", header: "godot_dictionary.h".}
|
||||
proc clear*(self: var Dictionary) {.
|
||||
importc: "godot_dictionary_clear", header: "godot_dictionary.h".}
|
||||
proc contains*(self: Dictionary; key: Variant): bool {.
|
||||
importc: "godot_dictionary_has",
|
||||
header: "godot_dictionary.h".}
|
||||
proc contains*(self: Dictionary; keys: Array): bool {.
|
||||
importc: "godot_dictionary_has_all",
|
||||
header: "godot_dictionary.h".}
|
||||
proc del*(self: var Dictionary; key: Variant) {.
|
||||
importc: "godot_dictionary_erase", header: "godot_dictionary.h".}
|
||||
|
||||
proc godotHash*(self: Dictionary): cint {.
|
||||
importc: "godot_dictionary_hash", header: "godot_dictionary.h".}
|
||||
proc hash*(self: Dictionary): Hash {.inline.} =
|
||||
hash(godotHash(self))
|
||||
|
||||
proc keys*(self: Dictionary): Array {.
|
||||
importc: "godot_dictionary_keys", header: "godot_dictionary.h".}
|
||||
proc values*(self: Dictionary): Array {.
|
||||
importc: "godot_dictionary_values", header: "godot_dictionary.h".}
|
||||
proc `[]`*(self: Dictionary; key: Variant): Variant {.
|
||||
importc: "godot_dictionary_get", header: "godot_dictionary.h".}
|
||||
proc `[]=`*(self: var Dictionary; key, value: Variant) {.
|
||||
importc: "godot_dictionary_set",
|
||||
header: "godot_dictionary.h".}
|
||||
proc mget*(self: var Dictionary; key: Variant): ptr Variant {.
|
||||
importc: "godot_dictionary_operator_index",
|
||||
header: "godot_dictionary.h".}
|
||||
|
||||
proc `==`*(self, other: Dictionary): bool {.
|
||||
importc: "godot_dictionary_operator_equal",
|
||||
header: "godot_dictionary.h".}
|
||||
|
||||
proc toJson*(self: Dictionary): GodotString {.
|
||||
importc: "godot_dictionary_to_json", header: "godot_dictionary.h".}
|
||||
|
||||
iterator keys*(dict: Dictionary): Variant =
|
||||
let keyArr = dict.keys()
|
||||
for key in keyArr:
|
||||
yield key
|
||||
|
||||
iterator values*(dict: Dictionary): Variant =
|
||||
let valArr = dict.values()
|
||||
for val in valArr:
|
||||
yield val
|
||||
|
||||
iterator pairs*(dict: Dictionary): tuple[key, val: Variant] =
|
||||
for key in keys(dict):
|
||||
yield (key, dict[key])
|
||||
107
godot/core/godotbase.nim
Normal file
107
godot/core/godotbase.nim
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
Error* {.importc: "godot_error", header: "../godot.h",
|
||||
size: sizeof(cint), pure.} = enum
|
||||
OK,
|
||||
Failed, ## Generic fail error
|
||||
Unavailable, ## What is requested is unsupported/unavailable
|
||||
Unconfigured, ## The object being used hasnt been properly set up yet
|
||||
Unauthorized, ## Missing credentials for requested resource
|
||||
ParameterRangeError, ## Parameter given out of range (5)
|
||||
OutOfMemory, ## Out of memory
|
||||
FileNotFound,
|
||||
FileBadDrive,
|
||||
FileBadPath,
|
||||
FileNoPermission, ## (10)
|
||||
FileAlreadyInUse,
|
||||
FileCantOpen,
|
||||
FileCantWrite,
|
||||
FileCantRead,
|
||||
FileUnrecognized, ## (15)
|
||||
FileCorrupt,
|
||||
FileMissingDependencies,
|
||||
FileEOF,
|
||||
CantOpen, ## Can't open a resource/socket/file
|
||||
CantCreate, ## (20)
|
||||
QueryFailed,
|
||||
AlreadyInUse,
|
||||
Locked, ## resource is locked
|
||||
Timeout,
|
||||
CantConnect, ## (25)
|
||||
CantResolve,
|
||||
ConnectionError,
|
||||
CantAquireResource,
|
||||
CantFork,
|
||||
InvalidData, ## Data passed is invalid (30)
|
||||
InvalidParameter, ## Parameter passed is invalid
|
||||
AlreadyExists, ## When adding, item already exists
|
||||
DoesNotExist, ## When retrieving/erasing, it item does not exist
|
||||
DatabaseCantRead, ## Database is full
|
||||
DatabaseCantWrite, ## Database is full (35)
|
||||
CompilationFailed,
|
||||
MethodNotFound,
|
||||
LinkFailed,
|
||||
ScriptFailed,
|
||||
CyclicLink, ## (40)
|
||||
InvalidDeclaration,
|
||||
DuplicateSymbol,
|
||||
PauseError,
|
||||
Busy,
|
||||
Skip, ## (45)
|
||||
Help, ## user requested help!!
|
||||
Bug,
|
||||
## a bug in the software certainly happened, due to a double
|
||||
## check failing or unexpected behavior.
|
||||
PrinterOnFire, ## the parallel port printer is engulfed in flames
|
||||
WTF ## shit happens, has never been used, though
|
||||
|
||||
const MAX_ARG_COUNT* = 128
|
||||
|
||||
type
|
||||
GodotObject* {.importc: "godot_object", header: "../godot.h".} = object
|
||||
Array* {.importc: "godot_array", header: "godot_array.h", byref.} = object
|
||||
Variant* {.importc: "godot_variant",
|
||||
header: "godot_variant.h", byref.} = object
|
||||
|
||||
proc initArray(dest: var Array, src: Array) {.
|
||||
importc: "godot_array_new_copy",
|
||||
header: "godot_array.h".}
|
||||
|
||||
proc deinit(self: var Array) {.importc: "godot_array_destroy",
|
||||
header: "godot_array.h".}
|
||||
|
||||
proc `=`(self: var Array, other: Array) {.inline.} =
|
||||
initArray(self, other)
|
||||
|
||||
proc `=destroy`(self: Array) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc initVariant(dest: var Variant; src: Variant) {.
|
||||
importc: "godot_variant_new_copy", header: "godot_variant.h".}
|
||||
|
||||
proc deinit*(self: var Variant) {.
|
||||
importc: "godot_variant_destroy", header: "godot_variant.h".}
|
||||
|
||||
proc `=`(self: var Variant, other: Variant) {.inline.} =
|
||||
initVariant(self, other)
|
||||
|
||||
proc `=destroy`(self: Variant) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
# System Functions
|
||||
|
||||
proc godotAlloc*(bytes: cint): pointer {.
|
||||
importc: "godot_alloc", header: "../godot.h".}
|
||||
## Allocates the specified number of bytes.
|
||||
## Using this instead of stdlib proc will help Godot track how much memory
|
||||
## is in use in debug mode.
|
||||
proc godotRealloc*(p: pointer; bytes: cint): pointer {.
|
||||
importc: "godot_realloc", header: "../godot.h".}
|
||||
## Reallocates the pointer for the specified number of bytes.
|
||||
## Using this instead of stdlib proc will help Godot track how much memory
|
||||
## is in use in debug mode.
|
||||
proc godotFree*(p: pointer) {.importc: "godot_free", header: "../godot.h".}
|
||||
## Frees the memory pointed to by the pointer.
|
||||
## Using this instead of stdlib proc will help Godot track how much memory
|
||||
## is in use in debug mode.
|
||||
296
godot/core/godotcore.nim
Normal file
296
godot/core/godotcore.nim
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase
|
||||
import strings, vector2, rect2, vector3, transform2d, plane, quat
|
||||
import rect3, basis, transform, color, nodepath, rid
|
||||
import dictionary, arrays, poolarray, variant
|
||||
|
||||
export godotbase, strings, vector2, rect2, vector3, transform2d, plane, quat,
|
||||
rect3, basis, transform, color, nodepath, rid, dictionary, arrays,
|
||||
poolarray, variant
|
||||
|
||||
# MethodBind API
|
||||
|
||||
type
|
||||
GodotMethodBind* {.importc: "godot_method_bind",
|
||||
header: "../godot.h".} = object
|
||||
|
||||
proc getMethod*(className: cstring; methodName: cstring): ptr GodotMethodBind {.
|
||||
importc: "godot_method_bind_get_method", header: "../godot.h".}
|
||||
proc ptrCall*(methodBind: ptr GodotMethodBind;
|
||||
instance: ptr GodotObject;
|
||||
args: ptr array[MAX_ARG_COUNT, pointer];
|
||||
ret: pointer) {.
|
||||
importc: "godot_method_bind_ptrcall", header: "../godot.h".}
|
||||
proc call*(methodBind: ptr GodotMethodBind;
|
||||
instance: ptr GodotObject;
|
||||
args: ptr array[MAX_ARG_COUNT, Variant]; argCount: cint;
|
||||
callError: var VariantCallError): Variant {.
|
||||
importc: "godot_method_bind_call", header: "../godot.h".}
|
||||
|
||||
var getClassMethodBind {.threadvar.}: ptr GodotMethodBind
|
||||
proc getClassName*(o: ptr GodotObject): string =
|
||||
if getClassMethodBind.isNil:
|
||||
getClassMethodBind = getMethod(cstring"Object", cstring"get_class")
|
||||
var ret: GodotString
|
||||
getClassMethodBind.ptrCall(o, nil, addr ret)
|
||||
result = $ret
|
||||
|
||||
# Script API
|
||||
|
||||
type
|
||||
GodotNativeInitOptions* {.importc: "godot_native_init_options",
|
||||
header: "../godot.h".} = object
|
||||
inEditor* {.importc: "in_editor".}: bool
|
||||
coreApiHash* {.importc: "core_api_hash".}: uint64
|
||||
editorApiHash* {.importc: "editor_api_hash".}: uint64
|
||||
noApiHash* {.importc: "no_api_hash".}: uint64
|
||||
|
||||
GodotNativeTerminateOptions* {.importc: "godot_native_terminate_options",
|
||||
header: "../godot.h".} = object
|
||||
inEditor* {.importc: "in_editor".}: bool
|
||||
|
||||
GodotMethodRPCMode* {.importc: "godot_method_rpc_mode", header: "../godot.h",
|
||||
size: sizeof(cint), pure.} = enum
|
||||
Disabled,
|
||||
Remote,
|
||||
Sync,
|
||||
Master,
|
||||
Slave
|
||||
|
||||
GodotMethodAttributes* {.importc: "godot_method_attributes",
|
||||
header: "../godot.h".} = object
|
||||
rpcMode* {.importc: "rpc_type".}: GodotMethodRPCMode
|
||||
|
||||
GodotPropertyHint* {.importc: "godot_property_hint", header: "../godot.h",
|
||||
size: sizeof(cint), pure.} = enum
|
||||
None, ## no hint provided.
|
||||
Range, ## hint_text = "min,max,step,slider; // slider is optional"
|
||||
ExpRange, ## hint_text = "min,max,step", exponential edit
|
||||
Enum, ## hint_text= "val1,val2,val3,etc"
|
||||
ExpEasing, ## exponential easing funciton (Math::ease)
|
||||
Length, ## hint_text= "length" (as integer)
|
||||
SpriteFrame,
|
||||
KeyAccel, ## hint_text= "length" (as integer)
|
||||
Flags, ## hint_text= "flag1,flag2,etc" (as bit flags)
|
||||
Layers2DRender,
|
||||
Layers2DPhysics,
|
||||
Layers3DRender,
|
||||
Layers3DPhysics,
|
||||
File, ## a file path must be passed, hint_text (optionally)
|
||||
## is a filter "*.png,*.wav,*.doc,"
|
||||
Dir, ## a directort path must be passed
|
||||
GlobalFile, ## a file path must be passed, hint_text (optionally) is a
|
||||
## filter "*.png,*.wav,*.doc,"
|
||||
GlobalDir, ## a directort path must be passed
|
||||
ResourceType, ## a resource object type
|
||||
MultilineText, ## used for string properties that can contain multiple lines
|
||||
ColorNoAlpha, ## used for ignoring alpha component when editing a color
|
||||
ImageCompressLossy,
|
||||
ImageCompressLossless,
|
||||
ObjectId,
|
||||
TypeString, ## a type string, the hint is the base type to choose
|
||||
NodePathToEditedNode, ## so something else can provide this
|
||||
## (used in scripts)
|
||||
MethodOfVariantType, ## a method of a type
|
||||
MethodOfBaseType, ## a method of a base type
|
||||
MethodOfInstance, ## a method of an instance
|
||||
MethodOfScript, ## a method of a script & base
|
||||
PropertyOfVariantType, ## a property of a type
|
||||
PropertyOfBaseType, ## a property of a base type
|
||||
PropertyOfInstance, ## a property of an instance
|
||||
PropertyOfScript, ## a property of a script & base
|
||||
PropertyHintMax
|
||||
|
||||
const
|
||||
GODOT_PROPERTY_USAGE_STORAGE_VALUE = 1.cint
|
||||
GODOT_PROPERTY_USAGE_EDITOR_VALUE = 2.cint
|
||||
GODOT_PROPERTY_USAGE_NETWORK_VALUE = 4.cint
|
||||
GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE = 8.cint
|
||||
GODOT_PROPERTY_USAGE_CHECKABLE_VALUE = 16.cint
|
||||
GODOT_PROPERTY_USAGE_CHECKED_VALUE = 32.cint
|
||||
GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE = 64.cint
|
||||
GODOT_PROPERTY_USAGE_GROUP_VALUE = 128.cint
|
||||
GODOT_PROPERTY_USAGE_CATEGORY_VALUE = 256.cint
|
||||
GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE = 512.cint
|
||||
GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE = 1024.cint
|
||||
GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE = 2048.cint
|
||||
GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE = 4096.cint
|
||||
GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE = 8192.cint
|
||||
GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE = 16384.cint
|
||||
GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE = 32768.cint
|
||||
GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE = 65536.cint
|
||||
|
||||
GODOT_PROPERTY_USAGE_DEFAULT_VALUE: cint =
|
||||
GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_EDITOR_VALUE or
|
||||
GODOT_PROPERTY_USAGE_NETWORK_VALUE
|
||||
GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE: cint =
|
||||
GODOT_PROPERTY_USAGE_STORAGE_VALUE or
|
||||
GODOT_PROPERTY_USAGE_EDITOR_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE or
|
||||
GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE
|
||||
GODOT_PROPERTY_USAGE_NOEDITOR_VALUE: cint =
|
||||
GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE
|
||||
|
||||
type
|
||||
GodotPropertyUsageFlags* {.importc: "godot_property_usage_flags",
|
||||
header: "../godot.h", size: sizeof(cint),
|
||||
pure.} = enum
|
||||
Storage = GODOT_PROPERTY_USAGE_STORAGE_VALUE
|
||||
Editor = GODOT_PROPERTY_USAGE_EDITOR_VALUE
|
||||
Network = GODOT_PROPERTY_USAGE_NETWORK_VALUE
|
||||
NoEditor = GODOT_PROPERTY_USAGE_NOEDITOR_VALUE
|
||||
Default = GODOT_PROPERTY_USAGE_DEFAULT_VALUE
|
||||
EditorHelper = GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE
|
||||
Checkable = GODOT_PROPERTY_USAGE_CHECKABLE_VALUE
|
||||
## used for editing global variables
|
||||
Checked = GODOT_PROPERTY_USAGE_CHECKED_VALUE
|
||||
## used for editing global variables
|
||||
Internationalized = GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE
|
||||
## hint for internationalized strings
|
||||
DefaultIntl = GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE
|
||||
Group = GODOT_PROPERTY_USAGE_GROUP_VALUE
|
||||
## used for grouping props in the editor
|
||||
Category = GODOT_PROPERTY_USAGE_CATEGORY_VALUE
|
||||
NonZero = GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE
|
||||
## only store if nonzero
|
||||
NonOne = GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE
|
||||
## only store if false
|
||||
NoInstanceState = GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE
|
||||
RestartIfChanged = GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE
|
||||
ScriptVariable = GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE
|
||||
StoreIfNull = GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE
|
||||
AnimateAsTrigger = GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE
|
||||
UpdateAllIfModified = GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE
|
||||
|
||||
GodotPropertyAttributes* {.importc: "godot_property_attributes",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
rsetType* {.importc: "rset_type".}: GodotMethodRPCMode
|
||||
typ* {.importc: "type".}: cint
|
||||
hint* {.importc: "hint".}: GodotPropertyHint
|
||||
hintString* {.importc: "hint_string".}: GodotString
|
||||
usage* {.importc: "usage".}: GodotPropertyUsageFlags
|
||||
defaultValue* {.importc: "default_value".}: Variant
|
||||
|
||||
GodotInstanceCreateFunc* {.importc: "godot_instance_create_func",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
createFunc* {.importc: "create_func".}:
|
||||
proc (obj: ptr GodotObject; methodData: pointer): pointer {.noconv.}
|
||||
## returns user data
|
||||
methodData* {.importc: "method_data".}: pointer
|
||||
freeFunc* {.importc: "free_func".}: proc (a2: pointer) {.noconv.}
|
||||
|
||||
GodotInstanceDestroyFunc* {.importc: "godot_instance_destroy_func",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
destroyFunc* {.importc: "destroy_func".}:
|
||||
proc (obj: ptr GodotObject; methodData: pointer;
|
||||
userData: pointer) {.noconv.}
|
||||
methodData* {.importc: "method_data".}: pointer
|
||||
freeFunc* {.importc: "free_func".}: proc (a2: pointer) {.noconv.}
|
||||
|
||||
proc godotScriptRegisterClass*(name, base: cstring;
|
||||
create_func: GodotInstanceCreateFunc;
|
||||
destroy_func: GodotInstanceDestroyFunc) {.
|
||||
importc: "godot_script_register_class", header: "../godot.h".}
|
||||
proc godotScriptRegisterToolClass*(name, base: cstring;
|
||||
createFunc: GodotInstanceCreateFunc;
|
||||
destroyFunc: GodotInstanceDestroyFunc) {.
|
||||
importc: "godot_script_register_tool_class", header: "../godot.h".}
|
||||
type
|
||||
GodotInstanceMethod* {.importc: "godot_instance_method",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
meth* {.importc: "method".}:
|
||||
proc (obj: ptr GodotObject; methodData: pointer;
|
||||
userData: pointer; numArgs: cint;
|
||||
args: var ptr array[MAX_ARG_COUNT, Variant]): Variant {.noconv.}
|
||||
methodData* {.importc: "method_data".}: pointer
|
||||
freeFunc* {.importc: "free_func".}: proc (a2: pointer) {.noconv.}
|
||||
|
||||
proc godotScriptRegisterMethod*(name: cstring; function_name: cstring;
|
||||
attr: GodotMethodAttributes;
|
||||
meth: GodotInstanceMethod) {.
|
||||
importc: "godot_script_register_method", header: "../godot.h".}
|
||||
type
|
||||
GodotPropertySetFunc* {.importc: "godot_property_set_func",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
setFunc* {.importc: "set_func".}: proc (obj: ptr GodotObject;
|
||||
methodData: pointer;
|
||||
userData: pointer;
|
||||
value: Variant) {.noconv.}
|
||||
methodData* {.importc: "method_data".}: pointer
|
||||
freeFunc* {.importc: "free_func".}: proc (a2: pointer) {.noconv.}
|
||||
|
||||
GodotPropertyGetFunc* {.importc: "godot_property_get_func",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
getFunc* {.importc: "get_func".}:
|
||||
proc (obj: ptr GodotObject; methodData: pointer;
|
||||
userData: pointer): Variant {.noconv.}
|
||||
methodData* {.importc: "method_data".}: pointer
|
||||
freeFunc* {.importc: "free_func".}: proc (a2: pointer) {.noconv.}
|
||||
|
||||
proc godotScriptRegisterProperty*(name: cstring; path: cstring;
|
||||
attr: var GodotPropertyAttributes;
|
||||
setFunc: GodotPropertySetFunc;
|
||||
getFunc: GodotPropertyGetFunc) {.
|
||||
importc: "godot_script_register_property", header: "../godot.h".}
|
||||
|
||||
type
|
||||
GodotSignalArgument* {.importc: "godot_signal_argument",
|
||||
header: "../godot.h", bycopy.} = object
|
||||
name* {.importc: "name".}: GodotString
|
||||
typ* {.importc: "type".}: cint
|
||||
hint* {.importc: "hint".}: GodotPropertyHint
|
||||
hintString* {.importc: "hint_string".}: GodotString
|
||||
usage* {.importc: "usage".}: GodotPropertyUsageFlags
|
||||
defaultValue* {.importc: "default_value".}: Variant
|
||||
|
||||
GodotSignal* {.importc: "godot_signal", header: "../godot.h".} = object
|
||||
name* {.importc: "name".}: GodotString
|
||||
numArgs* {.importc: "num_args".}: cint
|
||||
args* {.importc: "args".}: ptr GodotSignalArgument
|
||||
numDefaultArgs* {.importc: "num_default_args".}: cint
|
||||
defaultArgs* {.importc: "default_args".}: ptr Variant
|
||||
|
||||
proc godotScriptRegisterSignal*(name: cstring; signal: GodotSignal) {.
|
||||
importc: "godot_script_register_signal", header: "../godot.h".}
|
||||
proc getUserdata*(instance: ptr GodotObject): pointer {.
|
||||
importc: "godot_native_get_userdata", header: "../godot.h".}
|
||||
|
||||
type
|
||||
GodotClassConstructor* = proc (): ptr GodotObject {.gcsafe, noconv.}
|
||||
|
||||
proc getClassConstructor*(className: cstring): GodotClassConstructor {.
|
||||
importc: "godot_get_class_constructor", header: "../godot.h".}
|
||||
proc getGlobalConstants*(): Dictionary {.
|
||||
importc: "godot_get_global_constants", header: "../godot.h".}
|
||||
proc godotNew*(p_classname: cstring): ptr GodotObject {.
|
||||
importc: "godot_new", header: "../godot.h".}
|
||||
proc godotStackBottom*(): pointer {.
|
||||
importc: "godot_get_stack_bottom", header: "../godot.h".}
|
||||
|
||||
proc deinit*(o: ptr GodotObject) {.
|
||||
importc: "godot_object_destroy", header: "../godot.h".}
|
||||
|
||||
# print using Godot's error handler list
|
||||
|
||||
proc godotPrintError(description: cstring; function: cstring; file: cstring;
|
||||
line: cint) {.
|
||||
importc: "godot_print_error", header: "../godot.h".}
|
||||
|
||||
proc godotPrintWarning(description: cstring; function: cstring;
|
||||
file: cstring; line: cint) {.
|
||||
importc: "godot_print_warning", header: "../godot.h".}
|
||||
|
||||
proc godotPrint(message: GodotString) {.
|
||||
importc: "godot_print", header: "../godot.h".}
|
||||
|
||||
proc print*(message: string) {.inline.} =
|
||||
let s = message.toGodotString()
|
||||
godotPrint(s)
|
||||
|
||||
template printWarning*(warn: typed) =
|
||||
let (filename, line) = instantiationInfo()
|
||||
godotPrintWarning(cstring($warn), nil, cstring(filename), line.cint)
|
||||
|
||||
template printError*(err: typed) =
|
||||
let (filename, line) = instantiationInfo()
|
||||
godotPrintError(cstring($err), nil, cstring(filename), line.cint)
|
||||
55
godot/core/nodepath.nim
Normal file
55
godot/core/nodepath.nim
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, strings
|
||||
|
||||
type
|
||||
NodePath* {.importc: "godot_node_path",
|
||||
header: "godot_node_path.h", byref.} = object
|
||||
|
||||
proc initNodePath(dest: var NodePath; s: GodotString) {.
|
||||
importc: "godot_node_path_new", header: "godot_node_path.h".}
|
||||
proc initNodePath(dest: var NodePath;
|
||||
src: NodePath) {.
|
||||
importc: "godot_node_path_new_copy", header: "godot_node_path.h".}
|
||||
proc deinit(self: var NodePath) {.
|
||||
importc: "godot_node_path_destroy", header: "godot_node_path.h".}
|
||||
|
||||
proc initNodePath*(s: string): NodePath {.inline.} =
|
||||
initNodePath(result, s.toGodotString())
|
||||
|
||||
proc `=destroy`(self: NodePath) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc `=`(self: var NodePath, other: NodePath) {.inline.} =
|
||||
initNodePath(self, other)
|
||||
|
||||
proc toGodotString*(self: NodePath): GodotString {.
|
||||
importc: "godot_node_path_as_string", header: "godot_node_path.h".}
|
||||
proc `$`*(self: NodePath): string {.inline.} =
|
||||
let s = self.toGodotString()
|
||||
result = $s
|
||||
|
||||
proc isAbsolute*(self: NodePath): bool {.
|
||||
importc: "godot_node_path_is_absolute", header: "godot_node_path.h".}
|
||||
proc nameCount*(self: NodePath): cint {.
|
||||
importc: "godot_node_path_get_name_count",
|
||||
header: "godot_node_path.h".}
|
||||
proc getName*(self: NodePath; idx: cint): GodotString {.
|
||||
importc: "godot_node_path_get_name", header: "godot_node_path.h".}
|
||||
proc subnameCount*(self: NodePath): cint {.
|
||||
importc: "godot_node_path_get_subname_count",
|
||||
header: "godot_node_path.h".}
|
||||
proc getSubname*(self: NodePath; idx: cint): GodotString {.
|
||||
importc: "godot_node_path_get_subname",
|
||||
header: "godot_node_path.h".}
|
||||
proc property*(self: NodePath): GodotString {.
|
||||
importc: "godot_node_path_get_property", header: "godot_node_path.h".}
|
||||
proc isEmpty*(self: NodePath): bool {.
|
||||
importc: "godot_node_path_is_empty", header: "godot_node_path.h".}
|
||||
|
||||
proc `==`*(a, b: NodePath): bool {.
|
||||
importc: "godot_node_path_operator_equal",
|
||||
header: "godot_node_path.h".}
|
||||
|
||||
converter fromString*(s: string): NodePath =
|
||||
initNodePath(result, s.toGodotString())
|
||||
84
godot/core/plane.nim
Normal file
84
godot/core/plane.nim
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, vector3, strings
|
||||
|
||||
type
|
||||
Plane* {.importc: "godot_plane", header: "godot_plane.h", byref.} = object
|
||||
|
||||
proc initPlane(dest: var Plane; a, b, c, d: float32) {.
|
||||
importc: "godot_plane_new_with_reals", header: "godot_plane.h".}
|
||||
proc initPlane(dest: var Plane; v1, v2, v3: Vector3) {.
|
||||
importc: "godot_plane_new_with_vectors",
|
||||
header: "godot_plane.h".}
|
||||
proc initPlane(dest: var Plane; normal: Vector3; d: float32) {.
|
||||
importc: "godot_plane_new_with_normal",
|
||||
header: "godot_plane.h".}
|
||||
|
||||
proc initPlane*(a, b, c, d: float32): Plane =
|
||||
initPlane(result, a, b, c, d)
|
||||
|
||||
proc initPlane*(v1, v2, v3: Vector3): Plane =
|
||||
initPlane(result, v1, v2, v3)
|
||||
|
||||
proc initPlane*(normal: Vector3; d: float32): Plane =
|
||||
initPlane(result, normal, d)
|
||||
|
||||
proc toGodotString*(self: Plane): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_as_string", header: "godot_plane.h".}
|
||||
proc `$`*(self: Plane): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc normalized*(self: Plane): Plane {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_normalized", header: "godot_plane.h".}
|
||||
proc center*(self: Plane): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_center", header: "godot_plane.h".}
|
||||
proc getAnyPoint*(self: Plane): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_get_any_point", header: "godot_plane.h".}
|
||||
proc isPointOver*(self: Plane; point: Vector3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_is_point_over",
|
||||
header: "godot_plane.h".}
|
||||
proc distanceTo*(self: Plane; point: Vector3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_distance_to", header: "godot_plane.h".}
|
||||
proc contains*(self: Plane; point: Vector3;
|
||||
epsilon: float32): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_has_point", header: "godot_plane.h".}
|
||||
proc project*(self: Plane; point: Vector3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_project", header: "godot_plane.h".}
|
||||
proc intersect3*(self: Plane; dest: var Vector3;
|
||||
b, c: Plane): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_intersect_3",
|
||||
header: "godot_plane.h".}
|
||||
proc intersectsRay*(self: Plane; dest: var Vector3;
|
||||
v, dir: Vector3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_intersects_ray",
|
||||
header: "godot_plane.h".}
|
||||
proc intersectsSegment*(self: Plane; dest: var Vector3;
|
||||
segmentBegin, segmentEnd: Vector3): bool {.
|
||||
noSideEffect, importc: "godot_plane_intersects_segment",
|
||||
header: "godot_plane.h".}
|
||||
proc `-`*(self: Plane): Plane {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_operator_neg", header: "godot_plane.h".}
|
||||
proc `==`*(a, b: Plane): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_operator_equal", header: "godot_plane.h".}
|
||||
proc normal*(self: Plane): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_get_normal", header: "godot_plane.h".}
|
||||
proc `normal=`*(self: var Plane; normal: Vector3) {.
|
||||
importc: "godot_plane_set_normal", header: "godot_plane.h".}
|
||||
proc d*(self: Plane): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_plane_get_d", header: "godot_plane.h".}
|
||||
proc `d=`*(self: var Plane; d: float32) {.
|
||||
importc: "godot_plane_set_d", header: "godot_plane.h".}
|
||||
476
godot/core/poolarray.nim
Normal file
476
godot/core/poolarray.nim
Normal file
|
|
@ -0,0 +1,476 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, color, vector2, vector3, strings
|
||||
|
||||
type
|
||||
PoolByteArray* {.importc: "godot_pool_byte_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolIntArray* {.importc: "godot_pool_int_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolRealArray* {.importc: "godot_pool_real_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolStringArray* {.importc: "godot_pool_string_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolVector2Array* {.importc: "godot_pool_vector2_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolVector3Array* {.importc: "godot_pool_vector3_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
PoolColorArray* {.importc: "godot_pool_color_array",
|
||||
header: "godot_pool_arrays.h", byref.} = object
|
||||
|
||||
# byte
|
||||
|
||||
proc initPoolByteArray(dest: var PoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolByteArray(dest: var PoolByteArray;
|
||||
src: PoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolByteArray(dest: var PoolByteArray; arr: Array) {.
|
||||
importc: "godot_pool_byte_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_destroy", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolByteArray*(): PoolByteArray {.inline.} =
|
||||
initPoolByteArray(result)
|
||||
|
||||
proc initPoolByteArray*(arr: Array): PoolByteArray {.inline.} =
|
||||
initPoolByteArray(result, arr)
|
||||
|
||||
proc `=`(self: var PoolByteArray, other: PoolByteArray) {.inline.} =
|
||||
initPoolByteArray(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolByteArray) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolByteArray;
|
||||
data: uint8) {.
|
||||
importc: "godot_pool_byte_array_append", header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolByteArray, data: uint8) {.
|
||||
importc: "godot_pool_byte_array_push_back", header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolByteArray;
|
||||
arr: PoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolByteArray; idx: cint;
|
||||
data: uint8): Error {.
|
||||
importc: "godot_pool_byte_array_insert", header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolByteArray; idx: cint) {.
|
||||
importc: "godot_pool_byte_array_remove", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc reverse*(self: var PoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_invert", header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolByteArray; size: cint) {.
|
||||
importc: "godot_pool_byte_array_resize", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc `[]=`*(self: var PoolByteArray; idx: cint; data: uint8) {.
|
||||
importc: "godot_pool_byte_array_set", header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolByteArray; idx: cint): uint8 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_byte_array_get",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolByteArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_byte_array_size", header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolByteArray): byte =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolByteArray): tuple[key: cint, val: byte] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
proc initPoolIntArray(dest: var PoolIntArray) {.
|
||||
importc: "godot_pool_int_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolIntArray(dest: var PoolIntArray;
|
||||
src: PoolIntArray) {.
|
||||
importc: "godot_pool_int_array_new_copy", header: "godot_pool_arrays.h".}
|
||||
proc initPoolIntArray(dest: var PoolIntArray;
|
||||
arr: Array) {.
|
||||
importc: "godot_pool_int_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc deinit(self: var PoolIntArray) {.
|
||||
importc: "godot_pool_int_array_destroy", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolIntArray*(): PoolIntArray {.inline.} =
|
||||
initPoolIntArray(result)
|
||||
|
||||
proc initPoolIntArray*(arr: Array): PoolIntArray {.inline.} =
|
||||
initPoolIntArray(result, arr)
|
||||
|
||||
proc `=`(self: var PoolIntArray, other: PoolIntArray) {.inline.} =
|
||||
initPoolIntArray(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolIntArray) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolIntArray; data: cint) {.
|
||||
importc: "godot_pool_int_array_append", header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolIntArray; data: cint) {.
|
||||
importc: "godot_pool_int_array_push_back", header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolIntArray; arr: PoolIntArray) {.
|
||||
importc: "godot_pool_int_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolIntArray; idx: cint;
|
||||
data: cint): Error {.
|
||||
importc: "godot_pool_int_array_insert", header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolIntArray; idx: cint) {.
|
||||
importc: "godot_pool_int_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolIntArray) {.
|
||||
importc: "godot_pool_int_array_invert", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc setLen*(self: var PoolIntArray; size: cint) {.
|
||||
importc: "godot_pool_int_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolIntArray; idx: cint; data: cint) {.
|
||||
importc: "godot_pool_int_array_set", header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolIntArray; idx: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_int_array_get",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolIntArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_int_array_size",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolIntArray): cint =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolIntArray): tuple[key: cint, val: cint] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Real
|
||||
|
||||
proc initPoolRealArray(dest: var PoolRealArray) {.
|
||||
importc: "godot_pool_real_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolRealArray(dest: var PoolRealArray;
|
||||
src: PoolRealArray) {.
|
||||
importc: "godot_pool_real_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolRealArray(dest: var PoolRealArray; arr: Array) {.
|
||||
importc: "godot_pool_real_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolRealArray) {.
|
||||
importc: "godot_pool_real_array_destroy", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolRealArray*(): PoolRealArray {.inline.} =
|
||||
initPoolRealArray(result)
|
||||
|
||||
proc initPoolRealArray*(arr: Array): PoolRealArray {.inline.} =
|
||||
initPoolRealArray(result, arr)
|
||||
|
||||
proc `=`(self: var PoolRealArray, other: PoolRealArray) {.inline.} =
|
||||
initPoolRealArray(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolRealArray) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolRealArray; data: float32) {.
|
||||
importc: "godot_pool_real_array_append",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolRealArray; data: float32) {.
|
||||
importc: "godot_pool_real_array_push_back", header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolRealArray; arr: PoolRealArray) {.
|
||||
importc: "godot_pool_real_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolRealArray;
|
||||
idx: cint; data: float32): Error {.
|
||||
importc: "godot_pool_real_array_insert", header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolRealArray; idx: cint) {.
|
||||
importc: "godot_pool_real_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolRealArray) {.
|
||||
importc: "godot_pool_real_array_invert", header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolRealArray; size: cint) {.
|
||||
importc: "godot_pool_real_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolRealArray; idx: cint; data: float32) {.
|
||||
importc: "godot_pool_real_array_set", header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolRealArray; idx: cint): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_real_array_get",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolRealArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_real_array_size", header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolRealArray): float32 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolRealArray): tuple[key: cint, val: float32] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# String
|
||||
|
||||
proc initPoolStringArray(dest: var PoolStringArray) {.
|
||||
importc: "godot_pool_string_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolStringArray(dest: var PoolStringArray;
|
||||
src: PoolStringArray) {.
|
||||
importc: "godot_pool_string_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolStringArray(dest: var PoolStringArray; arr: Array) {.
|
||||
importc: "godot_pool_string_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolStringArray) {.
|
||||
importc: "godot_pool_string_array_destroy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolStringArray*(): PoolStringArray {.inline.} =
|
||||
initPoolStringArray(result)
|
||||
|
||||
proc initPoolStringArray*(arr: Array): PoolStringArray {.inline.} =
|
||||
initPoolStringArray(result, arr)
|
||||
|
||||
proc `=`(self: var PoolStringArray, other: PoolStringArray) {.inline.} =
|
||||
initPoolStringArray(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolStringArray) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolStringArray; data: GodotString) {.
|
||||
importc: "godot_pool_string_array_append",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolStringArray; data: GodotString) {.
|
||||
importc: "godot_pool_string_array_push_back",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolStringArray; arr: PoolStringArray) {.
|
||||
importc: "godot_pool_string_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolStringArray;
|
||||
idx: cint; data: GodotString): Error {.
|
||||
importc: "godot_pool_string_array_insert",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolStringArray; idx: cint) {.
|
||||
importc: "godot_pool_string_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolStringArray) {.
|
||||
importc: "godot_pool_string_array_invert", header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolStringArray; size: cint) {.
|
||||
importc: "godot_pool_string_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolStringArray; idx: cint;
|
||||
data: GodotString) {.
|
||||
importc: "godot_pool_string_array_set",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolStringArray; idx: cint): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_string_array_get",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolStringArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_string_array_size",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolStringArray): GodotString =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolStringArray): tuple[key: cint, val: GodotString] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Vector2
|
||||
|
||||
proc initPoolVector2Array(dest: var PoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolVector2Array(dest: var PoolVector2Array;
|
||||
src: PoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolVector2Array(dest: var PoolVector2Array; arr: Array) {.
|
||||
importc: "godot_pool_vector2_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_destroy", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolVector2Array*(): PoolVector2Array {.inline.} =
|
||||
initPoolVector2Array(result)
|
||||
|
||||
proc initPoolVector2Array*(arr: Array): PoolVector2Array {.inline.} =
|
||||
initPoolVector2Array(result, arr)
|
||||
|
||||
proc `=`(self: var PoolVector2Array, other: PoolVector2Array) {.inline.} =
|
||||
initPoolVector2Array(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolVector2Array) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolVector2Array; data: Vector2) {.
|
||||
importc: "godot_pool_vector2_array_append",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolVector2Array; data: Vector2) {.
|
||||
importc: "godot_pool_vector2_array_push_back",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolVector2Array;
|
||||
arr: PoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolVector2Array;
|
||||
idx: cint; data: Vector2): Error {.
|
||||
importc: "godot_pool_vector2_array_insert",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolVector2Array; idx: cint) {.
|
||||
importc: "godot_pool_vector2_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_invert",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolVector2Array; size: cint) {.
|
||||
importc: "godot_pool_vector2_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolVector2Array; idx: cint;
|
||||
data: ptr Vector2) {.
|
||||
importc: "godot_pool_vector2_array_set", header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolVector2Array; idx: cint): Vector2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector2_array_get", header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolVector2Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector2_array_size", header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolVector2Array): Vector2 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolVector2Array): tuple[key: cint, val: Vector2] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Vector3
|
||||
|
||||
proc initPoolVector3Array*(dest: var PoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolVector3Array*(dest: var PoolVector3Array;
|
||||
src: PoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolVector3Array*(dest: var PoolVector3Array; arr: Array) {.
|
||||
importc: "godot_pool_vector3_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_destroy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolVector3Array*(): PoolVector3Array {.inline.} =
|
||||
initPoolVector3Array(result)
|
||||
|
||||
proc initPoolVector3Array*(arr: Array): PoolVector3Array {.inline.} =
|
||||
initPoolVector3Array(result, arr)
|
||||
|
||||
proc `=`(self: var PoolVector3Array, other: PoolVector3Array) {.inline.} =
|
||||
initPoolVector3Array(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolVector3Array) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolVector3Array;
|
||||
data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_append",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolVector3Array;
|
||||
data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_push_back",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolVector3Array;
|
||||
arr: PoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolVector3Array;
|
||||
idx: cint; data: Vector3): Error {.
|
||||
importc: "godot_pool_vector3_array_insert",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolVector3Array; idx: cint) {.
|
||||
importc: "godot_pool_vector3_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_invert", header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolVector3Array; size: cint) {.
|
||||
importc: "godot_pool_vector3_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolVector3Array;
|
||||
idx: cint; data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_set",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolVector3Array;
|
||||
idx: cint): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector3_array_get",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolVector3Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector3_array_size",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolVector3Array): Vector3 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolVector3Array): tuple[key: cint, val: Vector3] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Color
|
||||
|
||||
proc initPoolColorArray(dest: var PoolColorArray) {.
|
||||
importc: "godot_pool_color_array_new", header: "godot_pool_arrays.h".}
|
||||
proc initPoolColorArray(dest: var PoolColorArray;
|
||||
src: PoolColorArray) {.
|
||||
importc: "godot_pool_color_array_new_copy",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc initPoolColorArray(dest: var PoolColorArray; arr: Array) {.
|
||||
importc: "godot_pool_color_array_new_with_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
|
||||
proc deinit(self: var PoolColorArray) {.
|
||||
importc: "godot_pool_color_array_destroy", header: "godot_pool_arrays.h".}
|
||||
|
||||
proc initPoolColorArray*(): PoolColorArray {.inline.} =
|
||||
initPoolColorArray(result)
|
||||
|
||||
proc initPoolColorArray*(arr: Array): PoolColorArray {.inline.} =
|
||||
initPoolColorArray(result, arr)
|
||||
|
||||
proc `=`(self: var PoolColorArray, other: PoolColorArray) {.inline.} =
|
||||
initPoolColorArray(self, other)
|
||||
|
||||
proc `=destroy`(self: PoolColorArray) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc add*(self: var PoolColorArray; data: Color) {.
|
||||
importc: "godot_pool_color_array_append",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc addFirst*(self: var PoolColorArray; data: Color) {.
|
||||
importc: "godot_pool_color_array_push_back",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc add*(self: var PoolColorArray; arr: PoolColorArray) {.
|
||||
importc: "godot_pool_color_array_append_array",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc insert*(self: var PoolColorArray;
|
||||
idx: cint; data: Color): Error {.
|
||||
importc: "godot_pool_color_array_insert",
|
||||
header: "godot_pool_arrays.h".}
|
||||
proc delete*(self: var PoolColorArray; idx: cint) {.
|
||||
importc: "godot_pool_color_array_remove", header: "godot_pool_arrays.h".}
|
||||
proc reverse*(self: var PoolColorArray) {.
|
||||
importc: "godot_pool_color_array_invert", header: "godot_pool_arrays.h".}
|
||||
proc setLen*(self: var PoolColorArray; size: cint) {.
|
||||
importc: "godot_pool_color_array_resize", header: "godot_pool_arrays.h".}
|
||||
proc `[]=`*(self: var PoolColorArray; idx: cint;
|
||||
data: Color) {.
|
||||
importc: "godot_pool_color_array_set", header: "godot_pool_arrays.h".}
|
||||
proc `[]`*(self: PoolColorArray; idx: cint): Color {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_color_array_get", header: "godot_pool_arrays.h".}
|
||||
proc len*(self: PoolColorArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_color_array_size", header: "godot_pool_arrays.h".}
|
||||
|
||||
iterator items*(arr: PoolColorArray): Color =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: PoolColorArray): tuple[key: cint, val: Color] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
114
godot/core/quat.nim
Normal file
114
godot/core/quat.nim
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, vector3, strings
|
||||
|
||||
type
|
||||
Quat* {.importc: "godot_quat", header: "godot_quat.h", byref.} = object
|
||||
|
||||
proc initQuat(dest: var Quat; x, y, z, w: float32) {.
|
||||
importc: "godot_quat_new", header: "godot_quat.h".}
|
||||
proc initQuat(dest: var Quat; axis: Vector3; angle: float32) {.
|
||||
importc: "godot_quat_new_with_axis_angle",
|
||||
header: "godot_quat.h".}
|
||||
|
||||
proc initQuat*(x, y, z, w: float32): Quat {.inline.} =
|
||||
initQuat(result, x, y, z, w)
|
||||
|
||||
proc initQuat*(axis: Vector3; angle: float32): Quat {.inline.} =
|
||||
initQuat(result, axis, angle)
|
||||
|
||||
proc x*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_get_x", header: "godot_quat.h".}
|
||||
proc `x=`*(self: var Quat; val: float32) {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_set_x", header: "godot_quat.h".}
|
||||
proc y*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_get_y", header: "godot_quat.h".}
|
||||
proc `y=`*(self: var Quat; val: float32) {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_set_y", header: "godot_quat.h".}
|
||||
proc z*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_get_z", header: "godot_quat.h".}
|
||||
proc `z=`*(self: var Quat; val: float32) {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_set_z", header: "godot_quat.h".}
|
||||
proc w*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_get_w", header: "godot_quat.h".}
|
||||
proc `w=`*(self: var Quat; val: float32) {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_set_w", header: "godot_quat.h".}
|
||||
|
||||
proc toGodotString*(self: Quat): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_as_string", header: "godot_quat.h".}
|
||||
proc `$`*(self: Quat): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc length*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_length", header: "godot_quat.h".}
|
||||
proc lengthSquared*(self: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_length_squared", header: "godot_quat.h".}
|
||||
proc normalized*(self: Quat): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_normalized", header: "godot_quat.h".}
|
||||
proc isNormalized*(self: Quat): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_is_normalized", header: "godot_quat.h".}
|
||||
proc inverse*(self: Quat): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_inverse", header: "godot_quat.h".}
|
||||
proc dot*(a, b: Quat): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_dot", header: "godot_quat.h".}
|
||||
proc xform*(self: Quat; v: Vector3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_xform", header: "godot_quat.h".}
|
||||
proc slerp*(self: Quat; b: Quat; t: float32): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_slerp", header: "godot_quat.h".}
|
||||
proc slerpni*(self: Quat; b: Quat; t: float32): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_slerpni", header: "godot_quat.h".}
|
||||
proc cubicSlerp*(self, b, pre_a, post_b: Quat;
|
||||
t: float32): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_cubic_slerp",
|
||||
header: "godot_quat.h".}
|
||||
proc `*`*(a: Quat, b: float32): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_multiply",
|
||||
header: "godot_quat.h".}
|
||||
proc `*=`*(a: var Quat, b: float32) {.inline.} =
|
||||
a = a * b
|
||||
|
||||
proc `+`*(a, b: Quat): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_add", header: "godot_quat.h".}
|
||||
proc `+=`*(a: var Quat, b: Quat) {.inline.} =
|
||||
a = a + b
|
||||
|
||||
proc `-`*(a, b: Quat): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_substract",
|
||||
header: "godot_quat.h".}
|
||||
proc `-=`* (a: var Quat, b: Quat) {.inline.} =
|
||||
a = a - b
|
||||
|
||||
proc `/`*(self: Quat; b: float32): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_divide", header: "godot_quat.h".}
|
||||
proc `/=`*(self: var Quat, b: float32) {.inline.} =
|
||||
self = self / b
|
||||
|
||||
proc `==`*(a, b: Quat): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_equal", header: "godot_quat.h".}
|
||||
proc `-`*(self: Quat): Quat {.
|
||||
noSideEffect,
|
||||
importc: "godot_quat_operator_neg", header: "godot_quat.h".}
|
||||
68
godot/core/rect2.nim
Normal file
68
godot/core/rect2.nim
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, vector2, strings
|
||||
|
||||
type
|
||||
Rect2* {.importc: "godot_rect2", header: "godot_rect2.h", byref.} = object
|
||||
|
||||
proc initRect2(dest: var Rect2; pos, size: Vector2) {.
|
||||
importc: "godot_rect2_new_with_position_and_size",
|
||||
header: "godot_rect2.h".}
|
||||
proc initRect2(dest: var Rect2; x, y, sizeX, sizeY: float32) {.
|
||||
importc: "godot_rect2_new", header: "godot_rect2.h".}
|
||||
|
||||
proc initRect2*(pos, size: Vector2): Rect2 {.inline.} =
|
||||
initRect2(result, pos, size)
|
||||
|
||||
proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline.} =
|
||||
initRect2(result, x, y, sizeX, sizeY)
|
||||
|
||||
proc toGodotString*(self: Rect2): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_as_string", header: "godot_rect2.h".}
|
||||
proc `$`*(self: Rect2): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc area*(self: Rect2): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_get_area", header: "godot_rect2.h".}
|
||||
proc intersects*(a, b: Rect2): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_intersects", header: "godot_rect2.h".}
|
||||
proc encloses*(a, b: Rect2): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_encloses", header: "godot_rect2.h".}
|
||||
proc hasNoArea*(self: Rect2): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_has_no_area", header: "godot_rect2.h".}
|
||||
proc clip*(a, b: Rect2): Rect2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_clip", header: "godot_rect2.h".}
|
||||
proc merge*(a, b: Rect2): Rect2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_merge", header: "godot_rect2.h".}
|
||||
proc contains*(self: Rect2; point: Vector2): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_has_point", header: "godot_rect2.h".}
|
||||
proc grow*(self: Rect2; by: float32): Rect2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_grow", header: "godot_rect2.h".}
|
||||
proc expand*(self: Rect2; to: Vector2): Rect2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_expand", header: "godot_rect2.h".}
|
||||
proc `==`*(a, b: Rect2): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_operator_equal",
|
||||
header: "godot_rect2.h".}
|
||||
proc position*(self: Rect2): Vector2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_get_position", header: "godot_rect2.h".}
|
||||
proc size*(self: Rect2): Vector2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_get_size", header: "godot_rect2.h".}
|
||||
proc setPosition*(self: var Rect2; pos: Vector2) {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_set_position", header: "godot_rect2.h".}
|
||||
proc setSize*(self: var Rect2; size: Vector2) {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect2_set_size", header: "godot_rect2.h".}
|
||||
100
godot/core/rect3.nim
Normal file
100
godot/core/rect3.nim
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase, plane, vector3, strings
|
||||
|
||||
type
|
||||
Rect3* {.importc: "godot_rect3", header: "godot_rect3.h", byref.} = object
|
||||
|
||||
proc initRect3(dest: var Rect3; pos, size: Vector3) {.
|
||||
importc: "godot_rect3_new", header: "godot_rect3.h".}
|
||||
|
||||
proc initRect3*(pos, size: Vector3): Rect3 {.inline.} =
|
||||
initRect3(result, pos, size)
|
||||
|
||||
proc position*(self: Rect3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_position", header: "godot_rect3.h".}
|
||||
proc setPosition*(self: var Rect3; v: Vector3) {.
|
||||
noSideEffect
|
||||
importc: "godot_rect3_set_position", header: "godot_rect3.h".}
|
||||
proc size*(self: Rect3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_size", header: "godot_rect3.h".}
|
||||
proc setSize*(self: var Rect3; v: Vector3) {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_set_size", header: "godot_rect3.h".}
|
||||
proc toGodotString*(self: Rect3): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_as_string", header: "godot_rect3.h".}
|
||||
proc `$`*(self: Rect3): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
proc area*(self: Rect3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_area", header: "godot_rect3.h".}
|
||||
proc hasNoArea*(self: Rect3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_has_no_area", header: "godot_rect3.h".}
|
||||
proc hasNoSurface*(self: Rect3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_has_no_surface", header: "godot_rect3.h".}
|
||||
proc intersects*(a, b: Rect3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_intersects", header: "godot_rect3.h".}
|
||||
proc encloses*(self, other: Rect3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_encloses", header: "godot_rect3.h".}
|
||||
proc merge*(self, other: Rect3): Rect3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_merge", header: "godot_rect3.h".}
|
||||
proc intersection*(self, other: Rect3): Rect3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_intersection", header: "godot_rect3.h".}
|
||||
proc intersectsPlane*(self: Rect3; plane: Plane): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_intersects_plane",
|
||||
header: "godot_rect3.h".}
|
||||
proc intersectsSegment*(self: Rect3; start, to: Vector3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_intersects_segment",
|
||||
header: "godot_rect3.h".}
|
||||
proc contains*(self: Rect3; point: Vector3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_has_point", header: "godot_rect3.h".}
|
||||
proc getSupport*(self: Rect3; dir: Vector3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_support", header: "godot_rect3.h".}
|
||||
proc getLongestAxis*(self: Rect3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_longest_axis", header: "godot_rect3.h".}
|
||||
proc getLongestAxisIndex*(self: Rect3): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_longest_axis_index",
|
||||
header: "godot_rect3.h".}
|
||||
proc getLongestAxisSize*(self: Rect3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_longest_axis_size",
|
||||
header: "godot_rect3.h".}
|
||||
proc getShortestAxis*(self: Rect3): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_shortest_axis", header: "godot_rect3.h".}
|
||||
proc getShortestAxisIndex*(self: Rect3): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_shortest_axis_index",
|
||||
header: "godot_rect3.h".}
|
||||
proc getShortestAxisSize*(self: Rect3): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_shortest_axis_size",
|
||||
header: "godot_rect3.h".}
|
||||
proc expand*(self: Rect3; toPoint: Vector3): Rect3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_expand", header: "godot_rect3.h".}
|
||||
proc grow*(self: Rect3; by: float32): Rect3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_grow", header: "godot_rect3.h".}
|
||||
proc getEndpoint*(self: Rect3; idx: cint): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_get_endpoint", header: "godot_rect3.h".}
|
||||
proc `==`*(a, b: Rect3): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_rect3_operator_equal",
|
||||
header: "godot_rect3.h".}
|
||||
28
godot/core/rid.nim
Normal file
28
godot/core/rid.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import godotbase
|
||||
|
||||
type
|
||||
RID* {.importc: "godot_rid", header: "godot_rid.h", byref.} = object
|
||||
|
||||
proc initRID(dest: var RID) {.
|
||||
importc: "godot_rid_new",
|
||||
header: "godot_rid.h".}
|
||||
proc initRID(dest: var RID; obj: ptr GodotObject) {.
|
||||
importc: "godot_rid_new_with_resource", header: "godot_rid.h".}
|
||||
|
||||
proc initRID*(): RID {.inline.} =
|
||||
initRID(result)
|
||||
|
||||
proc initRID*(obj: ptr GodotObject): RID {.inline.} =
|
||||
initRID(result, obj)
|
||||
|
||||
proc idCInt(self: RID): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_rid_get_id", header: "godot_rid.h".}
|
||||
|
||||
proc id*(self: RID): uint32 {.inline.} =
|
||||
cast[uint32](self.idCInt())
|
||||
|
||||
proc `==`*(a, b: RID): bool {.
|
||||
importc: "godot_rid_operator_equal", header: "godot_rid.h".}
|
||||
proc `<`*(a, b: RID): bool {.
|
||||
importc: "godot_rid_operator_less", header: "godot_rid.h".}
|
||||
58
godot/core/strings.nim
Normal file
58
godot/core/strings.nim
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import godotbase
|
||||
|
||||
type
|
||||
GodotString* {.importc: "godot_string", header: "godot_string.h",
|
||||
byref.} = object
|
||||
|
||||
proc initGodotString(dest: var GodotString) {.
|
||||
importc: "godot_string_new", header: "godot_string.h".}
|
||||
proc initGodotString(dest: var GodotString; src: GodotString) {.
|
||||
importc: "godot_string_new_copy", header: "godot_string.h".}
|
||||
proc initGodotString(dest: var GodotString; contents: cstring;
|
||||
size: cint) {.
|
||||
importc: "godot_string_new_data", header: "godot_string.h".}
|
||||
## Initializes ``dest`` from UTF-8 ``contents``
|
||||
proc getData(self: GodotString; dest: cstring;
|
||||
size: var cint) {.
|
||||
noSideEffect
|
||||
importc: "godot_string_get_data",
|
||||
header: "godot_string.h".}
|
||||
## Converts ``self`` into UTF-8 encoding, putting the result into ``dest``.
|
||||
|
||||
proc len*(self: GodotString): cint {.inline.} =
|
||||
## Returns the length of string in bytes if it is represented as UTF-8.
|
||||
getData(self, nil, result)
|
||||
|
||||
proc cstring*(self: GodotString): cstring {.
|
||||
importc: "godot_string_c_str", header: "godot_string.h".}
|
||||
proc `==`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_equal",
|
||||
header: "godot_string.h".}
|
||||
proc `<`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_less",
|
||||
header: "godot_string.h".}
|
||||
proc `&`*(self, b: GodotString): GodotString {.
|
||||
importc: "godot_string_operator_plus",
|
||||
header: "godot_string.h".}
|
||||
|
||||
proc deinit*(self: var GodotString) {.importc: "godot_string_destroy",
|
||||
header: "godot_string.h".}
|
||||
proc `=destroy`(self: GodotString) {.inline.} =
|
||||
unsafeAddr(self).deinit()
|
||||
|
||||
proc `=`(self: var GodotString, other: GodotString) {.inline.} =
|
||||
initGodotString(self, other)
|
||||
|
||||
proc `$`*(self: GodotString): string =
|
||||
## Converts the ``GodotString`` into Nim string
|
||||
var length = self.len
|
||||
result = newStringOfCap(length)
|
||||
getData(self, addr result[0], length)
|
||||
result.setLen(length)
|
||||
assert(result[length] == '\0')
|
||||
|
||||
proc toGodotString*(s: string): GodotString {.inline.} =
|
||||
## Converts the Nim string into ``GodotString``
|
||||
initGodotString(result, unsafeAddr s[0], cint(s.len + 1))
|
||||
82
godot/core/transform.nim
Normal file
82
godot/core/transform.nim
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
Transform* {.importc: "godot_transform", header: "godot_transform.h",
|
||||
byref.} = object
|
||||
|
||||
import godotbase, basis, variant, vector3, strings, plane, rect3
|
||||
|
||||
proc initTransform(dest: var Transform) {.
|
||||
importc: "godot_transform_new_identity", header: "godot_transform.h".}
|
||||
## Initializes the ``dest`` as identity transform.
|
||||
proc initTransform(dest: var Transform;
|
||||
xAxis, yAxis, zAxis, origin: Vector3) {.
|
||||
importc: "godot_transform_new_with_axis_origin",
|
||||
header: "godot_transform.h".}
|
||||
proc initTransform(dest: var Transform; basis: Basis;
|
||||
origin: Vector3) {.
|
||||
importc: "godot_transform_new",
|
||||
header: "godot_transform.h".}
|
||||
|
||||
proc initTransform*(): Transform {.inline.} =
|
||||
initTransform(result)
|
||||
|
||||
proc initTransform*(xAxis, yAxis, zAxis,
|
||||
origin: Vector3): Transform {.inline.} =
|
||||
initTransform(result, xAxis, yAxis, zAxis, origin)
|
||||
|
||||
proc initTransform*(basis: Basis, origin: Vector3): Transform {.inline.} =
|
||||
initTransform(result, basis, origin)
|
||||
|
||||
proc basis*(self: Transform): Basis {.
|
||||
importc: "godot_transform_get_basis", header: "godot_transform.h".}
|
||||
proc `basis=`*(self: var Transform; v: Basis) {.
|
||||
importc: "godot_transform_set_basis", header: "godot_transform.h".}
|
||||
proc origin*(self: Transform): Vector3 {.
|
||||
importc: "godot_transform_get_origin", header: "godot_transform.h".}
|
||||
proc `origin=`*(self: var Transform; v: Vector3) {.
|
||||
importc: "godot_transform_set_origin", header: "godot_transform.h".}
|
||||
|
||||
proc toGodotString*(self: Transform): GodotString {.
|
||||
importc: "godot_transform_as_string", header: "godot_transform.h".}
|
||||
proc `$`*(self: Transform): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc inverse*(self: Transform): Transform {.
|
||||
importc: "godot_transform_inverse", header: "godot_transform.h".}
|
||||
proc affineInverse*(self: Transform): Transform {.
|
||||
importc: "godot_transform_affine_inverse",
|
||||
header: "godot_transform.h".}
|
||||
proc orthonormalized*(self: Transform): Transform {.
|
||||
importc: "godot_transform_orthonormalized",
|
||||
header: "godot_transform.h".}
|
||||
proc rotated*(self: Transform; axis: Vector3;
|
||||
phi: float32): Transform {.
|
||||
importc: "godot_transform_rotated", header: "godot_transform.h".}
|
||||
proc scaled*(self: Transform; scale: Vector3): Transform {.
|
||||
importc: "godot_transform_scaled", header: "godot_transform.h".}
|
||||
proc translated*(self: Transform; offset: Vector3): Transform {.
|
||||
importc: "godot_transform_translated", header: "godot_transform.h".}
|
||||
proc lookingAt*(self: Transform;
|
||||
target, up: Vector3): Transform {.
|
||||
importc: "godot_transform_looking_at", header: "godot_transform.h".}
|
||||
|
||||
proc xformPlane*(self: Transform; v: Plane): Plane {.
|
||||
importc: "godot_transform_xform_plane", header: "godot_transform.h".}
|
||||
proc xformInvPlane*(self: Transform; v: Plane): Plane {.
|
||||
importc: "godot_transform_xform_inv_plane", header: "godot_transform.h".}
|
||||
proc xformVector3*(self: Transform; v: Vector3): Vector3 {.
|
||||
importc: "godot_transform_xform_vector3", header: "godot_transform.h".}
|
||||
proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {.
|
||||
importc: "godot_transform_xform_inv_vector3", header: "godot_transform.h".}
|
||||
proc xformRect3*(self: Transform; v: Vector3): Rect3 {.
|
||||
importc: "godot_transform_xform_rect3", header: "godot_transform.h".}
|
||||
proc xformInvRect3*(self: Transform; v: Vector3): Vector3 {.
|
||||
importc: "godot_transform_xform_inv_rect3", header: "godot_transform.h".}
|
||||
|
||||
proc `==`*(self: Transform; b: Transform): bool {.
|
||||
importc: "godot_transform_operator_equal", header: "godot_transform.h".}
|
||||
proc `*`*(a, b: Transform): Transform {.
|
||||
importc: "godot_transform_operator_multiply", header: "godot_transform.h".}
|
||||
proc `*=`*(a: var Transform, b: Transform) {.inline.} =
|
||||
a = a * b
|
||||
92
godot/core/transform2d.nim
Normal file
92
godot/core/transform2d.nim
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
Transform2D* {.importc: "godot_transform2d", header: "godot_transform2d.h",
|
||||
byref.} = object
|
||||
|
||||
import godotbase, strings, variant, vector2, rect2
|
||||
|
||||
proc initTransform2D(dest: var Transform2D) {.
|
||||
importc: "godot_transform2d_new_identity", header: "godot_transform2d.h".}
|
||||
proc initTransform2D(dest: var Transform2D; rot: float32; pos: Vector2) {.
|
||||
importc: "godot_transform2d_new", header: "godot_transform2d.h".}
|
||||
proc initTransform2D(dest: var Transform2D; xAxis, yAxis, origin: Vector2) {.
|
||||
importc: "godot_transform2d_new_axis_origin",
|
||||
header: "godot_transform2d.h".}
|
||||
|
||||
proc initTransform2D*(): Transform2D {.inline.} =
|
||||
initTransform2D(result)
|
||||
|
||||
proc initTransform2D*(rot: float32; pos: Vector2): Transform2D {.inline.} =
|
||||
initTransform2D(result, rot, pos)
|
||||
|
||||
proc initTransform2D*(xAxis, yAxis, origin: Vector2): Transform2D {.inline.} =
|
||||
initTransform2D(result, xAxis, yAxis, origin)
|
||||
|
||||
proc toGodotString*(self: Transform2D): GodotString {.
|
||||
importc: "godot_transform2d_as_string",
|
||||
header: "godot_transform2d.h".}
|
||||
proc `$`*(self: Transform2D): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc inverse*(self: Transform2D): Transform2D {.
|
||||
importc: "godot_transform2d_inverse", header: "godot_transform2d.h".}
|
||||
proc affineInverse*(self: Transform2D): Transform2D {.
|
||||
importc: "godot_transform2d_affine_inverse",
|
||||
header: "godot_transform2d.h".}
|
||||
proc rotation*(self: Transform2D): float32 {.
|
||||
importc: "godot_transform2d_get_rotation",
|
||||
header: "godot_transform2d.h".}
|
||||
proc origin*(self: Transform2D): Vector2 {.
|
||||
importc: "godot_transform2d_get_origin",
|
||||
header: "godot_transform2d.h".}
|
||||
proc scale*(self: Transform2D): Vector2 {.
|
||||
importc: "godot_transform2d_get_scale",
|
||||
header: "godot_transform2d.h".}
|
||||
proc orthonormalized*(self: Transform2D): Transform2D {.
|
||||
importc: "godot_transform2d_orthonormalized",
|
||||
header: "godot_transform2d.h".}
|
||||
proc rotated*(self: Transform2D; phi: float32): Transform2D {.
|
||||
importc: "godot_transform2d_rotated",
|
||||
header: "godot_transform2d.h".}
|
||||
proc scaled*(self: Transform2D; scale: Vector2): Transform2D {.
|
||||
importc: "godot_transform2d_scaled",
|
||||
header: "godot_transform2d.h".}
|
||||
proc translated*(self: Transform2D;
|
||||
offset: Vector2): Transform2D {.
|
||||
importc: "godot_transform2d_translated",
|
||||
header: "godot_transform2d.h".}
|
||||
proc xformVector2*(self: Transform2D; v: Vector2): Vector2 {.
|
||||
importc: "godot_transform2d_xform_vector2",
|
||||
header: "godot_transform2d.h".}
|
||||
proc xformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.
|
||||
importc: "godot_transform2d_xform_inv_vector2",
|
||||
header: "godot_transform2d.h".}
|
||||
proc basisXformVector2*(self: Transform2D;
|
||||
v: Vector2): Vector2 {.
|
||||
importc: "godot_transform2d_basis_xform_vector2",
|
||||
header: "godot_transform2d.h".}
|
||||
proc basisXformInvVector2*(self: Transform2D;
|
||||
v: Vector2): Vector2 {.
|
||||
importc: "godot_transform2d_basis_xform_inv_vector2",
|
||||
header: "godot_transform2d.h".}
|
||||
proc xformRect2*(self: Transform2D; v: Rect2): Rect2 {.
|
||||
importc: "godot_transform2d_xform_rect2", header: "godot_transform2d.h".}
|
||||
proc xformInvRect2*(self: Transform2D; v: Rect2): Rect2 {.
|
||||
importc: "godot_transform2d_xform_inv_rect2",
|
||||
header: "godot_transform2d.h".}
|
||||
|
||||
proc interpolateWith*(self, m: Transform2D;
|
||||
c: float32): Transform2D {.
|
||||
importc: "godot_transform2d_interpolate_with",
|
||||
header: "godot_transform2d.h".}
|
||||
proc `==`*(a, b: Transform2D): bool {.
|
||||
importc: "godot_transform2d_operator_equal",
|
||||
header: "godot_transform2d.h".}
|
||||
proc `*`*(a, b: Transform2D): Transform2D {.
|
||||
importc: "godot_transform2d_operator_multiply",
|
||||
header: "godot_transform2d.h".}
|
||||
|
||||
proc `*=`*(a: var Transform2D, b: Transform2D) {.inline.} =
|
||||
a = a * b
|
||||
|
||||
298
godot/core/variant.nim
Normal file
298
godot/core/variant.nim
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
import godotbase
|
||||
|
||||
import arrays, basis, dictionary, nodepath
|
||||
import plane, poolarray, quat, rect2, rect3, rid
|
||||
import strings, transform, transform2d, vector2
|
||||
import vector3, color
|
||||
|
||||
type
|
||||
VariantType* {.importc: "godot_variant_type", header: "godot_variant.h",
|
||||
size: sizeof(cint), pure.} = enum
|
||||
Nil, ## atomic types
|
||||
Bool,
|
||||
Int,
|
||||
Real,
|
||||
String,
|
||||
# math types
|
||||
Vector2, ## 5
|
||||
Rect2,
|
||||
Vector3,
|
||||
Transform2D,
|
||||
Plane,
|
||||
Quat, ## 10
|
||||
Rect3,
|
||||
Basis,
|
||||
Transform, ## misc types
|
||||
Color,
|
||||
NodePath, ## 15
|
||||
RID,
|
||||
Object,
|
||||
Dictionary,
|
||||
Array, ## 20
|
||||
# arrays
|
||||
PoolByteArray,
|
||||
PoolIntArray,
|
||||
PoolRealArray,
|
||||
PoolStringArray,
|
||||
PoolVector2Array, ## 25
|
||||
PoolVector3Array,
|
||||
PoolColorArray
|
||||
|
||||
VariantCallErrorType* {.importc: "godot_variant_call_error_error",
|
||||
header: "godot_variant.h",
|
||||
size: sizeof(cint),
|
||||
pure.} = enum
|
||||
OK,
|
||||
InvalidMethod,
|
||||
InvalidArgument,
|
||||
TooManyArguments,
|
||||
TooFewArguments,
|
||||
InstanceIsNull
|
||||
|
||||
VariantCallError* {.importc: "godot_variant_call_error",
|
||||
header: "godot_variant.h".} = object
|
||||
error* {.importc: "error".}: VariantCallErrorType
|
||||
argument* {.importc: "argument".}: cint
|
||||
expected* {.importc: "expected".}: VariantType
|
||||
|
||||
proc getType*(p: Variant): VariantType {.
|
||||
importc: "godot_variant_get_type", header: "godot_variant.h".}
|
||||
|
||||
proc initNilVariant(dest: var Variant) {.
|
||||
importc: "godot_variant_new_nil", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; b: bool) {.
|
||||
importc: "godot_variant_new_bool", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; i: uint64) {.
|
||||
importc: "godot_variant_new_uint", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; i: int64) {.
|
||||
importc: "godot_variant_new_int", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; r: cdouble) {.
|
||||
importc: "godot_variant_new_real", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; s: GodotString) {.
|
||||
importc: "godot_variant_new_string", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; v2: Vector2) {.
|
||||
importc: "godot_variant_new_vector2", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; rect2: Rect2) {.
|
||||
importc: "godot_variant_new_rect2", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; v3: Vector3) {.
|
||||
importc: "godot_variant_new_vector3", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; t2d: Transform2D) {.
|
||||
importc: "godot_variant_new_transform2d",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; plane: Plane) {.
|
||||
importc: "godot_variant_new_plane", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; quat: Quat) {.
|
||||
importc: "godot_variant_new_quat", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; rect3: Rect3) {.
|
||||
importc: "godot_variant_new_rect3", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; basis: Basis) {.
|
||||
importc: "godot_variant_new_basis", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant;
|
||||
trans: Transform) {.
|
||||
importc: "godot_variant_new_transform",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; color: Color) {.
|
||||
importc: "godot_variant_new_color", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; nodePath: NodePath) {.
|
||||
importc: "godot_variant_new_node_path",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; rid: RID) {.
|
||||
importc: "godot_variant_new_rid", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; obj: ptr GodotObject) {.
|
||||
importc: "godot_variant_new_object", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; dict: Dictionary) {.
|
||||
importc: "godot_variant_new_dictionary",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; arr: Array) {.
|
||||
importc: "godot_variant_new_array", header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pba: PoolByteArray) {.
|
||||
importc: "godot_variant_new_pool_byte_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pia: PoolIntArray) {.
|
||||
importc: "godot_variant_new_pool_int_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pra: PoolRealArray) {.
|
||||
importc: "godot_variant_new_pool_real_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; psa: PoolStringArray) {.
|
||||
importc: "godot_variant_new_pool_string_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pv2a: PoolVector2Array) {.
|
||||
importc: "godot_variant_new_pool_vector2_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pv3a: PoolVector3Array) {.
|
||||
importc: "godot_variant_new_pool_vector3_array",
|
||||
header: "godot_variant.h".}
|
||||
proc initVariant(dest: var Variant; pca: PoolColorArray) {.
|
||||
importc: "godot_variant_new_pool_color_array",
|
||||
header: "godot_variant.h".}
|
||||
|
||||
proc variant*(): Variant {.inline.} =
|
||||
initNilVariant(result)
|
||||
|
||||
proc variant*(b: bool): Variant {.inline.} =
|
||||
initVariant(result, b)
|
||||
|
||||
proc variant*(i: uint64): Variant {.inline.} =
|
||||
initVariant(result, i)
|
||||
|
||||
proc variant*(i: int64): Variant {.inline.} =
|
||||
initVariant(result, i)
|
||||
|
||||
proc variant*(r: cdouble): Variant {.inline.} =
|
||||
initVariant(result, r)
|
||||
|
||||
proc variant*(s: GodotString): Variant {.inline.} =
|
||||
initVariant(result, s)
|
||||
|
||||
proc variant*(s: string): Variant {.inline.} =
|
||||
initVariant(result, s.toGodotString())
|
||||
|
||||
proc variant*(v2: Vector2): Variant {.inline.} =
|
||||
initVariant(result, v2)
|
||||
|
||||
proc variant*(rect2: Rect2): Variant {.inline.} =
|
||||
initVariant(result, rect2)
|
||||
|
||||
proc variant*(v3: Vector3): Variant {.inline.} =
|
||||
initVariant(result, v3)
|
||||
|
||||
proc variant*(t2d: Transform2D): Variant {.inline.} =
|
||||
initVariant(result, t2d)
|
||||
|
||||
proc variant*(plane: Plane): Variant {.inline.} =
|
||||
initVariant(result, plane)
|
||||
|
||||
proc variant*(quat: Quat): Variant {.inline.} =
|
||||
initVariant(result, quat)
|
||||
|
||||
proc variant*(rect3: Rect3): Variant {.inline.} =
|
||||
initVariant(result, rect3)
|
||||
|
||||
proc variant*(basis: Basis): Variant {.inline.} =
|
||||
initVariant(result, basis)
|
||||
|
||||
proc variant*(trans: Transform): Variant {.inline.} =
|
||||
initVariant(result, trans)
|
||||
|
||||
proc variant*(color: Color): Variant {.inline.} =
|
||||
initVariant(result, color)
|
||||
|
||||
proc variant*(nodePath: NodePath): Variant {.inline.} =
|
||||
initVariant(result, nodePath)
|
||||
|
||||
proc variant*(rid: RID): Variant {.inline.} =
|
||||
initVariant(result, rid)
|
||||
|
||||
proc variant*(obj: ptr GodotObject): Variant {.inline.} =
|
||||
initVariant(result, obj)
|
||||
|
||||
proc variant*(dict: Dictionary): Variant {.inline.} =
|
||||
initVariant(result, dict)
|
||||
|
||||
proc variant*(arr: Array): Variant {.inline.} =
|
||||
initVariant(result, arr)
|
||||
|
||||
proc variant*(pba: PoolByteArray): Variant {.inline.} =
|
||||
initVariant(result, pba)
|
||||
|
||||
proc variant*(pia: PoolIntArray): Variant {.inline.} =
|
||||
initVariant(result, pia)
|
||||
|
||||
proc variant*(pra: PoolRealArray): Variant {.inline.} =
|
||||
initVariant(result, pra)
|
||||
|
||||
proc variant*(psa: PoolStringArray): Variant {.inline.} =
|
||||
initVariant(result, psa)
|
||||
|
||||
proc variant*(pv2a: PoolVector2Array): Variant {.inline.} =
|
||||
initVariant(result, pv2a)
|
||||
|
||||
proc variant*(pv3a: PoolVector3Array): Variant {.inline.} =
|
||||
initVariant(result, pv3a)
|
||||
|
||||
proc variant*(pca: PoolColorArray): Variant {.inline.} =
|
||||
initVariant(result, pca)
|
||||
|
||||
proc asBool*(self: Variant): bool {.
|
||||
importc: "godot_variant_as_bool", header: "godot_variant.h".}
|
||||
proc asUint*(self: Variant): uint64 {.
|
||||
importc: "godot_variant_as_uint", header: "godot_variant.h".}
|
||||
proc asInt*(self: Variant): int64 {.
|
||||
importc: "godot_variant_as_int", header: "godot_variant.h".}
|
||||
proc asReal*(self: Variant): cdouble {.
|
||||
importc: "godot_variant_as_real", header: "godot_variant.h".}
|
||||
proc asGodotString*(self: Variant): GodotString {.
|
||||
importc: "godot_variant_as_string", header: "godot_variant.h".}
|
||||
|
||||
proc asString*(self: Variant): string =
|
||||
let s = self.asGodotString()
|
||||
result = $s
|
||||
|
||||
proc asVector2*(self: Variant): Vector2 {.
|
||||
importc: "godot_variant_as_vector2", header: "godot_variant.h".}
|
||||
proc asRect2*(self: Variant): Rect2 {.
|
||||
importc: "godot_variant_as_rect2", header: "godot_variant.h".}
|
||||
proc asVector3*(self: Variant): Vector3 {.
|
||||
importc: "godot_variant_as_vector3", header: "godot_variant.h".}
|
||||
proc asTransform2D*(self: Variant): Transform2D {.
|
||||
importc: "godot_variant_as_transform2d", header: "godot_variant.h".}
|
||||
proc asPlane*(self: Variant): Plane {.
|
||||
importc: "godot_variant_as_plane", header: "godot_variant.h".}
|
||||
proc asQuat*(self: Variant): Quat {.
|
||||
importc: "godot_variant_as_quat", header: "godot_variant.h".}
|
||||
proc asRect3*(self: Variant): Rect3 {.
|
||||
importc: "godot_variant_as_rect3", header: "godot_variant.h".}
|
||||
proc asBasis*(self: Variant): Basis {.
|
||||
importc: "godot_variant_as_basis", header: "godot_variant.h".}
|
||||
proc asTransform*(self: Variant): Transform {.
|
||||
importc: "godot_variant_as_transform", header: "godot_variant.h".}
|
||||
proc asColor*(self: Variant): Color {.
|
||||
importc: "godot_variant_as_color", header: "godot_variant.h".}
|
||||
proc asNodePath*(self: Variant): NodePath {.
|
||||
importc: "godot_variant_as_node_path", header: "godot_variant.h".}
|
||||
proc asRid*(self: Variant): RID {.
|
||||
importc: "godot_variant_as_rid", header: "godot_variant.h".}
|
||||
proc asObject*(self: Variant): ptr GodotObject {.
|
||||
importc: "godot_variant_as_object", header: "godot_variant.h".}
|
||||
proc asDictionary*(self: Variant): Dictionary {.
|
||||
importc: "godot_variant_as_dictionary", header: "godot_variant.h".}
|
||||
proc asArray*(self: Variant): Array {.
|
||||
importc: "godot_variant_as_array", header: "godot_variant.h".}
|
||||
proc asPoolByteArray*(self: Variant): PoolByteArray {.
|
||||
importc: "godot_variant_as_pool_byte_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolIntArray*(self: Variant): PoolIntArray {.
|
||||
importc: "godot_variant_as_pool_int_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolRealArray*(self: Variant): PoolRealArray {.
|
||||
importc: "godot_variant_as_pool_real_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolStringArray*(self: Variant): PoolStringArray {.
|
||||
importc: "godot_variant_as_pool_string_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolVector2Array*(self: Variant): PoolVector2Array {.
|
||||
importc: "godot_variant_as_pool_vector2_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolVector3Array*(self: Variant): PoolVector3Array {.
|
||||
importc: "godot_variant_as_pool_vector3_array",
|
||||
header: "godot_variant.h".}
|
||||
proc asPoolColorArray*(self: Variant): PoolColorArray {.
|
||||
importc: "godot_variant_as_pool_color_array",
|
||||
header: "godot_variant.h".}
|
||||
|
||||
proc call*(self: Variant; meth: GodotString;
|
||||
args: var array[MAX_ARG_COUNT, Variant]; argCount: cint;
|
||||
error: var VariantCallError): Variant {.
|
||||
importc: "godot_variant_call", header: "godot_variant.h".}
|
||||
|
||||
proc hasMethod*(self: Variant; meth: GodotString): bool {.
|
||||
importc: "godot_variant_has_method", header: "godot_variant.h".}
|
||||
proc `==`*(self, other: Variant): bool {.
|
||||
importc: "godot_variant_operator_equal", header: "godot_variant.h".}
|
||||
proc `<`*(self, other: Variant): bool {.
|
||||
importc: "godot_variant_operator_less", header: "godot_variant.h".}
|
||||
proc hashCompare*(self, other: Variant): bool {.
|
||||
importc: "godot_variant_hash_compare", header: "godot_variant.h".}
|
||||
proc booleanize*(self: Variant; isValid: var bool): bool {.
|
||||
importc: "godot_variant_booleanize", header: "godot_variant.h".}
|
||||
117
godot/core/vector2.nim
Normal file
117
godot/core/vector2.nim
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
Vector2* {.importc: "godot_vector2", header: "godot_vector2.h",
|
||||
byref.} = object
|
||||
|
||||
import godotbase, strings
|
||||
|
||||
proc initVector2(dest: var Vector2; x, y: float32) {.
|
||||
importc: "godot_vector2_new", header: "godot_vector2.h".}
|
||||
|
||||
proc vec2*(x, y: float32): Vector2 {.inline.} =
|
||||
initVector2(result, x, y)
|
||||
|
||||
proc toGodotString*(self: Vector2): GodotString {.
|
||||
importc: "godot_vector2_as_string", header: "godot_vector2.h".}
|
||||
proc `$`*(self: Vector2): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc normalized*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_normalized", header: "godot_vector2.h".}
|
||||
proc length*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_length", header: "godot_vector2.h".}
|
||||
proc angle*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle", header: "godot_vector2.h".}
|
||||
proc lengthSquared*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_length_squared", header: "godot_vector2.h".}
|
||||
proc isNormalized*(self: Vector2): bool {.
|
||||
importc: "godot_vector2_is_normalized", header: "godot_vector2.h".}
|
||||
proc distanceTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_distance_to",
|
||||
header: "godot_vector2.h".}
|
||||
proc distanceSquaredTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_distance_squared_to",
|
||||
header: "godot_vector2.h".}
|
||||
proc angleTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle_to", header: "godot_vector2.h".}
|
||||
proc angleToPoint*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle_to_point",
|
||||
header: "godot_vector2.h".}
|
||||
proc lerp*(self, b: Vector2; t: float32): Vector2 {.
|
||||
importc: "godot_vector2_linear_interpolate",
|
||||
header: "godot_vector2.h".}
|
||||
proc cubicInterpolate*(self, b, pre_a, post_b: Vector2; t: float32): Vector2 {.
|
||||
importc: "godot_vector2_cubic_interpolate",
|
||||
header: "godot_vector2.h".}
|
||||
proc rotated*(self: Vector2; phi: float32): Vector2 {.
|
||||
importc: "godot_vector2_rotated", header: "godot_vector2.h".}
|
||||
proc tangent*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_tangent", header: "godot_vector2.h".}
|
||||
proc floor*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_floor", header: "godot_vector2.h".}
|
||||
proc snapped*(self: Vector2; by: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_snapped", header: "godot_vector2.h".}
|
||||
proc aspect*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_aspect", header: "godot_vector2.h".}
|
||||
proc dot*(a, b: Vector2): float32 {.
|
||||
importc: "godot_vector2_dot", header: "godot_vector2.h".}
|
||||
proc slide*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_slide", header: "godot_vector2.h".}
|
||||
proc bounce*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_bounce", header: "godot_vector2.h".}
|
||||
proc reflect*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_reflect", header: "godot_vector2.h".}
|
||||
proc abs*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_abs", header: "godot_vector2.h".}
|
||||
proc clamped*(self: Vector2; length: float32): Vector2 {.
|
||||
importc: "godot_vector2_clamped", header: "godot_vector2.h".}
|
||||
|
||||
proc `+`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_add", header: "godot_vector2.h".}
|
||||
proc `+=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a += b
|
||||
|
||||
proc `-`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_substract", header: "godot_vector2.h".}
|
||||
proc `-=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a - b
|
||||
|
||||
proc `*`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_multiply_vector",
|
||||
header: "godot_vector2.h".}
|
||||
|
||||
proc `*=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a * b
|
||||
|
||||
proc `*`*(self: Vector2, scalar: float32): Vector2 {.
|
||||
importc: "godot_vector2_operator_multiply_scalar",
|
||||
header: "godot_vector2.h".}
|
||||
proc `*=`*(self: var Vector2, scalar: float32) {.inline.} =
|
||||
self = self * scalar
|
||||
|
||||
proc `/`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_divide_vector", header: "godot_vector2.h".}
|
||||
proc `/=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a / b
|
||||
|
||||
proc `/`*(self: Vector2; scalar: float32): Vector2 {.
|
||||
importc: "godot_vector2_operator_divide_scalar", header: "godot_vector2.h".}
|
||||
proc `/=`*(self: var Vector2; scalar: float32) {.inline.} =
|
||||
self = self / scalar
|
||||
|
||||
proc `==`*(a, b: Vector2): bool {.
|
||||
importc: "godot_vector2_operator_equal", header: "godot_vector2.h".}
|
||||
proc `<`*(a, b: Vector2): bool {.
|
||||
importc: "godot_vector2_operator_less", header: "godot_vector2.h".}
|
||||
proc `-`*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_neg", header: "godot_vector2.h".}
|
||||
|
||||
proc `x=`*(self: var Vector2; x: float32) {.
|
||||
importc: "godot_vector2_set_x", header: "godot_vector2.h".}
|
||||
proc `y=`*(self: var Vector2; y: float32) {.
|
||||
importc: "godot_vector2_set_y", header: "godot_vector2.h".}
|
||||
proc x*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_get_x", header: "godot_vector2.h".}
|
||||
proc y*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_get_y", header: "godot_vector2.h".}
|
||||
148
godot/core/vector3.nim
Normal file
148
godot/core/vector3.nim
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
Vector3* {.importc: "godot_vector3", header: "godot_vector3.h",
|
||||
byref.} = object
|
||||
|
||||
import godotbase, basis, strings
|
||||
|
||||
type
|
||||
Vector3Axis {.importc: "godot_vector3_axis", header: "godot_vector3.h",
|
||||
size: sizeof(cint), pure.} = enum
|
||||
X,
|
||||
Y,
|
||||
Z
|
||||
|
||||
proc initVector3*(dest: var Vector3; x, y, z: float32) {.
|
||||
importc: "godot_vector3_new", header: "godot_vector3.h".}
|
||||
|
||||
proc vec3*(x, y, z: float32): Vector3 {.inline.} =
|
||||
initVector3(result, x, y, z)
|
||||
|
||||
proc toGodotString*(self: Vector3): GodotString {.
|
||||
importc: "godot_vector3_as_string", header: "godot_vector3.h".}
|
||||
proc `$`*(self: Vector3): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
|
||||
proc minAxis*(self: Vector3): cint {.
|
||||
importc: "godot_vector3_min_axis", header: "godot_vector3.h".}
|
||||
proc maxAxis*(self: Vector3): cint {.
|
||||
importc: "godot_vector3_max_axis", header: "godot_vector3.h".}
|
||||
proc length*(self: Vector3): float32 {.
|
||||
importc: "godot_vector3_length", header: "godot_vector3.h".}
|
||||
proc lengthSquared*(self: Vector3): float32 {.
|
||||
importc: "godot_vector3_length_squared", header: "godot_vector3.h".}
|
||||
proc isNormalized*(self: Vector3): bool {.
|
||||
importc: "godot_vector3_is_normalized", header: "godot_vector3.h".}
|
||||
proc normalized*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_normalized", header: "godot_vector3.h".}
|
||||
proc inverse*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_inverse", header: "godot_vector3.h".}
|
||||
proc snapped*(self: Vector3; by: float32): Vector3 {.
|
||||
importc: "godot_vector3_snapped", header: "godot_vector3.h".}
|
||||
proc rotated*(self: Vector3; axis: Vector3;
|
||||
phi: float32): Vector3 {.
|
||||
importc: "godot_vector3_rotated", header: "godot_vector3.h".}
|
||||
proc lerp*(self: Vector3; b: Vector3; t: float32): Vector3 {.
|
||||
importc: "godot_vector3_linear_interpolate", header: "godot_vector3.h".}
|
||||
proc cubicInterpolate*(self, b, preA, postB: Vector3;
|
||||
t: float32): Vector3 {.
|
||||
importc: "godot_vector3_cubic_interpolate", header: "godot_vector3.h".}
|
||||
proc dot*(a, b: Vector3): float32 {.
|
||||
importc: "godot_vector3_dot", header: "godot_vector3.h".}
|
||||
proc cross*(a, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_cross", header: "godot_vector3.h".}
|
||||
proc outer*(a, b: Vector3): Basis {.
|
||||
importc: "godot_vector3_outer", header: "godot_vector3.h".}
|
||||
proc toDiagonalMatrix*(self: Vector3): Basis {.
|
||||
importc: "godot_vector3_to_diagonal_matrix", header: "godot_vector3.h".}
|
||||
proc abs*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_abs", header: "godot_vector3.h".}
|
||||
proc floor*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_floor", header: "godot_vector3.h".}
|
||||
proc ceil*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_ceil", header: "godot_vector3.h".}
|
||||
proc distanceTo*(a, b: Vector3): float32 {.
|
||||
importc: "godot_vector3_distance_to", header: "godot_vector3.h".}
|
||||
proc distanceSquaredTo*(a, b: Vector3): float32 {.
|
||||
importc: "godot_vector3_distance_squared_to", header: "godot_vector3.h".}
|
||||
proc angleTo*(self, to: Vector3): float32 {.
|
||||
importc: "godot_vector3_angle_to", header: "godot_vector3.h".}
|
||||
proc slide*(self, n: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_slide", header: "godot_vector3.h".}
|
||||
proc bounce*(self, n: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_bounce", header: "godot_vector3.h".}
|
||||
proc reflect*(self, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_reflect", header: "godot_vector3.h".}
|
||||
|
||||
proc `+`*(a, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_operator_add", header: "godot_vector3.h".}
|
||||
proc `+=`*(a: var Vector3, b: Vector3) {.inline.} =
|
||||
a = a + b
|
||||
|
||||
proc `-`*(a, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_operator_substract", header: "godot_vector3.h".}
|
||||
proc `-=`*(a: var Vector3, b: Vector3) {.inline.} =
|
||||
a = a - b
|
||||
|
||||
proc `*`*(a, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_operator_multiply_vector",
|
||||
header: "godot_vector3.h".}
|
||||
proc `*=`*(a: var Vector3, b: Vector3) {.inline.}=
|
||||
a = a * b
|
||||
|
||||
proc `*`*(self: Vector3; b: float32): Vector3 {.
|
||||
importc: "godot_vector3_operator_multiply_scalar",
|
||||
header: "godot_vector3.h".}
|
||||
proc `*=`*(a: var Vector3; b: float32) {.inline.} =
|
||||
a = a * b
|
||||
|
||||
proc `/`*(a, b: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_operator_divide_vector",
|
||||
header: "godot_vector3.h".}
|
||||
proc `/=`*(a: var Vector3; b: Vector3) {.inline.} =
|
||||
a = a / b
|
||||
|
||||
proc `/`*(self: Vector3; b: float32): Vector3 {.
|
||||
importc: "godot_vector3_operator_divide_scalar",
|
||||
header: "godot_vector3.h".}
|
||||
proc `/=`*(a: var Vector3; b: float32) {.inline.} =
|
||||
a = a / b
|
||||
|
||||
proc `==`*(a, b: Vector3): bool {.
|
||||
importc: "godot_vector3_operator_equal", header: "godot_vector3.h".}
|
||||
proc `<`*(a, b: Vector3): bool {.
|
||||
importc: "godot_vector3_operator_less", header: "godot_vector3.h".}
|
||||
proc `-`*(self: Vector3): Vector3 {.
|
||||
importc: "godot_vector3_operator_neg", header: "godot_vector3.h".}
|
||||
|
||||
proc setAxis(self: var Vector3; axis: Vector3Axis;
|
||||
val: float32) {.
|
||||
importc: "godot_vector3_set_axis", header: "godot_vector3.h".}
|
||||
proc getAxis(self: Vector3; axis: Vector3Axis): float32 {.
|
||||
importc: "godot_vector3_get_axis", header: "godot_vector3.h".}
|
||||
|
||||
proc `[]`(self: Vector3, idx: range[0..2]): float32 {.inline.} =
|
||||
self.getAxis(Vector3Axis(idx))
|
||||
|
||||
proc `[]=`(self: var Vector3, idx: range[0..2],
|
||||
val: float32): float32 {.inline.} =
|
||||
self.setAxis(Vector3Axis(idx), val)
|
||||
|
||||
proc x*(self: Vector3): float32 {.inline.} =
|
||||
self.getAxis(Vector3Axis.X)
|
||||
|
||||
proc `x=`*(self: var Vector3, val: float32) {.inline.} =
|
||||
self.setAxis(Vector3Axis.X, val)
|
||||
|
||||
proc y*(self: Vector3): float32 {.inline.} =
|
||||
self.getAxis(Vector3Axis.Y)
|
||||
|
||||
proc `y=`*(self: var Vector3, val: float32) {.inline.} =
|
||||
self.setAxis(Vector3Axis.Y, val)
|
||||
|
||||
proc z*(self: Vector3): float32 {.inline.} =
|
||||
self.getAxis(Vector3Axis.Z)
|
||||
|
||||
proc `z=`*(self: var Vector3, val: float32) {.inline.} =
|
||||
self.setAxis(Vector3Axis.Z, val)
|
||||
Loading…
Add table
Add a link
Reference in a new issue