__init__.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. bl_info = {
  20. "name": "Quake MAP format",
  21. "author": "Campbell Barton",
  22. "blender": (2, 57, 0),
  23. "location": "File > Export",
  24. "description": "Export MAP brushes, nurbs surfaces, "
  25. "lamps and empties as map nodes",
  26. "warning": "",
  27. "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
  28. "Scripts/Import-Export/Quake_MAP",
  29. "tracker_url": "",
  30. "support": 'OFFICIAL',
  31. "category": "Import-Export"}
  32. # To support reload properly, try to access a package var, if it's there, reload everything
  33. if "bpy" in locals():
  34. import imp
  35. if "export_map" in locals():
  36. imp.reload(export_map)
  37. import bpy
  38. from bpy.props import StringProperty, FloatProperty, BoolProperty
  39. from bpy_extras.io_utils import ExportHelper
  40. class ExportMAP(bpy.types.Operator, ExportHelper):
  41. """Export selection to a quake map"""
  42. bl_idname = "export_scene.quake_map"
  43. bl_label = "Export MAP"
  44. bl_options = {'PRESET'}
  45. filename_ext = ".map"
  46. filter_glob = StringProperty(default="*.map", options={'HIDDEN'})
  47. face_thickness = FloatProperty(
  48. name="Face Thickness",
  49. description=("Thickness given to geometry which can't be "
  50. "converted into a brush"),
  51. min=0.0001, max=10.0,
  52. default=0.1,
  53. )
  54. global_scale = FloatProperty(
  55. name="Scale",
  56. description="Scale everything by this value",
  57. min=0.01, max=1000.0,
  58. default=100.0,
  59. )
  60. grid_snap = BoolProperty(
  61. name="Grid Snap",
  62. description="Round to whole numbers",
  63. default=False,
  64. )
  65. texture_null = StringProperty(
  66. name="Tex Null",
  67. description="Texture used when none is assigned",
  68. default="NULL",
  69. )
  70. texture_opts = StringProperty(
  71. name="Tex Opts",
  72. description="Brush texture options",
  73. default='0 0 0 1 1 0 0 0',
  74. )
  75. def execute(self, context):
  76. # import math
  77. # from mathutils import Matrix
  78. if not self.filepath:
  79. raise Exception("filepath not set")
  80. '''
  81. global_matrix = Matrix()
  82. global_matrix[0][0] = global_matrix[1][1] = global_matrix[2][2] = self.global_scale
  83. global_matrix = global_matrix * axis_conversion(to_forward=self.axis_forward, to_up=self.axis_up).to_4x4()
  84. keywords = self.as_keywords(ignore=("axis_forward", "axis_up", "global_scale", "check_existing", "filter_glob"))
  85. keywords["global_matrix"] = global_matrix
  86. '''
  87. keywords = self.as_keywords(ignore=("check_existing", "filter_glob"))
  88. from . import export_map
  89. return export_map.save(self, context, **keywords)
  90. def menu_func(self, context):
  91. self.layout.operator(ExportMAP.bl_idname, text="Quake MAP (.map)")
  92. def register():
  93. bpy.utils.register_module(__name__)
  94. bpy.types.INFO_MT_file_export.append(menu_func)
  95. def unregister():
  96. bpy.utils.unregister_module(__name__)
  97. bpy.types.INFO_MT_file_export.remove(menu_func)
  98. if __name__ == "__main__":
  99. register()