(namespace, data)
| 358 | print('\tpublic '+otype+' '+enumvalue['fieldname']+';') |
| 359 | |
| 360 | def outputstructs(namespace, data): |
| 361 | for struct in data['structs']: |
| 362 | if(len(struct) > 0 and len(struct['struct'])): |
| 363 | structname = struct['struct'] |
| 364 | #print('//'+structname) |
| 365 | ns = getnamespace(structname) |
| 366 | basename = getclasswithoutnamespace(structname) |
| 367 | if(basename != '(anonymous)' and (ns == namespace or (namespace == '' and ns[:1] == 'I') or (namespace == '' and ns[:1] == 'C'))): |
| 368 | for key, value in typedeflist.items(): |
| 369 | if(converttype(value) == basename): |
| 370 | basename = getclasswithoutnamespace(key) |
| 371 | break |
| 372 | |
| 373 | print('[StructLayout(LayoutKind.Sequential)] public struct '+basename+'\n{') |
| 374 | outputstructfields(struct, data) |
| 375 | |
| 376 | if (basename == 'HmdMatrix34_t'): |
| 377 | print('#if UNITY_5_3_OR_NEWER') |
| 378 | print('\n\tpublic Vector3 GetPosition()') |
| 379 | print('\t{') |
| 380 | print('\t\treturn new Vector3(m3, m7, -m11);') |
| 381 | print('\t}') |
| 382 | |
| 383 | print('\n\tpublic bool IsRotationValid()') |
| 384 | print('\t{') |
| 385 | print('\t\treturn ((m2 != 0 || m6 != 0 || m10 != 0) && (m1 != 0 || m5 != 0 || m9 != 0));') |
| 386 | print('\t}') |
| 387 | |
| 388 | print('\n\tpublic Quaternion GetRotation()') |
| 389 | print('\t{') |
| 390 | print('\t\tif (IsRotationValid())') |
| 391 | print('\t\t{') |
| 392 | print('\t\t\tfloat w = Mathf.Sqrt(Mathf.Max(0, 1 + m0 + m5 + m10)) / 2;') |
| 393 | print('\t\t\tfloat x = Mathf.Sqrt(Mathf.Max(0, 1 + m0 - m5 - m10)) / 2;') |
| 394 | print('\t\t\tfloat y = Mathf.Sqrt(Mathf.Max(0, 1 - m0 + m5 - m10)) / 2;') |
| 395 | print('\t\t\tfloat z = Mathf.Sqrt(Mathf.Max(0, 1 - m0 - m5 + m10)) / 2;') |
| 396 | |
| 397 | print('\n\t\t\t_copysign(ref x, -m9 - -m6);') |
| 398 | print('\t\t\t_copysign(ref y, -m2 - -m8);') |
| 399 | print('\t\t\t_copysign(ref z, m4 - m1);') |
| 400 | |
| 401 | print('\n\t\t\treturn new Quaternion(x, y, z, w);') |
| 402 | print('\t\t}') |
| 403 | |
| 404 | print('\t\treturn Quaternion.identity;') |
| 405 | print('\t}') |
| 406 | |
| 407 | print('\n\tprivate static void _copysign(ref float sizeval, float signval)') |
| 408 | print('\t{') |
| 409 | print('\t\tif (signval > 0 != sizeval > 0)') |
| 410 | print('\t\t\tsizeval = -sizeval;') |
| 411 | print('\t}') |
| 412 | |
| 413 | print('#endif') |
| 414 | print('}') |
| 415 | else: |
| 416 | print('}') |
| 417 |
nothing calls this directly
no test coverage detected