Browse Source

Blender: Let texture export use numeric constants.

tschw 10 years ago
parent
commit
3f200147f1

+ 20 - 0
utils/exporters/blender/addons/io_three/constants.py

@@ -32,6 +32,26 @@ MAPPING_TYPES = type('Mapping', (), {
     'SPHERICAL_REFLECTION': 'SphericalReflectionMapping'
     'SPHERICAL_REFLECTION': 'SphericalReflectionMapping'
 })
 })
 
 
+NUMERIC = {
+    'UVMapping': 300,
+    'CubeReflectionMapping': 301,
+    'CubeRefractionMapping': 302,
+    'EquirectangularReflectionMapping': 303,
+    'EquirectangularRefractionMapping': 304,
+    'SphericalReflectionMapping': 305,
+
+    'RepeatWrapping': 1000,
+    'ClampToEdgeWrapping': 1001,
+    'MirroredRepeatWrapping': 1002,
+
+    'NearestFilter': 1003,
+    'NearestMipMapNearestFilter': 1004,
+    'NearestMipMapLinearFilter': 1005,
+    'LinearFilter': 1006,
+    'LinearMipMapNearestFilter': 1007,
+    'LinearMipMapLinearFilter': 1008
+}
+
 JSON = 'json'
 JSON = 'json'
 EXTENSION = '.%s' % JSON
 EXTENSION = '.%s' % JSON
 INDENT = 'indent'
 INDENT = 'indent'

+ 9 - 6
utils/exporters/blender/addons/io_three/exporter/texture.py

@@ -8,6 +8,8 @@ class Texture(base_classes.BaseNode):
         logger.debug("Texture().__init__(%s)", node)
         logger.debug("Texture().__init__(%s)", node)
         base_classes.BaseNode.__init__(self, node, parent, constants.TEXTURE)
         base_classes.BaseNode.__init__(self, node, parent, constants.TEXTURE)
 
 
+        num = constants.NUMERIC
+
         img_inst = self.scene.image(api.texture.file_name(self.node))
         img_inst = self.scene.image(api.texture.file_name(self.node))
 
 
         if not img_inst:
         if not img_inst:
@@ -15,18 +17,19 @@ class Texture(base_classes.BaseNode):
             img_inst = image.Image(image_node.name, self.scene)
             img_inst = image.Image(image_node.name, self.scene)
             self.scene[constants.IMAGES].append(img_inst)
             self.scene[constants.IMAGES].append(img_inst)
 
 
+
         self[constants.IMAGE] = img_inst[constants.UUID]
         self[constants.IMAGE] = img_inst[constants.UUID]
 
 
-        self[constants.WRAP] = api.texture.wrap(self.node)
+        wrap = api.texture.wrap(self.node)
+        self[constants.WRAP] = (num[wrap[0]], num[wrap[1]])
 
 
-        if constants.WRAPPING.REPEAT in self[constants.WRAP]:
+        if constants.WRAPPING.REPEAT in wrap:
             self[constants.REPEAT] = api.texture.repeat(self.node)
             self[constants.REPEAT] = api.texture.repeat(self.node)
 
 
         self[constants.ANISOTROPY] = api.texture.anisotropy(self.node)
         self[constants.ANISOTROPY] = api.texture.anisotropy(self.node)
-        self[constants.MAG_FILTER] = api.texture.mag_filter(self.node)
-        self[constants.MIN_FILTER] = api.texture.min_filter(self.node)
-        self[constants.MAPPING] = api.texture.mapping(self.node)
-
+        self[constants.MAG_FILTER] = num[api.texture.mag_filter(self.node)]
+        self[constants.MIN_FILTER] = num[api.texture.min_filter(self.node)]
+        self[constants.MAPPING] = num[api.texture.mapping(self.node)]
 
 
     @property
     @property
     def image(self):
     def image(self):