Also, I noticed a bug in your createShape function:
[java] public static com.jme3.scene.Geometry createShape(BufferedImage shapeImage, float height)
{
Geometry geom = createGeometry(shapeImage);
geom = ShapeUtilities.combineComponents(geom, PIXEL_DISTANCE);
geom = simplify(geom, SIMPLIFY_AMOUNT);
geom = scale(geom, 1d / shapeImage.getWidth(), 1d / shapeImage.getHeight());//we scale it to [0,1] so it have correct uv.
MeshData mesh = createShape(geom, 0.05f);
Coordinate center = getCenter(geom);
mesh = mesh.translate(new Vector3f( (float)-center.x, 0, (float)-center.y) );
com.jme3.scene.Geometry g = new com.jme3.scene.Geometry("", mesh.createMesh());
return g;
}[/java]
This function doesnât use the âheightâ argument anywhere. I assume âheightâ is suppose to be where the fixed 0.05f value is.
After further testing⌠changes in size does fix the really big exception⌠but it isnât clear what is happening. Certain sizes work, while others donât. I just kept slowly scaling up and down images until they didnât cause exceptions anymore.
Still not sure what is causing the tan âX blockâ image exceptionâŚ
shape3d creates a shape defined by where there is black color, or something close to a black color. If there is no black color, and thus no shape (like in the x shape), or if the shape defined gets split in two, I would expect an error.
Iâld create a new version of ShapeUtilities.java and lower the BLACK_COLOR_THRESHOLD, or enable createGeometry to receive this value.
line 23 (what I would alter):
[java]
private static final int BLACK_COLOR_THRESHOLD = 10;
[/java]
line 116 and on (to ilustrate);
[java]
/** Creates a point where there is black color.*/
public static Geometry createGeometry(BufferedImage image)
{
ArrayList<Point> points = new ArrayList<Point>(128 * 128);
image = ImageUtilities.rotateImage(image, FastMath.PI);
for (int i = 0; i < image.getWidth(); i++)
{
for (int j = 0; j < image.getHeight(); j++)
{
Color color = ImageUtilities.getColor(image, i, j, true);
boolean opaque = (color.getAlpha() > BLACK_COLOR_THRESHOLD);
boolean black = ((color.getRed() + color.getGreen() + color.getBlue()) / 3 < BLACK_COLOR_THRESHOLD);
if (opaque && black)
{
points.add(createPoint(new Coordinate(i, j)));
}
}
}
GeometryCollection g = new GeometryCollection(points.toArray(new Point[points.size()]), GEOMETRY_FACTORY);
return g;
}
[/java]
Ahhhh, I see how it works. I thought it worked only via the alpha channel to determine what points to fill (wouldnât this make more sense?)⌠Iâll tweak my shape3d code accordingly. Thanks!
Glad to help. Having the option to choose would be best I guess, so you can use images with and without alpha values.
Iâm using shape3d code for the terrain surface thingy iâve made, but I had to do add some methods to it.
@tralala: Want to give googlecode another attempt? Then we can create a maintainable project