Textures not rendering

Hey guys, I’ve having a bit of a problem implementing textures. Basically, the blocks made that should have a dirt texture are light brown (about the same color as the texture itself), and only the last block rendered shows the texture, horribly wrapped and stretched and disgusting looking basically. I’ve pasted the code for the classes, and an image. How do I fix this?


This is the block class

[java]public class Block extends Geometry


public enum BlockType {RANDOMBLOCK,REDBLOCK}

protected ColorRGBA blockColor;

protected Texture blockTexture;

String boxName;

PhysicsNode physicsNode;

Node blockNode;

protected AssetManager assetManager;

BlockType type;

Texture texture;

public Block(String name, float x, float y, float z)


super();//does whatever usually happens when a geometry is made

this.name = name;

assetManager = JmeSystem.newAssetManager(Thread.currentThread().getContextClassLoader().getResource(“com/jme3/asset/Desktop.cfg”));

//Material blockMaterial = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);



this.mesh = new Mesh();



/Creates array of vertices/

Vector3f[] vertices = new Vector3f[8];

vertices[0]=new Vector3f(0,0,0);

vertices[1]=new Vector3f(0,0,2);//index is decimal; point is binary

vertices[2]=new Vector3f(0,2,0);

vertices[3]=new Vector3f(0,2,2);

vertices[4]=new Vector3f(2,0,0);

vertices[5]=new Vector3f(2,0,2);

vertices[6]=new Vector3f(2,2,0);

vertices[7]=new Vector3f(2,2,2);

/Creates normals/

/Creates texture verices

Vector2f[] texCoord = new Vector2f[8];

texCoord[0]=new Vector2f(0,0);

texCoord[1]=new Vector2f(0,1);

texCoord[2]=new Vector2f(0,-1);

texCoord[3]=new Vector2f(0,2);

texCoord[4]=new Vector2f(1,0);

texCoord[5]=new Vector2f(1,1);

texCoord[6]=new Vector2f(1,-1);

texCoord[7]=new Vector2f(1,2);//no clue how this is supposed to work, oh well

/Tells how to connect them///half of these faces are unnecessary, as the render to the inside, if you can figure out which ones they are, delete them

int[] indexes = {2,6,0, 6,4,0, /0,6,2, 0,4,6,//front/ 6,5,4, 6,7,5,/* 4,5,6, 5,7,6, /right/ 2,3,6, 3,7,6, /*6,3,2, 6,7,3,/top//1,4,0, 1,5,4,/ 0,4,1, 4,5,1, /bottom/ 7,1,5, 7,3,1, /*5,1,7, 1,3,7,/back/ 2,0,1, 3,2,1, /*1,0,2, 1,2,3/left/};

/Makes mesh/


this.mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));//didn’t seem to do anything



this.setModelBound(new BoundingBox());



blockNode = new Node(name); //new node for physics attachment

blockNode.attachChild(this); //attach block to node

CompoundCollisionShape boxShape = CollisionShapeFactory.createMeshCompoundShape(blockNode); //creates box shaped physics

physicsNode = new PhysicsNode(blockNode, boxShape, 0);

this.physicsNode.setLocalTranslation(x, y, z);


public void setColor(ColorRGBA color)


blockColor = color;

this.getMaterial().setColor(“m_Color”, color);


public void setTexture(Texture texture)


blockTexture = texture;

this.getMaterial().setTexture(“m_ColorMap”, texture);


public static int getNumTypes()


return BlockType.values().length;//code this dynamically later//almost cetainly will become depricated


public static int blockTypeToInt(BlockType type)


switch (type)



return 0;


return 1;


return -1;



public static BlockType intToBlockType(int type)


switch (type)


case 0:

return BlockType.RANDOMBLOCK;

case 1:

return BlockType.REDBLOCK;


return null;



public BlockType getType()


return this.type;



And this is the class that uses the texture.

[java]public class RedBlock extends Block


public RedBlock(String name, float x, float y, float z)



texture = assetManager.loadTexture(“Textures/dirtTexture.jpg”).clone();


// material = “Common/MatDefs/Misc/SolidColor.j3md”;

this.material = new Material(this.assetManager,“Common/MatDefs/Misc/SimpleTextured.j3md”);

this.material.setTexture(“m_ColorMap”, texture);


//this.setTexture(texture);//this is redundant the texture is under the material in the tree




Are you sure you don’t want to apply material on your mesh?

Are you sure you should extend Gemoetry and not simply Node?