# Different Geometries with the same Material

So I’m building a makeshift house from various items in my game. My game allows rotations of some items in 45 degree angles, so you can have walls, floors and roofs in variations of 45 degree angles.

Long story short, you can press the E key to adjust a quad to an isosceles or equilateral triangle instead - I guess a picture will explain it better:  This will allow people to have pitched roofs amongst other things. The problem is that when I have both a quad and a triangle in the same GeometryBatchFactory node, it returns an error:

UnsupportedOperationException: The geometry buffer TexCoord has different number of components than the rest of the meshes (this: 2, expected: 3)

I’m far from being a game guru, so i’m a little lost. Below is the code I use to create the various geometries needed. The same material is used for each shape.

[java]
public class ShapeFactory
{
public static enum ShapeType { Quad, Isosceles, Equalateral };

``````public static Geometry createQuad(String name)
{
Geometry geom = new Geometry(name, quad);

return geom;
}

public static Geometry createIsoscelesTriangle(String name)
{
Vector3f[] vertices =
{
new Vector3f(0, 0, 0),
new Vector3f(0, 1, 0),
new Vector3f(1, 0, 0),
};

Vector3f[] textCoords =
{
new Vector3f(0, 0, 0),
new Vector3f(0, 1, 0),
new Vector3f(1, 0, 0),
};

int[] indexes = { 0, 1, 2 };

Mesh mesh = new Mesh();

mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
mesh.setBuffer(VertexBuffer.Type.TexCoord, 3, BufferUtils.createFloatBuffer(textCoords));
mesh.setBuffer(VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer(indexes));

mesh.updateBound();

Geometry geom = new Geometry(name, mesh);

return geom;
}

public static Geometry createEqualateralTriangle(String name)
{
Vector3f[] vertices =
{
new Vector3f(0, 0, 0),
new Vector3f(.5f, 1, 0),
new Vector3f(1, 0, 0),
};

Vector3f[] textCoords =
{
new Vector3f(0, 0, 0),
new Vector3f(.5f, 1, 0),
new Vector3f(1, 0, 0),
};

int[] indexes = { 0, 1, 2 };

Mesh mesh = new Mesh();

mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
mesh.setBuffer(VertexBuffer.Type.TexCoord, 3, BufferUtils.createFloatBuffer(textCoords));
mesh.setBuffer(VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer(indexes));

mesh.updateBound();

Geometry geom = new Geometry(name, mesh);

return geom;
}
``````

}
[/java]

Why do your texture coordinates have three components? Most will only have two… certainly all of the standard JME shapes like Quad will only have two. (x,y) Yours have (x,y,z).

You cannot mix the two in one batch.

Oh there we go. I was using a vector3f for the textCoords as you said. To answer your question - I was flying blind trying to figure it out for myself - it tends to stick in my head that way, but that error made absolutely no sense at all to me. Problem solved. tyvm @jayfella said: Oh there we go. I was using a vector3f for the textCoords as you said. To answer your question - I was flying blind trying to figure it out for myself - it tends to stick in my head that way, but that error made absolutely no sense at all to me. Problem solved. tyvm :-D

You’re welcome. I didn’t want to assume you hadn’t done it on purpose… so I asked. In retrospect, I’m sure the error is much clearer. 