Repeating texture on a rectangle

Hi, does anyone know how could i load a texture on a 3D rectangle in order to look like smaller rectangles in line? Something like this:



The blue, yellow and red would be the texture.

Thank you.

Is this one textures?  If so, put regions of alpha on either side of the line and then set wrap mode to wrap/clamp so that it wraps only on one axis.  Finally, either scale the uv coords or apply a scale to the texture object to get it to repeat.

Those three colors are one texture:



I want to put it on the rectangle:



To look like this:



I’ve been trying without success:

ImageIcon imageTexture = new ImageIcon(pathToMyImage); //ok here
      Texture texture = TextureManager.loadTexture(imageTexture.getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
      texture.setWrap(Texture.WM_WRAP_S_WRAP_T);
      //texture.setScale(new Vector3f(2f,2f,2f));
      textureState.setTexture(texture);
      myModel.setRenderState(textureState);


The result is an orange rectangle  ://

Instead of Vector3f(2f,2f,2f) use Vector3f(2f,2f,1f). From experience I know that Z values other than 1 are bad for texture scaling…

Also, are you sure your model has texture coordinates?

hevee said:

Also, are you sure your model has texture coordinates?

I think it doesn't, how do i set this up? Working with texture is so frustrating  :x

try doing it blender and exporting an obj and then load it in jme… with simple example you can dig into the model and make a printout of texture coordinates to figure out how it works.

I am doing this, it is very simple:


      myStaticNode = physicSpace.createStaticNode();
      myStaticNode.setLocalTranslation(position);
      myStaticNode.createBox("myStaticNode");
      myStaticNode.setLocalScale(1f);
      myStaticNode.attachChild(utilMethodToLoadTheModel()); //it loads a .obj file exported from blender
      myStaticNode.generatePhysicsGeometry(true);
      myStaticNode.setMaterial(Material.IRON);
   }

   private void createTexture(TextureState textureState) {
      ImageIcon imageTexture = new ImageIcon(this.getClass().getClassLoader().getResource("path/image.jpg"));
      Texture texture = TextureManager.loadTexture(imageTexture.getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
      textureState.setTexture(texture);
      myStaticNode.setRenderState(textureState);
   }


The class extends Node and this is all, the problem is related to the model, the texture does not show up, i already tested it with a box and it worked.
Any idea?
Thanks.
juniorbl said:

I think it doesn't, how do i set this up? Working with texture is so frustrating  :x

That is more of a "getting started with blender" question - and a bit too complex for a one-line answer, I'm afraid. Luckily there are numerous tutorials on uv-mapping/texture mapping in blender on the net, and google knows them all :)
After you have set up texture coords in blender, any exporter (including .obj) should export them along with the rest of the geometry.

Ok, I will take a look, thanks.