|
| 1 | +package com.jme3.shadow; |
| 2 | + |
| 3 | +import com.jme3.asset.AssetManager; |
| 4 | +import com.jme3.asset.DesktopAssetManager; |
| 5 | +import com.jme3.export.binary.BinaryExporter; |
| 6 | +import com.jme3.light.DirectionalLight; |
| 7 | +import com.jme3.light.PointLight; |
| 8 | +import com.jme3.light.SpotLight; |
| 9 | +import com.jme3.math.ColorRGBA; |
| 10 | +import com.jme3.math.Vector3f; |
| 11 | +import com.jme3.post.Filter; |
| 12 | +import com.jme3.post.FilterPostProcessor; |
| 13 | +import org.junit.Assert; |
| 14 | +import org.junit.Test; |
| 15 | + |
| 16 | +/** |
| 17 | + * Automated tests for the {@code FilterPostProcessing} class. |
| 18 | + * |
| 19 | + * @author capdevon |
| 20 | + */ |
| 21 | +public class FilterPostProcessingTest { |
| 22 | + |
| 23 | + /** |
| 24 | + * Tests serialization and de-serialization of a {@code FilterPostProcessing}. |
| 25 | + */ |
| 26 | + @Test |
| 27 | + public void testSaveAndLoad() { |
| 28 | + AssetManager assetManager = new DesktopAssetManager(true); |
| 29 | + |
| 30 | + FilterPostProcessor fpp = new FilterPostProcessor(assetManager); |
| 31 | + fpp.addFilter(createDirectionalLightShadowFilter(assetManager)); |
| 32 | + fpp.addFilter(createSpotLightShadowFilter(assetManager)); |
| 33 | + fpp.addFilter(createPointLightShadowFilter(assetManager)); |
| 34 | + |
| 35 | + BinaryExporter.saveAndLoad(assetManager, fpp); |
| 36 | + } |
| 37 | + |
| 38 | + private DirectionalLightShadowFilter createDirectionalLightShadowFilter(AssetManager assetManager) { |
| 39 | + DirectionalLight light = new DirectionalLight(); |
| 40 | + light.setDirection(new Vector3f(-1, -2, -3).normalizeLocal()); |
| 41 | + light.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 1f)); |
| 42 | + |
| 43 | + DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, 2048, 1); |
| 44 | + dlsf.setLight(light); |
| 45 | + |
| 46 | + return dlsf; |
| 47 | + } |
| 48 | + |
| 49 | + private SpotLightShadowFilter createSpotLightShadowFilter(AssetManager assetManager) { |
| 50 | + SpotLight light = new SpotLight(); |
| 51 | + light.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 1f)); |
| 52 | + |
| 53 | + SpotLightShadowFilter slsf = new SpotLightShadowFilter(assetManager, 2048); |
| 54 | + slsf.setLight(light); |
| 55 | + |
| 56 | + return slsf; |
| 57 | + } |
| 58 | + |
| 59 | + private PointLightShadowFilter createPointLightShadowFilter(AssetManager assetManager) { |
| 60 | + PointLight light = new PointLight(); |
| 61 | + light.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 1f)); |
| 62 | + |
| 63 | + PointLightShadowFilter plsf = new PointLightShadowFilter(assetManager, 2048); |
| 64 | + plsf.setLight(light); |
| 65 | + |
| 66 | + return plsf; |
| 67 | + } |
| 68 | +} |
0 commit comments