public FloatBuffer getTextureCoords() { if (mBuffers.get(TEXTURE_BUFFER_KEY).buffer == null && mOriginalGeometry != null) { return mOriginalGeometry.getTextureCoords(); } return (FloatBuffer) mBuffers.get(TEXTURE_BUFFER_KEY).buffer; }
@Test public void testTextureCoords() { float[] expected = new float[]{ 0, 1, 0, 0, 1, 1, 1, 0, }; float[] result = new float[4 * 2]; screenQuad.getGeometry().getTextureCoords().get(result); for (int i = 0; i < result.length; i++) { assertEquals(expected[i], result[i], 1e-10); } } }
/** * Maps the (x,y) coordinates of <code>tileName</code> in <code>atlas</code> * to the TextureCoordinates of this BaseObject3D * * Saves a copy of the original TextureCoordinates in case of future mapping. * * @param tileName * @param atlas */ public void setAtlasTile(String tileName, TextureAtlas atlas) { Tile tile = atlas.getTileNamed(tileName); if(mOriginalTextureCoords == null) { mOriginalTextureCoords = this.getGeometry().getTextureCoords().duplicate(); } FloatBuffer fb = FloatBuffer.allocate(mOriginalTextureCoords.capacity()); for (int i = 0; i < fb.capacity(); i++) { double uvIn = mOriginalTextureCoords.get(i); double uvOut; if (i % 2 == 0) { uvOut = (uvIn * (tile.width / atlas.getWidth())) + tile.x / atlas.getWidth(); } else { uvOut = (uvIn * (tile.height / atlas.getHeight())) + tile.y / atlas.getHeight(); } fb.put(i, (float) uvOut); } mGeometry.changeBufferData(mGeometry.getTexCoordBufferInfo(), fb, 0); }
float[] addTextureCoords = getFloatArrayFromBuffer(geometry.getTextureCoords()); int[] addIndices = getIntArrayFromBuffer(geometry.getIndices()); int index_offset = 0;
public FloatBuffer getTextureCoords() { if (mTextureCoords == null && mOriginalGeometry != null) return mOriginalGeometry.getTextureCoords(); return mTextureCoords; }
for (int i = 0; i < g.getTextureCoords().capacity(); i += 2) { sb.append("vt "); sb.append(g.getTextureCoords().get(i)); sb.append(" "); sb.append(g.getTextureCoords().get(i + 1)); sb.append("\n"); bufferStringWriting(sb, bw);
/** * Calculate the length of the TriangleBlock that will be written. * * @param geom * @return */ private int awdGetGeomLength(Geometry3D geom) { return 24 + (geom.getNumIndices() * 2) + (geom.getNumVertices() * 4) + (geom.getNormals().limit() * 4) + (geom.getTextureCoords().limit() * 4); }
/** * Maps the (x,y) coordinates of <code>tileName</code> in <code>atlas</code> * to the TextureCoordinates of this BaseObject3D * * @param tileName * @param atlas */ public void setAtlasTile(String tileName, TextureAtlas atlas) { Tile tile = atlas.getTileNamed(tileName); FloatBuffer fb = this.getGeometry().getTextureCoords(); for (int i = 0; i < fb.capacity(); i++) { double uvIn = fb.get(i); double uvOut; if (i % 2 == 0) uvOut = (uvIn * (tile.width / atlas.getWidth())) + tile.x / atlas.getWidth(); else uvOut = (uvIn * (tile.height / atlas.getHeight())) + tile.y / atlas.getHeight(); fb.put(i, (float) uvOut); } mGeometry.changeBufferData(mGeometry.mTexCoordBufferInfo, fb, 0); }
writeAwdAttributeList(los, 3, 0, geom.getTextureCoords()); writeAwdAttributeList(los, 4, 0, geom.getNormals());
float[] addTextureCoords = getFloatArrayFromBuffer(geometry.getTextureCoords()); int[] addIndices = getIntArrayFromBuffer(geometry.getIndices()); int index_offset = (mVerticesArray.length / 3);