Vector4 variable

But can i save variable between sessions? need to try

public class Serialize {
    
    private static Object fromString( String s ) throws IOException, ClassNotFoundException {
        byte [] data = Base64.getDecoder().decode( s );
        ObjectInputStream ois = new ObjectInputStream( 
                                        new ByteArrayInputStream(  data ) );
        Object o  = ois.readObject();
        ois.close();
        return o;
   }

    /** Write the object to a Base64 string. */
    public static String toString( Serializable o ) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream( baos );
        oos.writeObject( o );
        oos.close();
        return Base64.getEncoder().encodeToString(baos.toByteArray()); 
    }
}
1 Like

What prevents you from saving the string name of the material? Apply this material to a new session.

1 Like

Try changing the variable to the Spec, then think it out for yourself.

protected Object saveMat = "Army";

//

		Spatial Model = assetManager.loadModel("player-test-fix.j3o");
		rootNode.attachChild(Model);

		SceneGraphVisitor searchGeomMat = new SceneGraphVisitor() {

			public void visit(Spatial spatial) {

				if (spatial instanceof Geometry) {

					Geometry geom = (Geometry) spatial;

					if (geom.getMaterial().getName().equals(saveMat)) {

						Material mat = geom.getMaterial();
						Model.setMaterial(mat);

					}

				}

			}

		};

		Model.depthFirstTraversal(searchGeomMat);
1 Like

This is return:

Army
Null (java error)
Null (java error)
Null (java error)

In blender model (spatial) only one material which assigned in blender before save.

1 Like

I try make next:

1.get material
2. save to string (serrialize)
3. switch material in blender
4. save to string
5 switch between saved materials

1 Like