protected float getHeight(int x, int z, float xm, float zm) { return geomap.getHeight(x,z,xm,zm); }
public FloatBuffer writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) { if (store != null) { if (store.remaining() < getWidth() * getHeight() * 2) { throw new BufferUnderflowException(); } } else { store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 2); } if (offset == null) { offset = new Vector2f(); } Vector2f tcStore = new Vector2f(); // work from bottom of heightmap up, so we don't flip the coords for (int y = getHeight() - 1; y >= 0; y--) { for (int x = 0; x < getWidth(); x++) { getUV(x, y, tcStore, offset, offsetAmount, totalSize); float tx = tcStore.x * scale.x; float ty = tcStore.y * scale.y; store.put(tx); store.put(ty); } } return store; }
if (tangentStore.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); tangentStore = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); if (binormalStore.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); binormalStore = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); for (int r = 0; r < getHeight(); r++) { for (int c = 0; c < getWidth(); c++) {
public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) { FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize); FloatBuffer nb = writeNormalArray(null, scale); Buffer ib; IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize); if (idxB.getBuffer() instanceof IntBuffer) ib = (IntBuffer)idxB.getBuffer(); else ib = (ShortBuffer)idxB.getBuffer(); FloatBuffer bb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); FloatBuffer tanb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); writeTangentArray(nb, tanb, bb, texb, scale); Mesh m = new Mesh(); m.setMode(Mode.TriangleStrip); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.Tangent, 3, tanb); m.setBuffer(Type.Binormal, 3, bb); m.setBuffer(Type.TexCoord, 2, texb); if (ib instanceof IntBuffer) m.setBuffer(Type.Index, 3, (IntBuffer)ib); else if (ib instanceof ShortBuffer) m.setBuffer(Type.Index, 3, (ShortBuffer)ib); m.setStatic(); m.updateBound(); return m; }
if (store.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); for (int r = 0; r < getHeight(); r++) { for (int c = 0; c < getWidth(); c++) { normal.addLocal( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) ); } else if (r == getHeight() - 1) { // last row if (c == 0) { // first column topPoint.set(0, getValue(c, r - 1), -1);
protected float getHeight(int x, int z, float xm, float zm) { return geomap.getHeight(x,z,xm,zm); }
public FloatBuffer writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) { if (store != null) { if (store.remaining() < getWidth() * getHeight() * 2) { throw new BufferUnderflowException(); } } else { store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 2); } if (offset == null) { offset = new Vector2f(); } Vector2f tcStore = new Vector2f(); // work from bottom of heightmap up, so we don't flip the coords for (int y = getHeight() - 1; y >= 0; y--) { for (int x = 0; x < getWidth(); x++) { getUV(x, y, tcStore, offset, offsetAmount, totalSize); float tx = tcStore.x * scale.x; float ty = tcStore.y * scale.y; store.put(tx); store.put(ty); } } return store; }
if (tangentStore.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); tangentStore = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); if (binormalStore.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); binormalStore = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); for (int r = 0; r < getHeight(); r++) { for (int c = 0; c < getWidth(); c++) {
public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) { FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize); FloatBuffer nb = writeNormalArray(null, scale); Buffer ib; IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize); if (idxB.getBuffer() instanceof IntBuffer) ib = (IntBuffer)idxB.getBuffer(); else ib = (ShortBuffer)idxB.getBuffer(); FloatBuffer bb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); FloatBuffer tanb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); writeTangentArray(nb, tanb, bb, texb, scale); Mesh m = new Mesh(); m.setMode(Mode.TriangleStrip); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.Tangent, 3, tanb); m.setBuffer(Type.Binormal, 3, bb); m.setBuffer(Type.TexCoord, 2, texb); if (ib instanceof IntBuffer) m.setBuffer(Type.Index, 3, (IntBuffer)ib); else if (ib instanceof ShortBuffer) m.setBuffer(Type.Index, 3, (ShortBuffer)ib); m.setStatic(); m.updateBound(); return m; }
if (store.remaining() < getWidth() * getHeight() * 3) { throw new BufferUnderflowException(); store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); for (int r = 0; r < getHeight(); r++) { for (int c = 0; c < getWidth(); c++) { normal.addLocal( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) ); } else if (r == getHeight() - 1) { // last row if (c == 0) { // first column topPoint.set(0, getValue(c, r - 1), -1);