Talk:TerrainObjExporter

Has anyone tested this exporter with dimensions of NxM terrains where n != m? Because in my point of view the current function only work for the case n=m correctly. (first code is in jscript / the correct one in c#)

Current one:

for (x = 0; x < w; x++) { tVertices[y*w + x] = Vector3.Scale(meshScale, Vector3(x, tData[x*tRes,y*tRes], y)) + terrainPos; tUV[y*w + x] = Vector2.Scale(Vector2(x*tRes, y*tRes), uvScale); }

Correct one:

for (int x = 0; x < w; x++) { tVertices[y*w + x] = Vector3.Scale(meshScale, new Vector3((float)x, tData[(y*(int)tRes), (x*(int)tRes)], (float)y)) + terrainPos; tUV[y*w + x] = Vector2.Scale(new Vector2(x*tRes, y*tRes), uvScale); }

It's a moot point, since you can only have nxn terrains anyway. Eric5h5 19:59, 17 January 2011 (PST)

There is a Bug in it. If the terrain width and height does not match the algorithm don't work correctly, i found a way out by changing the Vertex loop as follows:

// Build vertices and UVs int new_Y = h-1; for (int y = 0; y < h; y++) {       for (int x = 0; x < w; x++) {          tVertices[x * h + y] = Vector3.Scale(meshScale, new Vector3(y, tData[x * tRes, new_Y * tRes], x)) + terrainPos; tUV[x * h + y] = Vector2.Scale( new Vector2(x * tRes, new_Y * tRes), uvScale); }       new_Y--; }

--Orochi663 (talk) 04:03, 25 May 2013 (CEST)Rashid Tanweer