11/*
2- * Copyright (c) 2009-2022 jMonkeyEngine
2+ * Copyright (c) 2009-2025 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
4949import java .io .ByteArrayOutputStream ;
5050import java .io .IOException ;
5151import java .io .InputStream ;
52+ import java .net .URL ;
5253
5354import static org .junit .Assert .assertTrue ;
5455
@@ -58,56 +59,56 @@ public class TestMaterialWrite {
5859
5960 @ Before
6061 public void init () {
61- assetManager = JmeSystem .newAssetManager (
62- TestMaterialWrite .class .getResource ("/com/jme3/asset/Desktop.cfg" ));
63-
64-
62+ URL configFile = TestMaterialWrite .class .getResource ("/com/jme3/asset/Desktop.cfg" );
63+ assetManager = JmeSystem .newAssetManager (configFile );
6564 }
6665
67-
6866 @ Test
6967 public void testWriteMat () throws Exception {
70-
71- Material mat = new Material (assetManager ,"Common/MatDefs/Light/Lighting.j3md" );
72-
68+ Material mat = new Material (assetManager , "Common/MatDefs/Light/Lighting.j3md" );
69+ mat .setName ("TestMaterial" );
7370 mat .setBoolean ("UseMaterialColors" , true );
7471 mat .setColor ("Diffuse" , ColorRGBA .White );
7572 mat .setColor ("Ambient" , ColorRGBA .DarkGray );
7673 mat .setFloat ("AlphaDiscardThreshold" , 0.5f );
77-
7874 mat .setFloat ("Shininess" , 2.5f );
75+ mat .setTransparent (true );
76+ mat .setReceivesShadows (true );
7977
8078 Texture tex = assetManager .loadTexture (new TextureKey ("Common/Textures/MissingTexture.png" , true ));
8179 tex .setMagFilter (Texture .MagFilter .Nearest );
8280 tex .setMinFilter (Texture .MinFilter .BilinearNoMipMaps );
8381 tex .setWrap (Texture .WrapAxis .S , Texture .WrapMode .Repeat );
8482 tex .setWrap (Texture .WrapAxis .T , Texture .WrapMode .MirroredRepeat );
85-
8683 mat .setTexture ("DiffuseMap" , tex );
84+
8785 mat .getAdditionalRenderState ().setDepthWrite (false );
8886 mat .getAdditionalRenderState ().setDepthTest (false );
87+ mat .getAdditionalRenderState ().setColorWrite (false );
88+ mat .getAdditionalRenderState ().setWireframe (true );
8989 mat .getAdditionalRenderState ().setLineWidth (5 );
90+ mat .getAdditionalRenderState ().setPolyOffset (-1 , 1 );
9091 mat .getAdditionalRenderState ().setBlendMode (RenderState .BlendMode .Alpha );
9192
92- final ByteArrayOutputStream stream = new ByteArrayOutputStream ();
93+ final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
9394
9495 J3MExporter exporter = new J3MExporter ();
9596 try {
96- exporter .save (mat , stream );
97+ exporter .save (mat , baos );
9798 } catch (IOException e ) {
9899 e .printStackTrace ();
99100 }
100101
101- System .err .println (stream . toString () );
102+ System .err .println (baos );
102103
103104 J3MLoader loader = new J3MLoader ();
104105 AssetInfo info = new AssetInfo (assetManager , new AssetKey ("test" )) {
105106 @ Override
106107 public InputStream openStream () {
107- return new ByteArrayInputStream (stream .toByteArray ());
108+ return new ByteArrayInputStream (baos .toByteArray ());
108109 }
109110 };
110- Material mat2 = (Material )loader .load (info );
111+ Material mat2 = (Material ) loader .load (info );
111112
112113 assertTrue (mat .contentEquals (mat2 ));
113114 }
0 commit comments