private static int segmentPointToTextureDataIndex(Point2d point, double offsetX, double offsetY, MeshFactory mesh, TextureData td) { return mesh.addTextCoord(new TextCoord((point.x + offsetX) / td.getWidth(), (point.y + offsetY) / td.getHeight())); }
/** * @param pTextureFindCriteria * @param textureSet * @return */ public List<TextureData> filterByBestSizeMatch(TextureFindCriteria pTextureFindCriteria, List<TextureData> textureSet) { TextureData best = null; double bestError = Double.MAX_VALUE; double height = pTextureFindCriteria.getHeight() == null ? 0 : pTextureFindCriteria.getHeight(); double width = pTextureFindCriteria.getWidth() == null ? 0 : pTextureFindCriteria.getWidth(); for (TextureData td : textureSet) { double dH = td.getHeight() - height; double dW = td.getWidth() - width; double err = dH * dH + dW * dW; if (err < bestError) { bestError = err; best = td; } } return Arrays.asList(best); } }
public static TextureData colorableTextureData(TextureData textureData) { String tex0 = null; String tex1 = null; double width = 1d; double height = 1d; if (textureData != null) { tex0 = textureData.getTex0(); tex1 = textureData.getTex1(); width = textureData.getWidth(); height = textureData.getHeight(); } if (tex0 == null) { tex0 = "#c=0xffffff"; } else { tex0 = "#bw=" + tex0; } return new TextureData(tex0, tex1, width, height, true); }
public void draw(GL2 gl, Point3d cameraPosition) { gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_TEXTURE_2D); TextureData td = this.textureLibraryStorageService.getTextureDefault("ground.unknown"); Texture texture = this.textureCacheService.getTexture(gl, td.getTex0()); texture.enable(gl); texture.bind(gl); gl.glBegin(GL2.GL_POLYGON); gl.glColor3f((float) 123 / 256, (float) 111 / 256, (float) 100 / 255); double groundSize = 1500.0; Point3d c = cameraPosition; // gl.glTexCoord2d(tc.left(), tc.bottom()); double xRight = c.x + groundSize; double xLeft = c.x - groundSize; double zButtom = c.z + groundSize; double zTop = c.z - groundSize; gl.glNormal3d(0, 1, 0); gl.glTexCoord2d(xRight * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xRight, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zTop); gl.glTexCoord2d(xRight * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xRight, -0.01, zTop); gl.glEnd(); texture.disable(gl); gl.glDisable(GL2.GL_TEXTURE_2D); }
uLast = uEnd; int tc_0_0 = mesh.addTextCoord(new TextCoord(uBegin, minHeight1 / textureData.getHeight())); int tc_0_v = mesh.addTextCoord(new TextCoord(uBegin, height1 / textureData.getHeight())); int tc_u_0 = mesh.addTextCoord(new TextCoord(uEnd, minHeight2 / textureData.getHeight())); int tc_u_v = mesh.addTextCoord(new TextCoord(uEnd, height2 / textureData.getHeight()));
int topMaterialIndex = pRoofTextureData.getRoof().getMaterialIndexInModel(); double v1 = (h1 / facadeTexture.getHeight()); double u1 = (width1 / facadeTexture.getWidth());