use of com.ardor3d.renderer.state.TextureState 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.renderer.state.TextureState in project energy3d by concord-consortium.
the class SceneManager method changeSkyTexture.
public void changeSkyTexture() {
if (sky != null) {
final boolean isNightTime = Heliodon.getInstance().isNightTime();
String textureFile;
switch(Scene.getInstance().getTheme()) {
case Scene.DESERT_THEME:
textureFile = isNightTime ? "desert-night.jpg" : "desert.jpg";
break;
case Scene.GRASSLAND_THEME:
textureFile = isNightTime ? "grassland-night.jpg" : "grassland.jpg";
break;
case Scene.FOREST_THEME:
textureFile = isNightTime ? "forest-night.jpg" : "forest.jpg";
break;
default:
textureFile = isNightTime ? "nightsky.jpg" : "daysky.jpg";
}
final TextureState ts = new TextureState();
ts.setTexture(TextureManager.load(textureFile, Texture.MinificationFilter.Trilinear, TextureStoreFormat.GuessNoCompressedFormat, true));
sky.setRenderState(ts);
}
}
use of com.ardor3d.renderer.state.TextureState 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);
}
use of com.ardor3d.renderer.state.TextureState in project energy3d by concord-consortium.
the class Scene method destroy.
// just in case to prevent possible memory leaks
private void destroy() {
for (final HousePart p : parts) {
p.delete();
// detachment cannot be put into delete(), we detach all children here to help garbage collection
p.getRoot().detachAllChildren();
}
parts.clear();
if (groundImage != null) {
groundImage.flush();
groundImage = null;
}
if (SceneManager.getInstance().getGroundImageLand() != null) {
SceneManager.getInstance().getGroundImageLand().setRenderState(new TextureState());
}
if (foundationGroups != null) {
foundationGroups.clear();
}
}
use of com.ardor3d.renderer.state.TextureState in project energy3d by concord-consortium.
the class SceneManager method createSky.
private Mesh createSky() {
final Dome sky = new Dome("Sky", 100, 100, SKY_RADIUS);
sky.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
sky.getSceneHints().setLightCombineMode(LightCombineMode.Off);
sky.getSceneHints().setAllPickingHints(false);
sky.updateModelBound();
sky.updateWorldBound(true);
final TextureState ts = new TextureState();
ts.setTexture(TextureManager.load("daysky.jpg", Texture.MinificationFilter.Trilinear, TextureStoreFormat.GuessNoCompressedFormat, true));
sky.setRenderState(ts);
return sky;
}
Aggregations