Example #1
0
    def __init__(self, name, rTransmittance=0, gTransmittance=0, bTransmittance=0,
                 refraction=1.52, modifier="void"):
        """Create glass material.

        Attributes:
            name: Material name as a string. Do not use white space and special character.
            rTransmittance: Transmittance for red. The value should be between 0 and 1 (Default: 0).
            gTransmittance: Transmittance for green. The value should be between 0 and 1 (Default: 0).
            bTransmittance: Transmittance for blue. The value should be between 0 and 1 (Default: 0).
            refraction: Index of refraction. 1.52 for glass and 1.4 for ETFE (Default: 1.52).
            modifier: Material modifier (Default: "void").

        Usage:
            glassMaterial = GlassMaterial("generic glass", .65, .65, .65)
            print glassMaterial
        """
        RadianceMaterial.__init__(self, name, materialType="glass", modifier="void")
        self.rTransmittance = rTransmittance
        """Transmittance for red. The value should be between 0 and 1 (Default: 0)."""
        self.gTransmittance = gTransmittance
        """Transmittance for green. The value should be between 0 and 1 (Default: 0)."""
        self.bTransmittance = bTransmittance
        """Transmittance for blue. The value should be between 0 and 1 (Default: 0)."""
        self.refractionIndex = refraction
        """Index of refraction. 1.52 for glass and 1.4 for ETFE (Default: 1.52)."""
Example #2
0
    def __init__(self, name, rReflectance=0, gReflectance=0, bReflectance=0,
                 specularity=0, roughness=0, modifier="void"):
        """Create metal material.

        Attributes:
            name: Material name as a string. Do not use white space and special character.
            rReflectance: Reflectance for red. The value should be between 0 and 1 (Default: 0).
            gReflectance: Reflectance for green. The value should be between 0 and 1 (Default: 0).
            bReflectance: Reflectance for blue. The value should be between 0 and 1 (Default: 0).
            specularity: Fraction of specularity. Specularity fractions greater than 0.1 are
                not realistic (Default: 0).
            roughness: Roughness is specified as the rms slope of surface facets. A value of 0
                corresponds to a perfectly smooth surface, and a value of 1 would be a very rough
                surface. Roughness values greater than 0.2 are not very realistic. (Default: 0).
            modifier: Material modifier (Default: "void").

        Usage:
            wallMaterial = MetalMaterial("generic wall", .55, .65, .75)
            print wallMaterial
        """
        RadianceMaterial.__init__(self, name, materialType="metal", modifier="void")
        self.rReflectance = rReflectance
        """Reflectance for red. The value should be between 0 and 1 (Default: 0)."""
        self.gReflectance = gReflectance
        """Reflectance for green. The value should be between 0 and 1 (Default: 0)."""
        self.bReflectance = bReflectance
        """Reflectance for blue. The value should be between 0 and 1 (Default: 0)."""
        self.specularity = specularity
        """Fraction of specularity. Specularity fractions greater than 0.1 are not
           realistic (Default: 0)."""
        self.roughness = roughness
        """Roughness is specified as the rms slope of surface facets. A value of 0
Example #3
0
    def __init__(self, name, r_transmittance=0, g_transmittance=0, b_transmittance=0,
                 refraction=1.52, modifier="void"):
        """Create glass material.

        Attributes:
            name: Material name as a string. Do not use white space and special character
            r_transmittance: Transmittance for red. The value should be between 0 and 1
                (Default: 0).
            g_transmittance: Transmittance for green. The value should be between 0 and 1
                (Default: 0).
            b_transmittance: Transmittance for blue. The value should be between 0 and 1
                (Default: 0).
            refraction: Index of refraction. 1.52 for glass and 1.4 for ETFE
                (Default: 1.52).
            modifier: Material modifier (Default: "void").

        Usage:
            glassMaterial = GlassMaterial("generic glass", .65, .65, .65)
            print(glassMaterial)
        """
        RadianceMaterial.__init__(self, name, material_type="glass", modifier="void")
        self.r_transmittance = r_transmittance
        """Transmittance for red. The value should be between 0 and 1 (Default: 0)."""
        self.g_transmittance = g_transmittance
        """Transmittance for green. The value should be between 0 and 1 (Default: 0)."""
        self.b_transmittance = b_transmittance
        """Transmittance for blue. The value should be between 0 and 1 (Default: 0)."""
        self.refractionIndex = refraction
        """Index of refraction. 1.52 for glass and 1.4 for ETFE (Default: 1.52)."""
Example #4
0
    def __init__(self, name, rReflectance=0, gReflectance=0, bReflectance=0,
                 specularity=0, roughness=0, modifier="void"):
        """Create plastic material.

        Attributes:
            name: Material name as a string. Do not use white space and special character.
            rReflectance: Reflectance for red. The value should be between 0 and 1 (Default: 0).
            gReflectance: Reflectance for green. The value should be between 0 and 1 (Default: 0).
            bReflectance: Reflectance for blue. The value should be between 0 and 1 (Default: 0).
            specularity: Fraction of specularity. Specularity fractions greater than 0.1 are
                not realistic (Default: 0).
            roughness: Roughness is specified as the rms slope of surface facets. A value of 0
                corresponds to a perfectly smooth surface, and a value of 1 would be a very rough
                surface. Roughness values greater than 0.2 are not very realistic. (Default: 0).
            modifier: Material modifier (Default: "void").

        Usage:
            wallMaterial = PlasticMaterial("generic wall", .55, .65, .75)
            print wallMaterial
        """
        RadianceMaterial.__init__(self, name, materialType="plastic", modifier="void")
        self.rReflectance = rReflectance
        """Reflectance for red. The value should be between 0 and 1 (Default: 0)."""
        self.gReflectance = gReflectance
        """Reflectance for green. The value should be between 0 and 1 (Default: 0)."""
        self.bReflectance = bReflectance
        """Reflectance for blue. The value should be between 0 and 1 (Default: 0)."""
        self.specularity = specularity
        """Fraction of specularity. Specularity fractions greater than 0.1 are not
           realistic (Default: 0)."""
        self.roughness = roughness
        """Roughness is specified as the rms slope of surface facets. A value of 0
Example #5
0
    def __init__(self,
                 xmlfile,
                 up_orientation=None,
                 thickness=None,
                 modifier="void"):
        """Create BSDF material."""
        assert os.path.isfile(xmlfile), 'Invalid path: {}'.format(xmlfile)
        assert xmlfile.lower().endswith('.xml'), 'Invalid xml file: {}'.format(
            xmlfile)

        self.xmlfile = os.path.normpath(xmlfile)

        name = '.'.join(os.path.split(self.xmlfile)[-1].split('.')[:-1])

        RadianceMaterial.__init__(self,
                                  name,
                                  material_type="BSDF",
                                  modifier=modifier)
        try:
            x, y, z = up_orientation or (0.01, 0.01, 1.00)
        except TypeError as e:
            try:
                # Dynamo!
                x, y, z = up_orientation.X, up_orientation.Y, up_orientation.Z
            except AttributeError:
                # raise the original error
                raise TypeError(str(e))

        self.up_orientation = x, y, z
        self.thickness = thickness or 0
Example #6
0
    def __init__(self,
                 xmlfile,
                 up_orientation=None,
                 thickness=None,
                 modifier="void"):
        """Create BSDF material."""
        assert os.path.isfile(xmlfile), 'Invalid path: {}'.format(xmlfile)
        assert xmlfile.lower().endswith('.xml'), 'Invalid xml file: {}'.format(
            xmlfile)

        self.xmlfile = os.path.normpath(xmlfile)

        name = '.'.join(os.path.split(self.xmlfile)[-1].split('.')[:-1])

        RadianceMaterial.__init__(self,
                                  name,
                                  material_type="BSDF",
                                  modifier=modifier)

        try:
            x, y, z = up_orientation or (0.01, 0.01, 1.00)
        except TypeError as e:
            try:
                # Dynamo!
                x, y, z = up_orientation.X, up_orientation.Y, up_orientation.Z
            except AttributeError:
                # raise the original error
                raise TypeError(str(e))

        self.up_orientation = x, y, z

        self.thickness = thickness or 0

        with open(self.xmlfile, 'rb') as inf:
            for count, line in enumerate(inf):
                if line.strip().startswith('<AngleBasisName>'):
                    self._angle_basis = line.replace('<AngleBasisName>', '') \
                        .replace('</AngleBasisName>', '').replace('LBNL/', '').strip()
                    break

                assert count < 100, 'Failed to find AngleBasisName in first 100 lines.'
Example #7
0
    def __init__(self,
                 xmlfile,
                 upOrientation=None,
                 thickness=None,
                 modifier="void"):
        """Create BSDF material."""
        assert os.path.isfile(xmlfile), 'Invalid path: {}'.format(xmlfile)
        assert xmlfile.lower().endswith('.xml'), 'Invalid xml file: {}'.format(
            xmlfile)

        self.xmlfile = os.path.normpath(xmlfile)

        name = '.'.join(os.path.split(self.xmlfile)[-1].split('.')[:-1])

        RadianceMaterial.__init__(self,
                                  name,
                                  materialType="BSDF",
                                  modifier=modifier)
        x, y, z = upOrientation or (0.01, 0.01, 1.00)
        self.upOrientation = x, y, z
        self.thickness = thickness or 0
Example #8
0
    def __init__(self, name, red=0, green=0, blue=0):
        """
        Create light material
        Attributes:

            name: Material name as a string. The name should not have whitespaces or
                special characters.
            red: A positive value for the Red channel of the light
            green: A positive value for the Green channel of the light
            blue: A positive value for the Blue channel of the light
            modifer: Material modifier. The default value is void.
        """
        RadianceMaterial.__init__(self,
                                  name,
                                  material_type='light',
                                  modifier='void')
        self.red = red
        """A positive value for the Red channel of the light"""
        self.green = green
        """A positive value for the Green channel of the light"""
        self.blue = blue
        """A positive value for the Blue channel of the light"""
Example #9
0
 def __init__(self, name, materialType, values={}, modifier="void"):
     """Create custom radiance material."""
     RadianceMaterial.__init__(self, name, materialType, modifier="void")
     self.values = values
     """ A dictionary of material data. key is line number and item is the list of values
Example #10
0
 def __init__(self, name, material_type, values={}, modifier="void"):
     """Create custom radiance material."""
     RadianceMaterial.__init__(self, name, material_type, modifier="void")
     self.values = values
     """ A dictionary of material data. key is line number and item is the list of values