Vector4 variable

package custom;

//import static com.jme3.shader.VarType.Texture2D;
import com.jme3.shader.VarType.Vector4;
import com.jme3.texture.Texture2D;
import java.io.Serializable;

/**
 *
 * @author nn
 */
public class MaterisalParams implements Serializable {
    public  Vector4  diffuse;
    public boolean   useMaterialColors;
    public float     parallaxHeight;
    
    public Vector4   ambient;
    public boolean   backfaceShadows;
    public Texture2D diffuseMap;
    public Vector4   specular;
    public float     shininess;
    
 //name Shininess type Float
 //   Specular specular;
  // Shininess shininess;
}

Compile with errors.

i get material parameters.

Collection<MatParam> listMap =  material.getParams();
        
       for(MatParam param : listMap){
       
           System.out.println(" name " + param.getName() + " type " + param.getVarType());

       } 

And add to custom class:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package custom;

//import static com.jme3.shader.VarType.Texture2D;
import com.jme3.shader.VarType.Vector4;
import com.jme3.texture.Texture2D;
import java.io.Serializable;

/**
 *
 * @author nn
 */
public class MaterisalParams implements Serializable {
    public  Vector4  diffuse;
    public boolean   useMaterialColors;
    public float     parallaxHeight;
    
    public Vector4   ambient;
    public boolean   backfaceShadows;
    public Texture2D diffuseMap;
    public Vector4   specular;
    public float     shininess;
    
 //name Shininess type Float
 //   Specular specular;
  // Shininess shininess;
}

When i run application compiler not search type: Vectro4.
import com.jme3.shader.VarType.Vector4;

(cannot find symbol Vector4)

And Texture2D have 2 class:
import com.jme3.texture.Texture2D;
//import static com.jme3.shader.VarType.Texture2D;

which used in material parameters?

1 Like

It’s just “Texture” from the java point of view - so it would be com.jme3.texture.Texture.

Example:

import com.jme3.texture.Texture
// ...
Texture texture = assetManager.loadTexture("Textures/Earth/grass_diffuse.jpg");
1 Like

Than’ks
And import Vector4 not work:
import com.jme3.shader.VarType.Vector4;

1 Like

You want a Vector4f :stuck_out_tongue: com.jme3.math.Vector4f

2 Likes

Okay thanks.

how you think: uv map save in material parameters?

1 Like

This does not apply to the material, it’s vertex data.

1 Like

Okay. Where stored (saved) uv map coordinates?

1 Like

Logically in the mesh.

1 Like

If I understand, you want to get a material from a model. I can’t really write it any better than paul already did in an example.

1 Like

I have:
1 blender model
2 materials
2 uv maps
2 textures

In blender i can assign one material (of two).

Logic:

  1. I assign material

  2. I get material in jmonkey

  3. I save material to string (and restore when it need)

  4. I set needed material

       Node node         = (Node) assetManager.loadModel(modelPath);
        Geometry myGeo    = (Geometry)node.getChild("base.obj1");
        Material material = myGeo.getMaterial();
         
         
        Collection<MatParam> listMap =  material.getParams();
         
        for(MatParam param : listMap){
        
            System.out.println(" name " + param.getName() + " type " + param.getVarType());
    
        }
        MaterisalParams matParams = new MaterisalParams();
    

//next i assigned parameters. save all materials to string. and restore need material when need.

1 Like

I dont understand. Why do you need to save the state of a material? A material is a representation of a state. It displays the state, it is not a state itself.

1 Like

In blender:
material have uv map…

I need switch between two textures (between two uv map two material two textures)

But it’s not possible with jmonkey standart methods.

1 Like

Sure it is, but i think you maybe confuse yourself over-thinking. Just use a method or a class to do it.

private Material material;

public SomeClass() {
    this.material = myModel.getMaterial();
    setState1();
}

public void setState1() {
    material.setTexture("Diffuse", someTexture);
    // and everything else...
}

public void setState2() {
    material.setTexture("Diffuse", anotherTexture);
    // and everything else
}

Then call setState1() or setState2() whenever you want to change the material state.
Sorry for any typing errors, i am on my phone.

1 Like

Note that the variable you have with the material, you can create the variable Army and Spec. And apply them as needed.

1 Like
 Node node         = (Node) assetManager.loadModel(modelPath);
       Geometry myGeo    = (Geometry)node.getChild("base.obj1");
       Material material = myGeo.getMaterial();
        
        //
        
       MaterisalParams matParams = new MaterisalParams();
       matParams.material = material


public class MaterisalParams implements Serializable{
    String army = "rO0ABXNyABZjdXN0b20uTWF0ZXJpc2FsUGFyYW1zyvxKH9Pl8pICAAhaAA9iYWNrZmFjZVNoYWRvd3NGAA5wYXJhbGxheEhlaWdodEYACXNoaW5pbmVzc1oAEXVzZU1hdGVyaWFsQ29sb3JzTAAHYW1iaWVudHQAGExjb20vam1lMy9tYXRoL1ZlY3RvcjRmO0wAB2RpZmZ1c2VxAH4AAUwACmRpZmZ1c2VNYXB0ABxMY29tL2ptZTMvdGV4dHVyZS9UZXh0dXJlMkQ7TAAIc3BlY3VsYXJxAH4AAXhwAAAAAAAAAAAAAHBwcHA=";
   
    public Material material;
    
    
}
1 Like

Why is this ??

1 Like

Yes. This is what I wanted to say

1 Like

I can save material in variable…

String army = "rO0ABXNyABZjdXN0b20uTWF0ZXJpc2FsUGFyYW1zyvxKH9Pl8pICAAhaAA9iYWNrZmFjZVNoYWRvd3NGAA5wYXJhbGxheEhlaWdodEYACXNoaW5pbmVzc1oAEXVzZU1hdGVyaWFsQ29sb3JzTAAHYW1iaWVudHQAGExjb20vam1lMy9tYXRoL1ZlY3RvcjRmO0wAB2RpZmZ1c2VxAH4AAUwACmRpZmZ1c2VNYXB0ABxMY29tL2ptZTMvdGV4dHVyZS9UZXh0dXJlMkQ7TAAIc3BlY3VsYXJxAH4AAXhwAAAAAAAAAAAAAHBwcHA=";
1 Like

Just use individual variables. Dont base64 encode it. It wont help anything. I see no sense in it.

1 Like

Material mat = geom.getMaterial();

Do not be stupid, mat this is already a variable.

1 Like