mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Image maps working mostly
This commit is contained in:
parent
e1711b5d03
commit
617a797743
@ -298,6 +298,9 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
} else if (registrant.equals(IrisScript.class)) {
|
||||
r = (ResourceLoader<T>) new ScriptResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
}else if (registrant.equals(IrisImage.class)) {
|
||||
r = (ResourceLoader<T>) new ImageResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
} else {
|
||||
J.attempt(() -> registrant.getConstructor().newInstance().registerTypeAdapters(builder));
|
||||
r = new ResourceLoader<>(dataFolder, this, rr.getFolderName(), rr.getTypeName(), registrant);
|
||||
|
@ -675,7 +675,7 @@ public class SchemaBuilder {
|
||||
}
|
||||
|
||||
if (!r.isPrimitive() && !r.equals(KList.class) && !r.equals(KMap.class) && r.getCanonicalName().startsWith("com.volmit.")) {
|
||||
warnings.addIfMissing("Missing @Desc on " + r.getSimpleName() + " in " + r.getDeclaringClass().getCanonicalName());
|
||||
warnings.addIfMissing("Missing @Desc on " + r.getSimpleName() + " in " + (r.getDeclaringClass() != null ? r.getDeclaringClass().getCanonicalName() : " NOSRC"));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -18,12 +18,16 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IrisImage extends IrisRegistrant {
|
||||
private BufferedImage image;
|
||||
@ -125,4 +129,24 @@ public class IrisImage extends IrisRegistrant {
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) {
|
||||
|
||||
}
|
||||
|
||||
public void writeDebug(IrisImageChannel channel) {
|
||||
|
||||
|
||||
try {
|
||||
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
|
||||
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
for(int i = 0; i < getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < getHeight(); j++)
|
||||
{
|
||||
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB());
|
||||
}
|
||||
}
|
||||
ImageIO.write(b, "png", at);
|
||||
Iris.warn("Debug image written to " + at.getPath() + " for channel " + channel.name());
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.project.SchemaBuilder;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
@ -43,7 +44,7 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a carving configuration")
|
||||
@Desc("Represents an image map")
|
||||
@Data
|
||||
public class IrisImageMap {
|
||||
@RegistryListResource(IrisImage.class)
|
||||
@ -69,11 +70,19 @@ public class IrisImageMap {
|
||||
@Desc("Center 0,0 to the center of the image instead of the top left.")
|
||||
private boolean centered = true;
|
||||
|
||||
private AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
|
||||
public double getNoise(IrisData data, int x, int z)
|
||||
{
|
||||
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
|
||||
IrisImage i = imageCache.aquire(() -> {
|
||||
IrisImage ii = data.getImageLoader().load(image);
|
||||
return ii;
|
||||
});
|
||||
if(i == null)
|
||||
{
|
||||
Iris.error("NULL IMAGE FOR " + image);
|
||||
}
|
||||
|
||||
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx,zz) -> rawNoise(i, xx, zz));
|
||||
}
|
||||
|
||||
@ -85,7 +94,7 @@ public class IrisImageMap {
|
||||
z = isTiled() ? z % i.getHeight() : z;
|
||||
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;
|
||||
z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z;
|
||||
double v = i.getValue(getChannel(), (int)(x/coordinateScale), (int)(z/coordinateScale));
|
||||
double v = i.getValue(getChannel(), (int)x, (int)z);
|
||||
return isInverted() ? 1D - v : v;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,6 @@ public class ImageNoise implements NoiseGenerator {
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return noise(x, y, 0);
|
||||
return noise(x, z + y);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user