Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jme3-ios-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def iosChooserExcludedPrefixes = [
'jme3test.awt.',
'jme3test.bullet.',
'jme3test.niftygui.',
'jme3test.opencl.',
'jme3test.terrain.'
'jme3test.opencl.'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beside the point of this pr, but jme3test.opencl can be deleted from here too surely, it's gone

]
def iosChooserExcludedNames = [
'jme3test.app.TestChangeAppIcon',
Expand Down Expand Up @@ -311,10 +310,10 @@ dependencies {
implementation project(':jme3-plugins')
implementation project(':jme3-plugins-json')
implementation project(':jme3-plugins-json-gson')
implementation project(':jme3-terrain')

if ((findProperty('iosIncludeAwtUnsafeModules') ?: 'false').toString().toBoolean()) {
implementation project(':jme3-niftygui')
implementation project(':jme3-terrain')
}
}

Expand Down
45 changes: 12 additions & 33 deletions jme3-terrain/src/main/java/com/jme3/terrain/noise/ShaderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@
*/
package com.jme3.terrain.noise;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import com.jme3.math.ColorRGBA;
import com.jme3.texture.Texture2D;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
* Helper class containing useful functions explained in the book:
Expand Down Expand Up @@ -66,16 +61,18 @@ public static final float mix(final float a, final float b, final float f) {
return (1 - f) * a + f * b;
}

public static final Color mix(final Color a, final Color b, final float f) {
return new Color((int) ShaderUtils.clamp(ShaderUtils.mix(a.getRed(), b.getRed(), f), 0, 255), (int) ShaderUtils.clamp(
ShaderUtils.mix(a.getGreen(), b.getGreen(), f), 0, 255), (int) ShaderUtils.clamp(
ShaderUtils.mix(a.getBlue(), b.getBlue(), f), 0, 255));
}

public static final int mix(final int a, final int b, final float f) {
return (int) ((1 - f) * a + f * b);
}

public static final ColorRGBA mix(final ColorRGBA a, final ColorRGBA b, final float f) {
return new ColorRGBA(
ShaderUtils.mix(a.r, b.r, f),
ShaderUtils.mix(a.g, b.g, f),
ShaderUtils.mix(a.b, b.b, f),
ShaderUtils.mix(a.a, b.a, f));
}

public static final float[] mix(final float[] c1, final float[] c2, final float f) {
return new float[] { ShaderUtils.mix(c1[0], c2[0], f), ShaderUtils.mix(c1[1], c2[1], f), ShaderUtils.mix(c1[2], c2[2], f) };
}
Expand Down Expand Up @@ -257,26 +254,8 @@ public static final float length(final float[] v) {
return (float) Math.sqrt(s);
}

public static final ByteBuffer getImageDataFromImage(BufferedImage bufferedImage) {
WritableRaster wr;
DataBuffer db;

BufferedImage bi = new BufferedImage(128, 64, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
g.drawImage(bufferedImage, null, null);
bufferedImage = bi;
wr = bi.getRaster();
db = wr.getDataBuffer();

DataBufferInt dbi = (DataBufferInt) db;
int[] data = dbi.getData();

ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * 4);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
byteBuffer.asIntBuffer().put(data);
byteBuffer.flip();

return byteBuffer;
public static final ByteBuffer getImageDataFromTexture(final Texture2D texture) {
return texture.getImage().getData(0);
}

public static float frac(float f) {
Expand Down
Loading