1- import bpy
21import os
32import sys
3+
4+ import bpy
5+
46from io_xplane2blender .tests import *
57from io_xplane2blender .xplane_config import getDebug
68from io_xplane2blender .xplane_types import xplane_file
79
810__dirname__ = os .path .dirname (__file__ )
911
12+
1013class TestMaterials (XPlaneTestCase ):
1114 def test_material_attributes (self ):
12- xplaneFile = self .createXPlaneFileFromPotentialRoot (bpy .data .collections ["Layer 1" ])
13-
14- green = xplaneFile ._bl_obj_name_to_bone ['green' ].xplaneObject .material
15- red = xplaneFile ._bl_obj_name_to_bone ['red' ].xplaneObject .material
16- blue = xplaneFile ._bl_obj_name_to_bone ['blue' ].xplaneObject .material
17- emissive = xplaneFile ._bl_obj_name_to_bone ['emissive' ].xplaneObject .material
18- cockpit = xplaneFile ._bl_obj_name_to_bone ['cockpit' ].xplaneObject .material
19- cockpitPanel = xplaneFile ._bl_obj_name_to_bone ['cockpit_panel' ].xplaneObject .material
20- invisible = xplaneFile ._bl_obj_name_to_bone ['invisible' ].xplaneObject .material
21- surface = xplaneFile ._bl_obj_name_to_bone ['surface' ].xplaneObject .material
22- conditions = xplaneFile ._bl_obj_name_to_bone ['conditions' ].xplaneObject .material
23- specular = xplaneFile ._bl_obj_name_to_bone ['specular' ].xplaneObject .material
15+ xplaneFile = self .createXPlaneFileFromPotentialRoot (
16+ bpy .data .collections ["Layer 1" ]
17+ )
18+
19+ green = xplaneFile ._bl_obj_name_to_bone ["green" ].xplaneObject .material
20+ red = xplaneFile ._bl_obj_name_to_bone ["red" ].xplaneObject .material
21+ blue = xplaneFile ._bl_obj_name_to_bone ["blue" ].xplaneObject .material
22+ emissive = xplaneFile ._bl_obj_name_to_bone ["emissive" ].xplaneObject .material
23+ cockpit = xplaneFile ._bl_obj_name_to_bone ["cockpit" ].xplaneObject .material
24+ cockpitPanel = xplaneFile ._bl_obj_name_to_bone [
25+ "cockpit_panel"
26+ ].xplaneObject .material
27+ invisible = xplaneFile ._bl_obj_name_to_bone ["invisible" ].xplaneObject .material
28+ surface = xplaneFile ._bl_obj_name_to_bone ["surface" ].xplaneObject .material
29+ conditions = xplaneFile ._bl_obj_name_to_bone ["conditions" ].xplaneObject .material
30+ specular = xplaneFile ._bl_obj_name_to_bone ["specular" ].xplaneObject .material
2431
2532 defaultAttrs = {
26- ' ATTR_shiny_rat' : 1 ,
27- ' ATTR_hard' : None ,
28- ' ATTR_hard_deck' : None ,
29- ' ATTR_no_hard' : True ,
30- ' ATTR_blend' : True ,
31- ' ATTR_shadow_blend' : None ,
32- ' ATTR_no_blend' : None ,
33- ' ATTR_draw_enable' : True ,
34- ' ATTR_shadow' : True ,
35- ' ATTR_no_shadow' : False ,
36- ' ATTR_draw_disable' : None ,
37- ' ATTR_solid_camera' : None ,
38- ' ATTR_no_solid_camera' : True ,
39- ' ATTR_light_level' : None ,
40- ' ATTR_poly_os' : None ,
41- ' ATTR_draped' : None ,
42- ' ATTR_no_draped' : True
33+ " ATTR_shiny_rat" : 1 ,
34+ " ATTR_hard" : None ,
35+ " ATTR_hard_deck" : None ,
36+ " ATTR_no_hard" : True ,
37+ " ATTR_blend" : True ,
38+ " ATTR_shadow_blend" : None ,
39+ " ATTR_no_blend" : None ,
40+ " ATTR_draw_enable" : True ,
41+ " ATTR_shadow" : True ,
42+ " ATTR_no_shadow" : False ,
43+ " ATTR_draw_disable" : None ,
44+ " ATTR_solid_camera" : None ,
45+ " ATTR_no_solid_camera" : True ,
46+ " ATTR_light_level" : None ,
47+ " ATTR_poly_os" : None ,
48+ " ATTR_draped" : None ,
49+ " ATTR_no_draped" : True ,
4350 }
4451 defaultCockpitAttrs = {
45- 'ATTR_cockpit' : None ,
46- 'ATTR_no_cockpit' : True ,
47- 'ATTR_cockpit_region' : None
52+ "ATTR_cockpit" : None ,
53+ "ATTR_cockpit_lit_only" : None ,
54+ "ATTR_cockpit_region" : None ,
55+ "ATTR_no_cockpit" : True ,
4856 }
4957
5058 redAttrs = defaultAttrs .copy ()
@@ -56,48 +64,49 @@ def test_material_attributes(self):
5664 emissiveAttrs = defaultAttrs .copy ()
5765
5866 cockpitAttrs = defaultAttrs .copy ()
59- cockpitAttrs [' ATTR_shiny_rat' ] = 1.0
60- cockpitAttrs [' ATTR_blend' ] = True
61- cockpitAttrs [' ATTR_draw_enable' ] = True
62- cockpitAttrs [' ATTR_solid_camera' ] = True
63- cockpitAttrs [' ATTR_no_solid_camera' ] = False
64- cockpitAttrs [' ATTR_light_level' ] = [1.0 , 2.0 , ' light-level-test' ]
67+ cockpitAttrs [" ATTR_shiny_rat" ] = 1.0
68+ cockpitAttrs [" ATTR_blend" ] = True
69+ cockpitAttrs [" ATTR_draw_enable" ] = True
70+ cockpitAttrs [" ATTR_solid_camera" ] = True
71+ cockpitAttrs [" ATTR_no_solid_camera" ] = False
72+ cockpitAttrs [" ATTR_light_level" ] = [1.0 , 2.0 , " light-level-test" ]
6573 cockpitCockpitAttrs = defaultCockpitAttrs .copy ()
66- cockpitCockpitAttrs [' ATTR_cockpit' ] = None
67- cockpitCockpitAttrs [' ATTR_no_cockpit' ] = True
68- cockpitCockpitAttrs [' ATTR_cockpit_region' ] = None
74+ cockpitCockpitAttrs [" ATTR_cockpit" ] = None
75+ cockpitCockpitAttrs [" ATTR_no_cockpit" ] = True
76+ cockpitCockpitAttrs [" ATTR_cockpit_region" ] = None
6977
7078 cockpitPanelAttrs = defaultAttrs .copy ()
71- cockpitPanelAttrs [' ATTR_shiny_rat' ] = None
72- cockpitPanelAttrs [' ATTR_blend' ] = None
73- cockpitPanelAttrs [' ATTR_draw_enable' ] = True
79+ cockpitPanelAttrs [" ATTR_shiny_rat" ] = None
80+ cockpitPanelAttrs [" ATTR_blend" ] = None
81+ cockpitPanelAttrs [" ATTR_draw_enable" ] = True
7482 cockpitPanelAttrs ["ATTR_shadow" ] = None
7583 cockpitPanelAttrs ["ATTR_no_shadow" ] = None
76- cockpitPanelAttrs [' ATTR_solid_camera' ] = True
77- cockpitPanelAttrs [' ATTR_no_solid_camera' ] = False
84+ cockpitPanelAttrs [" ATTR_solid_camera" ] = True
85+ cockpitPanelAttrs [" ATTR_no_solid_camera" ] = False
7886 cockpitPanelCockpitAttrs = defaultCockpitAttrs .copy ()
79- cockpitPanelCockpitAttrs ['ATTR_cockpit' ] = True
80- cockpitPanelCockpitAttrs ['ATTR_no_cockpit' ] = None
81- cockpitPanelCockpitAttrs ['ATTR_cockpit_region' ] = 0
87+ cockpitPanelCockpitAttrs ["ATTR_cockpit" ] = True
88+ cockpitPanelCockpitAttrs ["ATTR_cockpit_lit_only" ] = None
89+ cockpitPanelCockpitAttrs ["ATTR_cockpit_region" ] = 0
90+ cockpitPanelCockpitAttrs ["ATTR_no_cockpit" ] = None
8291
8392 invisibleAttrs = defaultAttrs .copy ()
84- invisibleAttrs [' ATTR_shiny_rat' ] = None
85- invisibleAttrs [' ATTR_blend' ] = None
86- invisibleAttrs [' ATTR_draw_enable' ] = None
87- invisibleAttrs [' ATTR_draw_disable' ] = True
93+ invisibleAttrs [" ATTR_shiny_rat" ] = None
94+ invisibleAttrs [" ATTR_blend" ] = None
95+ invisibleAttrs [" ATTR_draw_enable" ] = None
96+ invisibleAttrs [" ATTR_draw_disable" ] = True
8897 invisibleAttrs ["ATTR_shadow" ] = None
8998 invisibleAttrs ["ATTR_no_shadow" ] = None
9099
91100 surfaceAttrs = defaultAttrs .copy ()
92- surfaceAttrs [' ATTR_no_hard' ] = None
93- surfaceAttrs [' ATTR_hard_deck' ] = ' asphalt'
94- surfaceAttrs [' ATTR_poly_os' ] = 2
101+ surfaceAttrs [" ATTR_no_hard" ] = None
102+ surfaceAttrs [" ATTR_hard_deck" ] = " asphalt"
103+ surfaceAttrs [" ATTR_poly_os" ] = 2
95104
96105 conditionsAttrs = defaultAttrs .copy ()
97- conditionsAttrs [' custom_prop' ] = '10'
106+ conditionsAttrs [" custom_prop" ] = "10"
98107
99108 specularAttrs = defaultAttrs .copy ()
100- specularAttrs [' ATTR_shiny_rat' ] = 0.25
109+ specularAttrs [" ATTR_shiny_rat" ] = 0.25
101110
102111 self .assertAttributesEqualDict (red .attributes , redAttrs )
103112 self .assertAttributesEqualDict (red .cockpitAttributes , defaultCockpitAttrs )
@@ -115,7 +124,9 @@ def test_material_attributes(self):
115124 self .assertAttributesEqualDict (cockpit .cockpitAttributes , cockpitCockpitAttrs )
116125
117126 self .assertAttributesEqualDict (cockpitPanel .attributes , cockpitPanelAttrs )
118- self .assertAttributesEqualDict (cockpitPanel .cockpitAttributes , cockpitPanelCockpitAttrs )
127+ self .assertAttributesEqualDict (
128+ cockpitPanel .cockpitAttributes , cockpitPanelCockpitAttrs
129+ )
119130
120131 self .assertAttributesEqualDict (invisible .attributes , invisibleAttrs )
121132 self .assertAttributesEqualDict (invisible .cockpitAttributes , defaultCockpitAttrs )
@@ -124,20 +135,24 @@ def test_material_attributes(self):
124135 self .assertAttributesEqualDict (surface .cockpitAttributes , defaultCockpitAttrs )
125136
126137 self .assertAttributesEqualDict (conditions .attributes , conditionsAttrs )
127- self .assertAttributesEqualDict (conditions .cockpitAttributes , defaultCockpitAttrs )
138+ self .assertAttributesEqualDict (
139+ conditions .cockpitAttributes , defaultCockpitAttrs
140+ )
128141
129142 self .assertAttributesEqualDict (specular .attributes , specularAttrs )
130143 self .assertAttributesEqualDict (specular .cockpitAttributes , defaultCockpitAttrs )
131144
132145 def test_export_materials (self ):
133146 def filterLines (line ):
134- return isinstance (line [0 ], str ) and line [0 ].find (' ATTR_' ) == 0
147+ return isinstance (line [0 ], str ) and line [0 ].find (" ATTR_" ) == 0
135148
136- filename = ' test_materials'
149+ filename = " test_materials"
137150 self .assertLayerExportEqualsFixture (
138- 0 , os .path .join (__dirname__ , 'fixtures' , filename + '.obj' ),
151+ 0 ,
152+ os .path .join (__dirname__ , "fixtures" , filename + ".obj" ),
139153 filterLines ,
140154 filename ,
141155 )
142156
157+
143158runTestCases ([TestMaterials ])
0 commit comments