rev |
line source |
nuclear@33
|
1 # Goat3D Blender >2.5 exporter
|
nuclear@33
|
2 import bpy;
|
nuclear@36
|
3 import ctypes
|
nuclear@36
|
4 from ctypes import *
|
nuclear@36
|
5 from ctypes.util import find_library
|
nuclear@33
|
6
|
nuclear@33
|
7
|
nuclear@38
|
8 def export(oper, ctx, fname):
|
nuclear@38
|
9 print("Exporting goat3d file: " + fname)
|
nuclear@33
|
10
|
nuclear@38
|
11 # load all relevant functions from libgoat3d
|
nuclear@38
|
12 libname = find_library("goat3d")
|
nuclear@38
|
13 if not libname:
|
nuclear@38
|
14 oper.report({'ERROR'}, "Could not find the goat3d library! make sure it's installed.")
|
nuclear@38
|
15 return False
|
nuclear@33
|
16
|
nuclear@38
|
17 libgoat = CDLL(libname)
|
nuclear@38
|
18 if not libgoat:
|
nuclear@38
|
19 oper.report({'ERROR'}, "Could not open goat3d library!")
|
nuclear@38
|
20 return False
|
nuclear@37
|
21
|
nuclear@38
|
22 goat3d_create = libgoat.goat3d_create
|
nuclear@38
|
23 goat3d_create.argtypes = None
|
nuclear@38
|
24 goat3d_create.restype = c_void_p
|
nuclear@36
|
25
|
nuclear@38
|
26 goat3d_free = libgoat.goat3d_free
|
nuclear@38
|
27 goat3d_free.argtypes = [c_void_p]
|
nuclear@38
|
28 goat3d_free.restype = None
|
nuclear@36
|
29
|
nuclear@38
|
30 goat3d_set_name = libgoat.goat3d_set_name
|
nuclear@38
|
31 goat3d_set_name.argtypes = [c_void_p, c_char_p]
|
nuclear@36
|
32
|
nuclear@38
|
33 goat3d_set_ambient3f = libgoat.goat3d_set_ambient3f
|
nuclear@38
|
34 goat3d_set_ambient3f.argtypes = [c_void_p, c_float, c_float, c_float]
|
nuclear@38
|
35 goat3d_set_ambient3f.restype = None
|
nuclear@36
|
36
|
nuclear@38
|
37 goat3d_add_mtl = libgoat.goat3d_add_mtl
|
nuclear@38
|
38 goat3d_add_mtl.argtypes = [c_void_p, c_void_p]
|
nuclear@38
|
39 goat3d_add_mtl.restype = None
|
nuclear@36
|
40
|
nuclear@38
|
41 goat3d_create_mtl = libgoat.goat3d_create_mtl
|
nuclear@38
|
42 goat3d_create_mtl.argtypes = None
|
nuclear@38
|
43 goat3d_create_mtl.restype = c_void_p
|
nuclear@36
|
44
|
nuclear@38
|
45 goat3d_set_mtl_name = libgoat.goat3d_set_mtl_name
|
nuclear@38
|
46 goat3d_set_mtl_name.argtypes = [c_void_p, c_char_p]
|
nuclear@38
|
47 goat3d_set_mtl_name.restype = None
|
nuclear@33
|
48
|
nuclear@38
|
49 goat3d_set_mtl_attrib4f = libgoat.goat3d_set_mtl_attrib4f
|
nuclear@38
|
50 goat3d_set_mtl_attrib4f.argtypes = [c_void_p, c_char_p, c_float, c_float, c_float, c_float]
|
nuclear@38
|
51 goat3d_set_mtl_attrib4f.restype = None
|
nuclear@33
|
52
|
nuclear@38
|
53 goat3d_set_mtl_attrib_map = libgoat.goat3d_set_mtl_attrib_map
|
nuclear@38
|
54 goat3d_set_mtl_attrib_map.argtypes = [c_void_p, c_char_p, c_char_p]
|
nuclear@38
|
55 goat3d_set_mtl_attrib_map.restype = None
|
nuclear@33
|
56
|
nuclear@38
|
57 goat3d_add_mesh = libgoat.goat3d_add_mesh
|
nuclear@38
|
58 goat3d_add_mesh.argtypes = [c_void_p, c_void_p]
|
nuclear@38
|
59 goat3d_add_mesh.restype = None
|
nuclear@33
|
60
|
nuclear@38
|
61 goat3d_create_mesh = libgoat.goat3d_create_mesh
|
nuclear@38
|
62 goat3d_create_mesh.argtypes = None
|
nuclear@38
|
63 goat3d_create_mesh.restype = c_void_p
|
nuclear@38
|
64
|
nuclear@38
|
65 goat3d_set_mesh_name = libgoat.goat3d_set_mesh_name
|
nuclear@38
|
66 goat3d_set_mesh_name.argtypes = [c_void_p, c_char_p]
|
nuclear@38
|
67 goat3d_set_mesh_name.restype = None
|
nuclear@38
|
68
|
nuclear@38
|
69 goat3d_set_mesh_mtl = libgoat.goat3d_set_mesh_mtl
|
nuclear@38
|
70 goat3d_set_mesh_mtl.argtypes = [c_void_p, c_void_p]
|
nuclear@38
|
71 goat3d_set_mesh_mtl.restype = None
|
nuclear@38
|
72
|
nuclear@38
|
73 goat3d_set_mesh_attribs = libgoat.goat3d_set_mesh_attribs
|
nuclear@38
|
74 goat3d_set_mesh_attribs.argtypes = [c_void_p, c_int, c_void_p, c_int]
|
nuclear@38
|
75 goat3d_set_mesh_attribs.restype = None
|
nuclear@38
|
76
|
nuclear@38
|
77 goat3d_set_mesh_faces = libgoat.goat3d_set_mesh_faces
|
nuclear@38
|
78 goat3d_set_mesh_faces.argtypes = [c_void_p, c_void_p, c_int]
|
nuclear@38
|
79 goat3d_set_mesh_faces.restype = None
|
nuclear@38
|
80
|
nuclear@38
|
81 goat3d_add_node = libgoat.goat3d_add_node
|
nuclear@38
|
82 goat3d_add_node.argtypes = [c_void_p, c_void_p]
|
nuclear@38
|
83 goat3d_add_node.restype = None
|
nuclear@38
|
84
|
nuclear@38
|
85 goat3d_create_node = libgoat.goat3d_create_node
|
nuclear@38
|
86 goat3d_create_node.argtypes = None
|
nuclear@38
|
87 goat3d_create_node.restype = c_void_p
|
nuclear@38
|
88
|
nuclear@38
|
89 goat3d_set_node_name = libgoat.goat3d_set_node_name
|
nuclear@38
|
90 goat3d_set_node_name.argtypes = [c_void_p, c_char_p]
|
nuclear@38
|
91 goat3d_set_node_name.restype = None
|
nuclear@38
|
92
|
nuclear@38
|
93 goat3d_set_node_object = libgoat.goat3d_set_node_object
|
nuclear@38
|
94 goat3d_set_node_object.argtypes = [c_void_p, c_int, c_void_p]
|
nuclear@38
|
95 goat3d_set_node_object.restype = None
|
nuclear@38
|
96
|
nuclear@38
|
97 goat3d_add_node_child = libgoat.goat3d_add_node_child
|
nuclear@38
|
98 goat3d_add_node_child.argtypes = [c_void_p, c_void_p]
|
nuclear@38
|
99 goat3d_add_node_child.restype = None
|
nuclear@38
|
100
|
nuclear@38
|
101 goat3d_set_node_position = libgoat.goat3d_set_node_position
|
nuclear@38
|
102 goat3d_set_node_position.argtypes = [c_void_p, c_float, c_float, c_float, c_long]
|
nuclear@38
|
103 goat3d_set_node_position.restype = None
|
nuclear@38
|
104
|
nuclear@38
|
105 goat3d_set_node_rotation = libgoat.goat3d_set_node_rotation
|
nuclear@38
|
106 goat3d_set_node_rotation.argtypes = [c_void_p, c_float, c_float, c_float, c_float, c_long]
|
nuclear@38
|
107 goat3d_set_node_rotation.restype = None
|
nuclear@38
|
108
|
nuclear@38
|
109 goat3d_set_node_scaling = libgoat.goat3d_set_node_scaling
|
nuclear@38
|
110 goat3d_set_node_scaling.argtypes = [c_void_p, c_float, c_float, c_float, c_long]
|
nuclear@38
|
111 goat3d_set_node_scaling.restype = None
|
nuclear@38
|
112
|
nuclear@38
|
113 goat3d_set_node_pivot = libgoat.goat3d_set_node_pivot
|
nuclear@38
|
114 goat3d_set_node_pivot.argtypes = [c_void_p, c_float, c_float, c_float]
|
nuclear@38
|
115 goat3d_set_node_pivot.restype = None
|
nuclear@38
|
116
|
nuclear@38
|
117 goat3d_save = libgoat.goat3d_save
|
nuclear@38
|
118 goat3d_save.argtypes = [c_void_p, c_char_p]
|
nuclear@38
|
119
|
nuclear@38
|
120 # initiaize a goat3d object and start filling it up with data
|
nuclear@38
|
121 goat = goat3d_create()
|
nuclear@38
|
122 if not goat:
|
nuclear@38
|
123 oper.report({'ERROR'}, "Failed to create goat3d object")
|
nuclear@38
|
124 return False
|
nuclear@38
|
125
|
nuclear@38
|
126 goat3d_save(goat, fname.encode('utf-8'))
|
nuclear@38
|
127 goat3d_free(goat)
|
nuclear@38
|
128 return True
|
nuclear@38
|
129
|
nuclear@38
|
130
|