material = definitions_asset.retrieve_material(surface.material_name) effect = material.get('effect', DEFAULT_EFFECT_NAME) effect_name = "effect-%s" % shape_name material_name = "material-%s" % surface.material_name instance_name = "instance-%s-%s" % (shape_name, surface_name) json_asset.attach_effect(effect_name, effect) mat_params = material.get('parameters', None) json_asset.attach_material(material_name, effect=effect, parameters=mat_params) def textures(mat_params): for k, v in mat_params.iteritems(): # If a paramater of a material has a string value, it is assumed to be a texture definition if isinstance(v, basestring): # Return the type of the texture (e.g. 'diffuse') yield k for t_type in textures(mat_params): json_asset.attach_texture(material_name, t_type, mat_params[t_type]) first = surface.first last = first + surface.count json_asset.attach_surface(asset.primitives[first:last], JsonAsset.SurfaceTriangles, shape_name, name=surface_name) json_asset.attach_node_shape_instance(node_name, instance_name, shape_name, material_name, surface=surface_name) json_asset.attach_bbox(asset.bbox) standard_json_out(json_asset, output_filename, options) return json_asset if __name__ == "__main__": standard_main(parse, __version__, "Convert LightWave (.obj) OBJ2 files into a Turbulenz JSON asset. Supports generating NBTs.", __dependencies__)
LOG.error('Failed processing:%s' % input_filename) LOG.error(' >> %s' % e) else: json_asset = JsonAsset() for mat_name, material in materials.iteritems(): effect = material.pop('effect', None) technique = material.pop('technique', None) meta = material.pop('meta', None) json_asset.attach_material(mat_name, effect, technique, material, meta) standard_json_out(json_asset, output_filename, options) return json_asset except IOError as e: LOG.error('Failed processing: %s' % output_filename) LOG.error(' >> %s' % e) return None if __name__ == "__main__": try: standard_main( parse, __version__, "Convert Material Yaml (.material) files into a Turbulenz JSON asset.", __dependencies__) # pylint: disable=W0703 except Exception as err: LOG.critical('Unexpected exception: %s' % err) exit(1) # pylint: enable=W0703
LOG.error('Failed processing: %s' % input_filename) LOG.error(' >> %s' % e) else: json_asset = JsonAsset() for effect_name, effect_parameters in effects.iteritems(): effect_type = effect_parameters.pop('type', None) shader = effect_parameters.pop('shader', None) meta = effect_parameters.pop('meta', None) json_asset.attach_effect(effect_name, effect_type, effect_parameters, shader, meta) standard_json_out(json_asset, output_filename, options) return json_asset except IOError as e: LOG.error('Failed processing: %s' % output_filename) LOG.error(' >> %s' % e) return None if __name__ == "__main__": try: standard_main( parse, __version__, "Convert Effect Yaml (.effect) files into a Turbulenz JSON asset.", __dependencies__) # pylint: disable=W0703 except Exception as err: LOG.critical('Unexpected exception: %s' % err) exit(1) # pylint: enable=W0703
# pylint: disable=E1101 except yaml.scanner.ScannerError as e: # pylint: enable=E1101 LOG.error('Failed processing: %s' % input_filename) LOG.error(' >> %s' % e) else: json_asset = JsonAsset() for effect_name, effect_parameters in effects.iteritems(): effect_type = effect_parameters.pop('type', None) shader = effect_parameters.pop('shader', None) meta = effect_parameters.pop('meta', None) json_asset.attach_effect(effect_name, effect_type, effect_parameters, shader, meta) standard_json_out(json_asset, output_filename, options) return json_asset except IOError as e: LOG.error('Failed processing: %s' % output_filename) LOG.error(' >> %s' % e) return None if __name__ == "__main__": try: standard_main(parse, __version__, "Convert Effect Yaml (.effect) files into a Turbulenz JSON asset.", __dependencies__) # pylint: disable=W0703 except Exception as err: LOG.critical('Unexpected exception: %s' % err) exit(1) # pylint: enable=W0703
# pylint: disable=E1101 except yaml.scanner.ScannerError as e: # pylint: enable=E1101 LOG.error('Failed processing:%s' % input_filename) LOG.error(' >> %s' % e) else: json_asset = JsonAsset() for mat_name, material in materials.iteritems(): effect = material.pop('effect', None) technique = material.pop('technique', None) meta = material.pop('meta', None) json_asset.attach_material(mat_name, effect, technique, material, meta) standard_json_out(json_asset, output_filename, options) return json_asset except IOError as e: LOG.error('Failed processing: %s' % output_filename) LOG.error(' >> %s' % e) return None if __name__ == "__main__": try: standard_main(parse, __version__, "Convert Material Yaml (.material) files into a Turbulenz JSON asset.", __dependencies__) # pylint: disable=W0703 except Exception as err: LOG.critical('Unexpected exception: %s' % err) exit(1) # pylint: enable=W0703