-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
75 lines (60 loc) · 2.03 KB
/
Copy pathtest.py
File metadata and controls
75 lines (60 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# Copyright (c) 2013 Ambrus Csaszar
#
# Tests the mikktspace python extension using known data.
# Currently the extension only supports un-indexed triangle data passed as a
# flat tuple or list (see format hints below).
#
import mikktspace as mk
test_tris = (
0, 0, 0, # position x,y,z
0, -0.70710678118, 0.70710678118, # normal x,y,z (normalized)
0, 0, # texcoord u,v
1, 0, 0,
0.70710678118, 0, 0.70710678118,
1, 1,
0, 1, 0,
0, 0.70710678118, 0.70710678118,
0, 1,
0, 1, 0,
0, 0.70710678118, 0.70710678118,
0, 1,
1, 0, 0,
0.70710678118, 0, 0.70710678118,
1, 1,
1, 1, 0,
-0.70710678118, 0, 0.70710678118,
1, 2,
)
expected_result = (
0.8164966702461243, -0.40824833512306213, -0.40824827551841736, # tangent (normalized)
0.0, 0.7071068286895752, 0.7071067690849304, # bi-tangent (normalized)
1.4142135381698608, 1.0, # mag-tan, mag-bitan
0.40824833512306213, -0.8164965510368347, -0.40824827551841736,
0.0, 0.9999999403953552, 0.0,
1.4142135381698608, 1.0,
0.8164965510368347, -0.40824833512306213, 0.40824827551841736,
0.0, 0.7071067690849304, -0.7071067094802856,
1.4142135381698608, 1.0,
0.8164965510368347, -0.40824833512306213, 0.40824827551841736,
0.0, 0.7071067690849304, -0.7071067094802856,
1.4142135381698608, 1.0,
0.40824833512306213, -0.8164965510368347, -0.40824827551841736,
0.0, 0.9999999403953552, 0.0,
1.4142135381698608, 1.0,
0.40824833512306213, -0.8164966702461243, 0.40824827551841736,
0.0, 1.0, 0.0,
1.4142135381698608, 1.0
)
# Compute
ret = mk.compute_tri_tangents(test_tris)
# Validate
if len(ret) != len(expected_result):
print("ERROR: length mismatch")
if ret == expected_result:
print("All good. Exact result obtained.")
else:
err = 0
for i in xrange(len(ret)):
err = max(err, abs(expected_result[i] - ret[i]))
print("Inexact result: max error is %s" % err)