goat3d
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/exporters/blendgoat/src/export_goat.py Mon Oct 07 20:02:57 2013 +0300 1.3 @@ -0,0 +1,130 @@ 1.4 +# Goat3D Blender >2.5 exporter 1.5 +import bpy; 1.6 +import ctypes 1.7 +from ctypes import * 1.8 +from ctypes.util import find_library 1.9 + 1.10 + 1.11 +def export(oper, ctx, fname): 1.12 + print("Exporting goat3d file: " + fname) 1.13 + 1.14 + # load all relevant functions from libgoat3d 1.15 + libname = find_library("goat3d") 1.16 + if not libname: 1.17 + oper.report({'ERROR'}, "Could not find the goat3d library! make sure it's installed.") 1.18 + return False 1.19 + 1.20 + libgoat = CDLL(libname) 1.21 + if not libgoat: 1.22 + oper.report({'ERROR'}, "Could not open goat3d library!") 1.23 + return False 1.24 + 1.25 + goat3d_create = libgoat.goat3d_create 1.26 + goat3d_create.argtypes = None 1.27 + goat3d_create.restype = c_void_p 1.28 + 1.29 + goat3d_free = libgoat.goat3d_free 1.30 + goat3d_free.argtypes = [c_void_p] 1.31 + goat3d_free.restype = None 1.32 + 1.33 + goat3d_set_name = libgoat.goat3d_set_name 1.34 + goat3d_set_name.argtypes = [c_void_p, c_char_p] 1.35 + 1.36 + goat3d_set_ambient3f = libgoat.goat3d_set_ambient3f 1.37 + goat3d_set_ambient3f.argtypes = [c_void_p, c_float, c_float, c_float] 1.38 + goat3d_set_ambient3f.restype = None 1.39 + 1.40 + goat3d_add_mtl = libgoat.goat3d_add_mtl 1.41 + goat3d_add_mtl.argtypes = [c_void_p, c_void_p] 1.42 + goat3d_add_mtl.restype = None 1.43 + 1.44 + goat3d_create_mtl = libgoat.goat3d_create_mtl 1.45 + goat3d_create_mtl.argtypes = None 1.46 + goat3d_create_mtl.restype = c_void_p 1.47 + 1.48 + goat3d_set_mtl_name = libgoat.goat3d_set_mtl_name 1.49 + goat3d_set_mtl_name.argtypes = [c_void_p, c_char_p] 1.50 + goat3d_set_mtl_name.restype = None 1.51 + 1.52 + goat3d_set_mtl_attrib4f = libgoat.goat3d_set_mtl_attrib4f 1.53 + goat3d_set_mtl_attrib4f.argtypes = [c_void_p, c_char_p, c_float, c_float, c_float, c_float] 1.54 + goat3d_set_mtl_attrib4f.restype = None 1.55 + 1.56 + goat3d_set_mtl_attrib_map = libgoat.goat3d_set_mtl_attrib_map 1.57 + goat3d_set_mtl_attrib_map.argtypes = [c_void_p, c_char_p, c_char_p] 1.58 + goat3d_set_mtl_attrib_map.restype = None 1.59 + 1.60 + goat3d_add_mesh = libgoat.goat3d_add_mesh 1.61 + goat3d_add_mesh.argtypes = [c_void_p, c_void_p] 1.62 + goat3d_add_mesh.restype = None 1.63 + 1.64 + goat3d_create_mesh = libgoat.goat3d_create_mesh 1.65 + goat3d_create_mesh.argtypes = None 1.66 + goat3d_create_mesh.restype = c_void_p 1.67 + 1.68 + goat3d_set_mesh_name = libgoat.goat3d_set_mesh_name 1.69 + goat3d_set_mesh_name.argtypes = [c_void_p, c_char_p] 1.70 + goat3d_set_mesh_name.restype = None 1.71 + 1.72 + goat3d_set_mesh_mtl = libgoat.goat3d_set_mesh_mtl 1.73 + goat3d_set_mesh_mtl.argtypes = [c_void_p, c_void_p] 1.74 + goat3d_set_mesh_mtl.restype = None 1.75 + 1.76 + goat3d_set_mesh_attribs = libgoat.goat3d_set_mesh_attribs 1.77 + goat3d_set_mesh_attribs.argtypes = [c_void_p, c_int, c_void_p, c_int] 1.78 + goat3d_set_mesh_attribs.restype = None 1.79 + 1.80 + goat3d_set_mesh_faces = libgoat.goat3d_set_mesh_faces 1.81 + goat3d_set_mesh_faces.argtypes = [c_void_p, c_void_p, c_int] 1.82 + goat3d_set_mesh_faces.restype = None 1.83 + 1.84 + goat3d_add_node = libgoat.goat3d_add_node 1.85 + goat3d_add_node.argtypes = [c_void_p, c_void_p] 1.86 + goat3d_add_node.restype = None 1.87 + 1.88 + goat3d_create_node = libgoat.goat3d_create_node 1.89 + goat3d_create_node.argtypes = None 1.90 + goat3d_create_node.restype = c_void_p 1.91 + 1.92 + goat3d_set_node_name = libgoat.goat3d_set_node_name 1.93 + goat3d_set_node_name.argtypes = [c_void_p, c_char_p] 1.94 + goat3d_set_node_name.restype = None 1.95 + 1.96 + goat3d_set_node_object = libgoat.goat3d_set_node_object 1.97 + goat3d_set_node_object.argtypes = [c_void_p, c_int, c_void_p] 1.98 + goat3d_set_node_object.restype = None 1.99 + 1.100 + goat3d_add_node_child = libgoat.goat3d_add_node_child 1.101 + goat3d_add_node_child.argtypes = [c_void_p, c_void_p] 1.102 + goat3d_add_node_child.restype = None 1.103 + 1.104 + goat3d_set_node_position = libgoat.goat3d_set_node_position 1.105 + goat3d_set_node_position.argtypes = [c_void_p, c_float, c_float, c_float, c_long] 1.106 + goat3d_set_node_position.restype = None 1.107 + 1.108 + goat3d_set_node_rotation = libgoat.goat3d_set_node_rotation 1.109 + goat3d_set_node_rotation.argtypes = [c_void_p, c_float, c_float, c_float, c_float, c_long] 1.110 + goat3d_set_node_rotation.restype = None 1.111 + 1.112 + goat3d_set_node_scaling = libgoat.goat3d_set_node_scaling 1.113 + goat3d_set_node_scaling.argtypes = [c_void_p, c_float, c_float, c_float, c_long] 1.114 + goat3d_set_node_scaling.restype = None 1.115 + 1.116 + goat3d_set_node_pivot = libgoat.goat3d_set_node_pivot 1.117 + goat3d_set_node_pivot.argtypes = [c_void_p, c_float, c_float, c_float] 1.118 + goat3d_set_node_pivot.restype = None 1.119 + 1.120 + goat3d_save = libgoat.goat3d_save 1.121 + goat3d_save.argtypes = [c_void_p, c_char_p] 1.122 + 1.123 + # initiaize a goat3d object and start filling it up with data 1.124 + goat = goat3d_create() 1.125 + if not goat: 1.126 + oper.report({'ERROR'}, "Failed to create goat3d object") 1.127 + return False 1.128 + 1.129 + goat3d_save(goat, fname.encode('utf-8')) 1.130 + goat3d_free(goat) 1.131 + return True 1.132 + 1.133 +