goat3d
view exporters/blendgoat/src/export_goat.py @ 38:60f2037680ee
split the exporter into two files to make it more readable (and maybe make an importer too at some point?)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 07 Oct 2013 20:02:57 +0300 |
parents | exporters/blendgoat/src/blendgoat.py@d259a5094390 |
children | 0e48907847ad |
line source
1 # Goat3D Blender >2.5 exporter
2 import bpy;
3 import ctypes
4 from ctypes import *
5 from ctypes.util import find_library
8 def export(oper, ctx, fname):
9 print("Exporting goat3d file: " + fname)
11 # load all relevant functions from libgoat3d
12 libname = find_library("goat3d")
13 if not libname:
14 oper.report({'ERROR'}, "Could not find the goat3d library! make sure it's installed.")
15 return False
17 libgoat = CDLL(libname)
18 if not libgoat:
19 oper.report({'ERROR'}, "Could not open goat3d library!")
20 return False
22 goat3d_create = libgoat.goat3d_create
23 goat3d_create.argtypes = None
24 goat3d_create.restype = c_void_p
26 goat3d_free = libgoat.goat3d_free
27 goat3d_free.argtypes = [c_void_p]
28 goat3d_free.restype = None
30 goat3d_set_name = libgoat.goat3d_set_name
31 goat3d_set_name.argtypes = [c_void_p, c_char_p]
33 goat3d_set_ambient3f = libgoat.goat3d_set_ambient3f
34 goat3d_set_ambient3f.argtypes = [c_void_p, c_float, c_float, c_float]
35 goat3d_set_ambient3f.restype = None
37 goat3d_add_mtl = libgoat.goat3d_add_mtl
38 goat3d_add_mtl.argtypes = [c_void_p, c_void_p]
39 goat3d_add_mtl.restype = None
41 goat3d_create_mtl = libgoat.goat3d_create_mtl
42 goat3d_create_mtl.argtypes = None
43 goat3d_create_mtl.restype = c_void_p
45 goat3d_set_mtl_name = libgoat.goat3d_set_mtl_name
46 goat3d_set_mtl_name.argtypes = [c_void_p, c_char_p]
47 goat3d_set_mtl_name.restype = None
49 goat3d_set_mtl_attrib4f = libgoat.goat3d_set_mtl_attrib4f
50 goat3d_set_mtl_attrib4f.argtypes = [c_void_p, c_char_p, c_float, c_float, c_float, c_float]
51 goat3d_set_mtl_attrib4f.restype = None
53 goat3d_set_mtl_attrib_map = libgoat.goat3d_set_mtl_attrib_map
54 goat3d_set_mtl_attrib_map.argtypes = [c_void_p, c_char_p, c_char_p]
55 goat3d_set_mtl_attrib_map.restype = None
57 goat3d_add_mesh = libgoat.goat3d_add_mesh
58 goat3d_add_mesh.argtypes = [c_void_p, c_void_p]
59 goat3d_add_mesh.restype = None
61 goat3d_create_mesh = libgoat.goat3d_create_mesh
62 goat3d_create_mesh.argtypes = None
63 goat3d_create_mesh.restype = c_void_p
65 goat3d_set_mesh_name = libgoat.goat3d_set_mesh_name
66 goat3d_set_mesh_name.argtypes = [c_void_p, c_char_p]
67 goat3d_set_mesh_name.restype = None
69 goat3d_set_mesh_mtl = libgoat.goat3d_set_mesh_mtl
70 goat3d_set_mesh_mtl.argtypes = [c_void_p, c_void_p]
71 goat3d_set_mesh_mtl.restype = None
73 goat3d_set_mesh_attribs = libgoat.goat3d_set_mesh_attribs
74 goat3d_set_mesh_attribs.argtypes = [c_void_p, c_int, c_void_p, c_int]
75 goat3d_set_mesh_attribs.restype = None
77 goat3d_set_mesh_faces = libgoat.goat3d_set_mesh_faces
78 goat3d_set_mesh_faces.argtypes = [c_void_p, c_void_p, c_int]
79 goat3d_set_mesh_faces.restype = None
81 goat3d_add_node = libgoat.goat3d_add_node
82 goat3d_add_node.argtypes = [c_void_p, c_void_p]
83 goat3d_add_node.restype = None
85 goat3d_create_node = libgoat.goat3d_create_node
86 goat3d_create_node.argtypes = None
87 goat3d_create_node.restype = c_void_p
89 goat3d_set_node_name = libgoat.goat3d_set_node_name
90 goat3d_set_node_name.argtypes = [c_void_p, c_char_p]
91 goat3d_set_node_name.restype = None
93 goat3d_set_node_object = libgoat.goat3d_set_node_object
94 goat3d_set_node_object.argtypes = [c_void_p, c_int, c_void_p]
95 goat3d_set_node_object.restype = None
97 goat3d_add_node_child = libgoat.goat3d_add_node_child
98 goat3d_add_node_child.argtypes = [c_void_p, c_void_p]
99 goat3d_add_node_child.restype = None
101 goat3d_set_node_position = libgoat.goat3d_set_node_position
102 goat3d_set_node_position.argtypes = [c_void_p, c_float, c_float, c_float, c_long]
103 goat3d_set_node_position.restype = None
105 goat3d_set_node_rotation = libgoat.goat3d_set_node_rotation
106 goat3d_set_node_rotation.argtypes = [c_void_p, c_float, c_float, c_float, c_float, c_long]
107 goat3d_set_node_rotation.restype = None
109 goat3d_set_node_scaling = libgoat.goat3d_set_node_scaling
110 goat3d_set_node_scaling.argtypes = [c_void_p, c_float, c_float, c_float, c_long]
111 goat3d_set_node_scaling.restype = None
113 goat3d_set_node_pivot = libgoat.goat3d_set_node_pivot
114 goat3d_set_node_pivot.argtypes = [c_void_p, c_float, c_float, c_float]
115 goat3d_set_node_pivot.restype = None
117 goat3d_save = libgoat.goat3d_save
118 goat3d_save.argtypes = [c_void_p, c_char_p]
120 # initiaize a goat3d object and start filling it up with data
121 goat = goat3d_create()
122 if not goat:
123 oper.report({'ERROR'}, "Failed to create goat3d object")
124 return False
126 goat3d_save(goat, fname.encode('utf-8'))
127 goat3d_free(goat)
128 return True