@@ -79,8 +79,8 @@ def test__render(self):
7979
8080class OpaqueRenderingStage (testsuite .CarnaRenderingTestCase ):
8181
82- def test (self ):
83- # .. OpaqueRenderingStage: example-start
82+ def setUp (self ):
83+ # .. OpaqueRenderingStage: example-setup- start
8484 GEOMETRY_TYPE_OPAQUE = 1
8585
8686 # Create and configure frame renderer
@@ -119,19 +119,45 @@ def test(self):
119119 projection = r .frustum (fov = np .pi / 2 , z_near = 1 , z_far = 1e3 ),
120120 local_transform = carna .math .translation (0 , 0 , 250 ),
121121 )
122+ # .. OpaqueRenderingStage: example-setup-end
122123
123- # Render scene
124+ self .r , self .camera = r , camera
125+
126+ def test (self ):
127+ r , camera = self .r , self .camera
128+
129+ # .. OpaqueRenderingStage: example-single-frame-start
124130 array = r .render (camera )
125- # .. OpaqueRenderingStage: example-end
131+ # .. OpaqueRenderingStage: example-single-frame- end
126132
127133 # Verify result
128134 self .assert_image_almost_expected (array )
129135
136+ def test__animated (self ):
137+ r , camera = self .r , self .camera
138+
139+ # Render the scene once
140+ # .. OpaqueRenderingStage: example-animation-start
141+ # Define animation
142+ animation = carna .animation (
143+ [
144+ carna .animation .rotate_local (camera )
145+ ],
146+ n_frames = 50 ,
147+ )
148+
149+ # Render animation
150+ frames = list (animation .render (r , camera ))
151+ # .. OpaqueRenderingStage: example-animation-end
152+
153+ # Verify result
154+ self .assert_image_almost_expected (np .array (frames ))
155+
130156
131157class MaskRenderingStage (testsuite .CarnaRenderingTestCase ):
132158
133- def test (self ):
134- # .. MaskRenderingStage: example-start
159+ def setUp (self ):
160+ # .. MaskRenderingStage: example-setup- start
135161 GEOMETRY_TYPE_VOLUME = 2
136162
137163 # Create and configure frame renderer
@@ -158,10 +184,32 @@ def test(self):
158184 projection = r .frustum (fov = np .pi / 2 , z_near = 1 , z_far = 500 ),
159185 local_transform = carna .math .translation (0 , 0 , 100 ),
160186 )
187+ # .. MaskRenderingStage: example-setup-end
188+
189+ self .r , self .camera = r , camera
190+
191+ def test (self ):
192+ r , camera = self .r , self .camera
161193
162194 # Render scene
163195 array = r .render (camera )
164- # .. MaskRenderingStage: example-end
165196
166197 # Verify result
167- self .assert_image_almost_expected (array )
198+ self .assert_image_almost_expected (array )
199+
200+ def test__animated (self ):
201+ r , camera = self .r , self .camera
202+
203+ # Define animation
204+ animation = carna .animation (
205+ [
206+ carna .animation .rotate_local (camera )
207+ ],
208+ n_frames = 50 ,
209+ )
210+
211+ # Render animation
212+ frames = list (animation .render (r , camera ))
213+
214+ # Verify result
215+ self .assert_image_almost_expected (np .array (frames ))
0 commit comments