I have a scene with a quad that I want to have the material repeating. I could not get that to work so I made a new scene with only a quad. I put the material on the quad and I can see the image, just not repeating. I made a control to attach to the quad so I can try to make the image repeat. It’s a shame I cannot do it from the material file itself. Here is the material file:
Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
BackfaceShadows : true
DiffuseMap : Repeat Models/floor/floor.png
UseInstancing : false
UseMaterialColors : false
SteepParallax : false
Shininess : 5.0
}
AdditionalRenderState {
PointSprite On
FaceCull Back
AlphaTestFalloff 0.0
DepthWrite On
ColorWrite On
PolyOffset 0.0 0.0
DepthTest On
Blend Off
Wireframe Off
}
}
I made the control so I can get the material to repeat. I tried several things from quite a few forum posts but I only found one that I could use. When I try to use it the material of the quad goes from the image to a light grey color. here is the code from the control.
package mygame;
import com.jme3.math.Vector2f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
public class repeatTexControl extends AbstractControl {
public int factor = 10;
@Override
protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
@Override
public Control cloneForSpatial ( Spatial spatial ) {
Control control = new repeatTexControl();
control.setSpatial( spatial );
Geometry geom = (Geometry) spatial;
geom.getMesh().scaleTextureCoordinates( new Vector2f( factor, factor ) );
return control;
}
}
Is there a better way? What did I miss with this approach? Thank you in advance.