Esempio n. 1
0
    def getRSSIValue(self, target):
        """
        IMPORTANT:
        To get the material property a workaround is needed.
        The material from the targets is KX_BlenderMaterial (and not
        KX_PolygonMaterial). So the properties are not accessible.
        Workaround:
        Get material name of the GameObject and then use the method
        bpymorse.get_material(name).
        Material name must be parsed because of the prefix 'MA' in Blender;
        before the name is used to get the material properties.
        """
        mat_name = target.getMaterialName()
        try:
            mat_name = mat_name[2:]
            mat = bpymorse.get_material(mat_name)
            if mat:
                return mat.specular_intensity

        except:
            logger.error("Error: Could not parse material name %s. \
                    The leading 'MA' (prefix in Blender) is missing. \
                    Please check on the material name and the source file \
                    /src/morse/sensors/laserscanner.py the method \
                    'default_action' in the class LaserScannner_RSSI, \
                    where the name is parsed." % mat_name)
            return -1
Esempio n. 2
0
    def getRSSIValue(self, target):

        """
        IMPORTANT:
        To get the material property a workaround is needed.
        The material from the targets is KX_BlenderMaterial (and not
        KX_PolygonMaterial). So the properties are not accessible.
        Workaround:
        Get material name of the GameObject and then use the method
        bpymorse.get_material(name).
        Material name must be parsed because of the prefix 'MA' in Blender;
        before the name is used to get the material properties.
        """
        mat_name = target.getMaterialName()
        try: 
            mat_name = mat_name[2:]
            mat = bpymorse.get_material(mat_name)
            if mat:
                return mat.specular_intensity

        except:
            logger.error("Error: Could not parse material name %s. \
                    The leading 'MA' (prefix in Blender) is missing. \
                    Please check on the material name and the source file \
                    /src/morse/sensors/laserscanner.py the method \
                    'default_action' in the class LaserScannner_RSSI, \
                    where the name is parsed."%mat_name)
            return -1              
Esempio n. 3
0
 def color(self, r=0.1, g=0.1, b=0.1):
     if not self._bpy_object.active_material:
         all_materials = bpymorse.get_materials().keys()
         bpymorse.new_material()
         material_name = [name for name in bpymorse.get_materials().keys() \
                          if name not in all_materials].pop()
         # link material to object
         self._bpy_object.active_material = bpymorse.get_material(material_name)
     self._bpy_object.active_material.diffuse_color = (r, g, b)