morse-simulator/morse — pull request #527 by HorvathJo (2014-04-14 07:32:00+00:00)
Title: [sensors] added a remission_list to a new level laserscanner

Change/Work list:
- LaserScanner has now 2 levels: "raw" (old one) and "rssi"
- added a list with remission values (the specular_intensity of the material for every scanpoint) for the LaserScanner on the new level "rssi"
- run pylint on laserscanner.py

I know that the workaround to get the material property is not nice (parsing the name), but I didn't find another way.

"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. " (comment in laserscanner.py)

But if the parsing should fail, a detailed error message is displayed for easier troubleshooting

Path to the remission values:
- rayCast [1]; option poly = 1
- target_poly [2]
- getMaterialName() [3]; material is KX_BlenderMaterial [4]
- parse the name (remove leading "MA")
- bpymorse.get_material(name)
- Goal: material.specular_intensity

A better way would be if the material would be KX_PolygonMaterial [5], but I don't know when that is the case.

Please let me know you suggestions of improvements.
Cheers,
Johannes

[1] http://www.blender.org/documentation/blender_python_api_2_63_17/bge.types.html#bge.types.KX_GameObject.rayCast
[2] http://www.blender.org/documentation/blender_python_api_2_63_17/bge.types.html#bge.types.KX_PolyProxy
[3] http://www.blender.org/documentation/blender_python_api_2_63_17/bge.types.html#bge.types.KX_PolyProxy.getMaterialName
[4] http://www.blender.org/documentation/blender_python_api_2_63_17/bge.types.html#bge.types.KX_BlenderMaterial
[5] http://www.blender.org/documentation/blender_python_api_2_63_17/bge.types.html#bge.types.KX_PolygonMaterial