I’ve got this quad I’m using that will eventually display part of a planet’s map so players can harvest resources. What I want is to animate it from a tiny rectangle to the full-scale quad. Thing is, it’s not really animating. When I click “Show map” a tiny rectangle is displayed (expected), but it’s not grown to the wanted size. The same happens if you click to shrink it down.
There’s probably something I’m doing that is wrong. I can’t seem to find what exactly.
Halp!
Here’s the anonymous class that does the grow() and shrink().
[java]
private class MapQuad {
private final static float MAX_WIDTH_SIZE = 1200.0f;
private final static float MAX_HEIGHT_SIZE = 675.0f;
private final static int ZOOM_TIME = 250;
private final static float RATIO = 1f / ZOOM_TIME;
private final Geometry map;
private final Quad quad = new Quad(MAX_WIDTH_SIZE, MAX_HEIGHT_SIZE);
private final Node mapNode = new Node(“MapNode”);
private Transform startTransform;
private Transform endTransform;
private int step = 1;
private boolean opened;
private MapQuad(int width, int height) {
Material mat = new Material(app.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);
map.getLocalTransform().interpolateTransforms(startTransform, endTransform, RATIO * step);
mapNode.attachChild(map);
}
private void grow() {
if (step == ZOOM_TIME) {
animating = false;
opened = true;
System.out.println("Growing Quad Done " + step + " size ratio " + RATIO * step);
} else {
System.out.println("Growing Quad " + step + " size ratio " + RATIO * step);
step++;
map.getLocalTransform().interpolateTransforms(startTransform, endTransform, RATIO * step);
}
}
private void shrink() {
if (step == 1) {
animating = false;
opened = false;
System.out.println("Shrinking Quad Done " + step + " size ratio " + RATIO * step);
} else {
System.out.println("Shrinking Quad " + step + " size ratio " + RATIO * step);
step–;
map.getLocalTransform().interpolateTransforms(endTransform, startTransform, RATIO * step);
}
}
}
[/java]
The output is fine. I get things like that:
...
Growing Quad 244 size ratio 0.9760001
Growing Quad 245 size ratio 0.98
Growing Quad 246 size ratio 0.984
Growing Quad 247 size ratio 0.98800004
Growing Quad 248 size ratio 0.99200004
Growing Quad 249 size ratio 0.99600005
Growing Quad Done 250 size ratio 1.0
But when "growing", only the first "frame" is put, it's not scaled as it's expanded. When shrinking the only thing I see is when it's done shrinking and it removes everything; but the output is fine.
So, I'm wondering if the scaling isn't applied somehow. Like using "updateGeometricState()" but for transforms? I noticed the "setTransformRefresh()" but it's protected and from what I've seen I don't think I need to call this, but then again, I might...
It seems I can’t do the animation I wanted with procedural textures.
When I try to do this, growing and shrinking after a click on a button, the procedural texture is ALWAYS at the viewport’s origin and not at the geometry’s. It’s also always full size. Meaning it doesn’t take the transform interpolation into consideration. :?
So what I do is, at each frame I “reset” the geometry (with a new one) with the proper size. That works, but the main problem remains, the proc texture is at the viewport’s origin.
Help appreciated here.
Here’s the class.
[java]
class MapSurface {
private Geometry realMap;
private Quad mapSurface;
private Transform endTransform;
private Transform startTransform;
private AssetManager am;
private int width;
private int height;
private Planet body;
MapSurface(AssetManager am, int width, int height, final float ratio, Planet body) {
And yet, after two fixes I failed to do that. I feel some other dumb thing is waiting for me. *hurries to put [FIXED] before those dumb things really happen*