[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.gef3d] Re: interpolated animation


OK, I was actually able to implement a simple version of this pretty easily..

First, I have a seperate model runnning; anytime there is a change in state the model listerner does this:

public void update(IModel model) {
for (animationStep = 0; animationStep < animationStepCount; animationStep++) {
figure.invalidateTree();
refresh();
figure.getUpdateManager().performUpdate();
}
animationStep = 0;
}



That forces constraints to be recalculated, which does this:

   Map<Object, IVector3f> startPoints = new HashMap<Object, IVector3f>();
   Map<Object, Vector3f> addPoints = new HashMap<Object, Vector3f>();

protected void calculateConstraints(GraphicalEditPart editPart) {
Object agent = editPart.getModel();
ILocation location = getLocationProvider().getLocation(agent);
if (location != null) {
IFigure3D agentFigure = (IFigure3D) editPart.getFigure();
IVector3f endPoint = new Vector3fImpl((float) GenericEditPart.SCALE * location.getX(),
(float) GenericEditPart.SCALE * location.getY(), -GenericEditPart.SCALE);
if (((Scape) getMemberProvider().getParent(getModel())).getPeriod() > 0) {
IVector3f startPoint;
Vector3f addPoint;
if (animationStep == 0) {
startPoint = agentFigure.getPosition3D().getLocation3D();
startPoints.put(agent, startPoint);
addPoint = new Vector3fImpl();
Math3DVector3f.sub(endPoint, startPoint, addPoint);
Math3DVector3f.scale(1.0f / animationEnd, addPoint, addPoint);
addPoints.put(agent, addPoint);
} else {
startPoint = startPoints.get(agent);
addPoint = addPoints.get(agent);
}
Vector3f intermediatePoint = new Vector3fImpl();
IVector3f currentPoint = agentFigure.getPosition3D().getLocation3D();
Math3DVector3f.add(currentPoint, addPoint, intermediatePoint);
agentFigure.getPosition3D().setLocation3D(intermediatePoint);
} else {
agentFigure.getPosition3D().setLocation3D(endPoint);
}
}
}


(The location and member provider are AGF classes, their usage should be pretty obvious.)


On 2009-06-16 01:21:28 -0700, Kristian Duske <kristian.duske@xxxxxxxxxxxxxxxx> said:


Hi Miles,

OK, this is waaay out on the "some day would be nice" frontier, but I'm wondering if there is any way to get animation for figures that have moved between refreshes, ala GEF. (Actyually, I haven't had great success getting this to work there anyway.) That is, if you place a figure at X[1],Y[1],Z[1] and then move that figure to X1[4],Y1[1],Z1[1] to have the intermediate step(s) X1[2],Y1[1],Z1[1], X1[3],Y1[1],Z1[1] rendered at some time slice period. (Of course one could do it manually but that's not practical for all cases.)

This is on my mental to do list, but it has pretty low priority right now. We will get to animations sooner or later because we will need this for some nice GUI enhancements, but if we do this, we should get it right. That means it should be applicable to all kinds of figure changes (moving, resizing, rotating, ...) and it should be non-invasive so that it can be applied to all kinds of figures, 2D and 3D.


So yeah, we will do this, but there are other GEF3D shortcomings that are much more important to fix right now, so this is not going to happen in the near future - sorry!

Best regards
Kristian