use of com.ardor3d.image.Texture2D in project energy3d by concord-consortium.
the class Scene method applyGroundImage.
private void applyGroundImage() {
final Mesh mesh = SceneManager.getInstance().getGroundImageLand();
if (groundImage == null) {
// set a dummy texture in case the mesh holds the original buffered image and causes memory leak
mesh.setRenderState(new TextureState());
mesh.setVisible(false);
setFoundationsVisible(true);
} else {
SceneManager.getInstance().resizeGroundImageLand(groundImageScale);
final Texture2D texture = new Texture2D();
texture.setTextureKey(TextureKey.getRTTKey(MinificationFilter.NearestNeighborNoMipMaps));
texture.setImage(AWTImageLoader.makeArdor3dImage(groundImage, true));
final TextureState textureState = new TextureState();
textureState.setTexture(texture);
mesh.setRenderState(textureState);
mesh.setVisible(!hideGroundImage);
setFoundationsVisible(false);
}
}
use of com.ardor3d.image.Texture2D in project energy3d by concord-consortium.
the class SolarRadiation method applyTexture.
private void applyTexture(final Mesh mesh) {
if (onMesh.get(mesh) == null) {
mesh.setDefaultColor(ColorRGBA.BLACK);
mesh.clearRenderState(StateType.Texture);
return;
}
final double[][] solarData = onMesh.get(mesh).dailySolarIntensity;
final int rows = solarData.length;
if (rows == 0) {
return;
}
final int cols = solarData[0].length;
if (cols == 0) {
return;
}
fillBlanksWithNeighboringValues(solarData);
final ByteBuffer data = BufferUtils.createByteBuffer(cols * rows * 3);
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
final ColorRGBA color = computeColor(solarData[row][col], maxValue);
data.put((byte) (color.getRed() * 255)).put((byte) (color.getGreen() * 255)).put((byte) (color.getBlue() * 255));
}
}
final Image image = new Image(ImageDataFormat.RGB, PixelDataType.UnsignedByte, cols, rows, data, null);
final Texture2D texture = new Texture2D();
texture.setTextureKey(TextureKey.getRTTKey(MinificationFilter.NearestNeighborNoMipMaps));
texture.setImage(image);
// texture.setWrap(WrapMode.Clamp);
final TextureState textureState = new TextureState();
textureState.setTexture(texture);
mesh.setDefaultColor(ColorRGBA.WHITE);
mesh.setRenderState(textureState);
}
Aggregations