4949import com .jme3 .terrain .heightmap .ImageBasedHeightMap ;
5050import com .jme3 .texture .Texture ;
5151import com .jme3 .util .SkyFactory ;
52+ import org .jmonkeyengine .screenshottests .testframework .Scenario ;
5253import org .jmonkeyengine .screenshottests .testframework .ScreenshotTestBase ;
5354import org .junit .jupiter .api .Test ;
5455
@@ -67,7 +68,7 @@ public class TestFog extends ScreenshotTestBase {
6768 */
6869 @ Test
6970 public void testFog () {
70- screenshotTest ( new BaseAppState () {
71+ screenshotMultiScenarioTest ( new Scenario ( "FullscreenQuad" , new BaseAppState () {
7172 @ Override
7273 protected void initialize (Application app ) {
7374 SimpleApplication simpleApplication = (SimpleApplication ) app ;
@@ -165,7 +166,105 @@ public void update(float tpf) {
165166 System .out .println (getApplication ().getCamera ().getLocation ());
166167 }
167168
168- })
169+ }),new Scenario ("FullscreenTriangle" ,new BaseAppState () {
170+ @ Override
171+ protected void initialize (Application app ) {
172+ SimpleApplication simpleApplication = (SimpleApplication ) app ;
173+ Node rootNode = simpleApplication .getRootNode ();
174+
175+ simpleApplication .getCamera ().setLocation (new Vector3f (-34.74095f , 95.21318f , -287.4945f ));
176+ simpleApplication .getCamera ().setRotation (new Quaternion (0.023536969f , 0.9361278f , -0.016098259f , -0.35050195f ));
177+
178+ Node mainScene = new Node ();
179+
180+ mainScene .attachChild (SkyFactory .createSky (simpleApplication .getAssetManager (),
181+ "Textures/Sky/Bright/BrightSky.dds" ,
182+ SkyFactory .EnvMapType .CubeMap ));
183+
184+ createTerrain (mainScene , app .getAssetManager ());
185+
186+ DirectionalLight sun = new DirectionalLight ();
187+ Vector3f lightDir = new Vector3f (-0.37352666f , -0.50444174f , -0.7784704f );
188+ sun .setDirection (lightDir );
189+ sun .setColor (ColorRGBA .White .clone ().multLocal (2 ));
190+ mainScene .addLight (sun );
191+
192+ rootNode .attachChild (mainScene );
193+
194+ FilterPostProcessor fpp = new FilterPostProcessor (simpleApplication .getAssetManager (),true );
195+
196+ FogFilter fog = new FogFilter ();
197+ fog .setFogColor (new ColorRGBA (0.9f , 0.9f , 0.9f , 1.0f ));
198+ fog .setFogDistance (155 );
199+ fog .setFogDensity (1.0f );
200+ fpp .addFilter (fog );
201+ simpleApplication .getViewPort ().addProcessor (fpp );
202+ }
203+
204+
205+ private void createTerrain (Node rootNode , AssetManager assetManager ) {
206+ Material matRock = new Material (assetManager , "Common/MatDefs/Terrain/TerrainLighting.j3md" );
207+ matRock .setBoolean ("useTriPlanarMapping" , false );
208+ matRock .setBoolean ("WardIso" , true );
209+ matRock .setTexture ("AlphaMap" , assetManager .loadTexture ("Textures/Terrain/splat/alphamap.png" ));
210+ Texture heightMapImage = assetManager .loadTexture ("Textures/Terrain/splat/mountains512.png" );
211+ Texture grass = assetManager .loadTexture ("Textures/Terrain/splat/grass.jpg" );
212+ grass .setWrap (Texture .WrapMode .Repeat );
213+ matRock .setTexture ("DiffuseMap" , grass );
214+ matRock .setFloat ("DiffuseMap_0_scale" , 64 );
215+ Texture dirt = assetManager .loadTexture ("Textures/Terrain/splat/dirt.jpg" );
216+ dirt .setWrap (Texture .WrapMode .Repeat );
217+ matRock .setTexture ("DiffuseMap_1" , dirt );
218+ matRock .setFloat ("DiffuseMap_1_scale" , 16 );
219+ Texture rock = assetManager .loadTexture ("Textures/Terrain/splat/road.jpg" );
220+ rock .setWrap (Texture .WrapMode .Repeat );
221+ matRock .setTexture ("DiffuseMap_2" , rock );
222+ matRock .setFloat ("DiffuseMap_2_scale" , 128 );
223+ Texture normalMap0 = assetManager .loadTexture ("Textures/Terrain/splat/grass_normal.jpg" );
224+ normalMap0 .setWrap (Texture .WrapMode .Repeat );
225+ Texture normalMap1 = assetManager .loadTexture ("Textures/Terrain/splat/dirt_normal.png" );
226+ normalMap1 .setWrap (Texture .WrapMode .Repeat );
227+ Texture normalMap2 = assetManager .loadTexture ("Textures/Terrain/splat/road_normal.png" );
228+ normalMap2 .setWrap (Texture .WrapMode .Repeat );
229+ matRock .setTexture ("NormalMap" , normalMap0 );
230+ matRock .setTexture ("NormalMap_1" , normalMap1 );
231+ matRock .setTexture ("NormalMap_2" , normalMap2 );
232+
233+ AbstractHeightMap heightmap = new ImageBasedHeightMap (heightMapImage .getImage (), 0.25f );
234+ heightmap .load ();
235+
236+ TerrainQuad terrain = new TerrainQuad ("terrain" , 65 , 513 , heightmap .getHeightMap ());
237+
238+ terrain .setMaterial (matRock );
239+ terrain .setLocalScale (new Vector3f (5 , 5 , 5 ));
240+ terrain .setLocalTranslation (new Vector3f (0 , -30 , 0 ));
241+ terrain .setLocked (false ); // unlock it so we can edit the height
242+
243+ terrain .setShadowMode (RenderQueue .ShadowMode .Receive );
244+ rootNode .attachChild (terrain );
245+
246+ }
247+
248+
249+ @ Override
250+ protected void cleanup (Application app ) {
251+ }
252+
253+ @ Override
254+ protected void onEnable () {
255+ }
256+
257+ @ Override
258+ protected void onDisable () {
259+ }
260+
261+ @ Override
262+ public void update (float tpf ) {
263+ super .update (tpf );
264+ System .out .println (getApplication ().getCamera ().getLocation ());
265+ }
266+
267+ }))
169268 .setFramesToTakeScreenshotsOn (1 )
170269 .run ();
171270 }
0 commit comments