[solved] Textured objects getting improperly clipped as cammera turns

Having an issue where any object I texture gets clipped improperly. If I use a solid color material, every thing renders fine, issue only appears if I switch to a textured material. Any idea what I might be doing wrong?



http://www.shideforest.com/images/Clips1.png

http://www.shideforest.com/images/Clips2.png

http://www.shideforest.com/images/Clips3.png



[java] List<Vector3f> normals = new ArrayList<Vector3f>();

List<Vector3f> vertices = new ArrayList<Vector3f>();

List<Vector2f> texCoord = new ArrayList<Vector2f>();

List<Integer> indexes = new ArrayList<Integer>();



Vector3f up = new Vector3f(0, 1, 0);

int cx = 1000;

int cz = 1000;

int y = 0;



int r1 = -1;

int scanLine = 0;

for (int x=-50; x<=50; x+=10) {

scanLine++;

}



float txt = (float)scanLine;



for (int z=-50, r2=0; z<=50; z+=10, r2+=scanLine) {

if (r1 == -1) {

for (int x=-50, c2=0; x<=50; x+=10, c2++) {

vertices.add(new Vector3f(x+cx, y, z+cz));

normals.add(up);

texCoord.add(new Vector2f(c2/txt, r2/txt));

}

} else {

int c1 = -1;



for (int x=-50, c2=0; x<=50; x+=10, c2++) {

vertices.add(new Vector3f(x+cx, y, z+cz));

normals.add(up);

texCoord.add(new Vector2f(c2/txt, r2/txt));



if (c1 >= 0) {

indexes.add(r1 + c1);

indexes.add(r2 + c1);

indexes.add(r1 + c2);



indexes.add(r1 + c2);

indexes.add(r2 + c1);

indexes.add(r2 + c2);

}



c1 = c2;

}

}



r1 = r2;

}



int[] ints = new int[indexes.size()];

for (int i=0, n=ints.length; i<n; i++) {

ints = indexes.get(i).intValue();

}



Mesh mesh = new Mesh();

mesh.setBuffer(VertexBuffer.Type.Normal, 3, BufferUtils.createFloatBuffer(normals.toArray(new Vector3f[normals.size()])));

mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vertices.toArray(new Vector3f[vertices.size()])));

mesh.setBuffer(VertexBuffer.Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord.toArray(new Vector2f[texCoord.size()])));

mesh.setBuffer(VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer(ints));

mesh.updateBound();



//mat.setColor(“Color”, ColorRGBA.Blue);



Geometry geo = new Geometry(“Mesh”, mesh);



Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

Texture texture = assetManager.loadTexture(“Media/Textures/Terrain/City/grass.jpg”);

texture.setWrap(WrapMode.Repeat);

mat.setTexture(“DiffuseMap”, texture);



mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Specular”,ColorRGBA.White);

mat.setColor(“Diffuse”,ColorRGBA.White);

mat.setFloat(“Shininess”, 0f);

geo.setMaterial(mat);



Node node = new Node();

node.attachChild(geo);

return node;

[/java]

Just upgraded to RC2 and seems to solve the problem.

1 Like