Revision 18657 trunk/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/MenuAnimation3D.java
MenuAnimation3D.java | ||
---|---|---|
12 | 12 |
import com.iver.andami.ui.mdiManager.IWindow; |
13 | 13 |
import com.iver.cit.gvsig.ProjectExtension; |
14 | 14 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
15 |
import com.iver.cit.gvsig.animation.AnimationLayer2D; |
|
16 |
import com.iver.cit.gvsig.animation.AnimationLayer3DFlat; |
|
17 |
import com.iver.cit.gvsig.animation.AnimationObject2D; |
|
18 |
import com.iver.cit.gvsig.animation.AnimationObject3DFlat; |
|
19 | 15 |
import com.iver.cit.gvsig.animation.AnimationPlayer; |
20 |
import com.iver.cit.gvsig.animation.Interpolator2D; |
|
21 |
import com.iver.cit.gvsig.animation.Interpolator3DFlat; |
|
22 |
import com.iver.cit.gvsig.animation.KeyFrame2D; |
|
23 |
import com.iver.cit.gvsig.animation.KeyFrame3DFlat; |
|
16 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
17 |
import com.iver.cit.gvsig.animation.animatedObject.AnimatedObjectBase; |
|
24 | 18 |
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval; |
19 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
25 | 20 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
21 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
26 | 22 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorFuntion; |
23 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.InterpolatorFactory; |
|
27 | 24 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
28 | 25 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
29 | 26 |
import com.iver.cit.gvsig.fmap.MapControl; |
... | ... | |
52 | 49 |
private AnimationContainer ac; |
53 | 50 |
private AnimationTimeTrack animationTimeTrack = null; |
54 | 51 |
private AnimationKeyFrameInterval AKFinterval; |
55 |
private AnimationObject3DFlat object3D = new AnimationObject3DFlat();
|
|
56 |
private AnimationObject2D object2D = new AnimationObject2D();
|
|
52 |
private AnimatedObjectBase object3D = new AnimatedObjectBase();
|
|
53 |
private AnimatedObjectBase object2D = new AnimatedObjectBase();
|
|
57 | 54 |
|
58 | 55 |
public void execute(String actionCommand) { |
59 | 56 |
|
... | ... | |
85 | 82 |
// Getting the active windows |
86 | 83 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
87 | 84 |
|
88 |
// crear track sino existe
|
|
85 |
// Getting the animation container.
|
|
89 | 86 |
ac = this.getAnimationContainer(); |
90 | 87 |
|
91 |
// If the w is instance of View
|
|
88 |
// If the window instance is View, it will manage extends 2D
|
|
92 | 89 |
if (w instanceof View) { |
93 | 90 |
|
91 |
// Getting the animation extension point. |
|
94 | 92 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
95 | 93 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation")); |
96 | 94 |
|
95 |
// Creating new track |
|
97 | 96 |
animationTimeTrack = this.getAnimationTimeTrack( |
98 | 97 |
"encuadrator_track_2D", ac); |
99 |
// generar el intervalo
|
|
98 |
// Creating the interval
|
|
100 | 99 |
if (AKFinterval == null) { |
101 | 100 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
102 | 101 |
.createKeyFrameInterval(); |
102 |
// Setting up interval properties. |
|
103 | 103 |
AKFinterval.setInitialTime(0.0); |
104 | 104 |
AKFinterval.setEndTime(1.0); |
105 | 105 |
} |
106 |
|
|
106 |
|
|
107 |
// Getting the current extend and adding to project extends. |
|
107 | 108 |
BaseView view = (BaseView) w; |
108 | 109 |
MapControl mapa = view.getMapControl(); |
109 | 110 |
ProjectExtent extent = ProjectFactory.createExtent(); |
... | ... | |
111 | 112 |
extent.setExtent(mapa.getViewPort().getExtent()); |
112 | 113 |
project.addExtent(extent); |
113 | 114 |
|
114 |
// generar lista de keyframes |
|
115 |
|
|
115 |
// Creating the keyframe list. |
|
116 | 116 |
ProjectExtent[] extentsList = project.getExtents(); |
117 | 117 |
keyFrameList = new ArrayList(); |
118 | 118 |
for (int i = 0; i < extentsList.length; i++) { |
119 | 119 |
ProjectExtent projectExtent = extentsList[i]; |
120 |
// KeyFrame2D kf2D = new KeyFrame2D(); |
|
121 |
KeyFrame2D kf2D = null;
|
|
120 |
|
|
121 |
IKeyFrame kf2D = null;
|
|
122 | 122 |
try { |
123 |
kf2D = (KeyFrame2D)extPoint.create("KeyFrame2D");
|
|
123 |
kf2D = (IKeyFrame)extPoint.create("KeyFrame2D");
|
|
124 | 124 |
} catch (InstantiationException e) { |
125 |
//TODO stop this loop and show a advertise message. |
|
125 | 126 |
e.printStackTrace(); |
126 | 127 |
} catch (IllegalAccessException e) { |
127 | 128 |
e.printStackTrace(); |
128 | 129 |
} |
129 | 130 |
|
131 |
// Setting up the initial and end time interval. |
|
130 | 132 |
double fin = AKFinterval.getEndTime(); |
131 | 133 |
double ini = AKFinterval.getInitialTime(); |
132 | 134 |
double size = extentsList.length; |
133 |
// Calcular el tiempo de insercion
|
|
135 |
// Calculating the insertion time.
|
|
134 | 136 |
double tiempo = 0.0; |
135 | 137 |
if (i != 0) |
136 | 138 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
137 | 139 |
kf2D.setTime(tiempo); |
138 | 140 |
// hacer funcion de insercion o adapter |
139 |
// kf2D.CapturesProperties(projectExtent); |
|
140 | 141 |
kf2D.setAnimatedObject(projectExtent); |
142 |
kf2D.CapturesProperties(); |
|
141 | 143 |
keyFrameList.add(kf2D); |
142 | 144 |
|
143 | 145 |
} |
... | ... | |
145 | 147 |
|
146 | 148 |
if (w instanceof View3D) { |
147 | 149 |
|
150 |
// Getting the animation extension point. |
|
148 | 151 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
149 | 152 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation")); |
150 | 153 |
|
154 |
// Creating new track |
|
151 | 155 |
animationTimeTrack = this.getAnimationTimeTrack( |
152 | 156 |
"encuadrator_track_3D", ac); |
153 |
// generar el intervalo |
|
157 |
|
|
158 |
// Creating the interval |
|
154 | 159 |
if (AKFinterval == null) { |
155 | 160 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
156 | 161 |
.createKeyFrameInterval(); |
... | ... | |
158 | 163 |
AKFinterval.setEndTime(1.0); |
159 | 164 |
} |
160 | 165 |
|
166 |
// Getting the current camera position and insert it into project camera list. |
|
161 | 167 |
View3D view = (View3D) w; |
162 | 168 |
Camera ca = view.getCamera(); |
163 |
|
|
164 |
|
|
165 | 169 |
ProjectCamera camera = new ProjectCamera(); |
166 |
|
|
167 | 170 |
camera.setDescription(name); |
168 | 171 |
camera.setCamera(ca); |
172 |
project.addCamera(camera); |
|
169 | 173 |
|
170 |
project.addCamera(camera); |
|
171 |
// generar lista de keyframes |
|
174 |
// Creating key frame list |
|
172 | 175 |
Object[] extentsList = project.getCameras(); |
173 | 176 |
keyFrameList = new ArrayList(); |
174 | 177 |
for (int i = 0; i < extentsList.length; i++) { |
175 | 178 |
ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
176 |
//KeyFrame3DFlat kf3D = new KeyFrame3DFlat(); |
|
177 |
KeyFrame3DFlat kf3D = null; |
|
179 |
IKeyFrame kf3D = null; |
|
178 | 180 |
try { |
179 |
kf3D = (KeyFrame3DFlat)extPoint.create("KeyFrame3DFlat");
|
|
181 |
kf3D = (IKeyFrame)extPoint.create("KeyFrame3DFlat");
|
|
180 | 182 |
} catch (InstantiationException e) { |
181 | 183 |
e.printStackTrace(); |
182 | 184 |
} catch (IllegalAccessException e) { |
183 | 185 |
e.printStackTrace(); |
184 | 186 |
} |
185 | 187 |
|
188 |
// Setting up the initial and end time interval. |
|
186 | 189 |
double fin = AKFinterval.getEndTime(); |
187 | 190 |
double ini = AKFinterval.getInitialTime(); |
188 | 191 |
double size = extentsList.length; |
189 |
// Calcular el tiempo de insercion
|
|
192 |
// Calculating the correct time for this key frame.
|
|
190 | 193 |
double tiempo = 0.0; |
191 | 194 |
if (i != 0) |
192 | 195 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
193 |
// (AKFinterval.getEndTime() - AKFinterval |
|
194 |
// .getInitialTime()) / extentsList.length); |
|
196 |
// Setting the time. |
|
195 | 197 |
kf3D.setTime(tiempo); |
196 | 198 |
// hacer funcion de insercion o adapter |
197 |
// kf2D.CapturesProperties(projectExtent); |
|
198 | 199 |
kf3D.setAnimatedObject(projectCamera); |
200 |
kf3D.CapturesProperties(); |
|
199 | 201 |
keyFrameList.add(kf3D); |
200 | 202 |
|
201 | 203 |
} |
... | ... | |
224 | 226 |
IAnimationTrack aa = ac.findTrack(name); |
225 | 227 |
if (aa == null) { |
226 | 228 |
|
229 |
// Getting the extension point. |
|
227 | 230 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
228 | 231 |
.getInstance(); |
229 | 232 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
230 | 233 |
.get("Animation")); |
231 | 234 |
|
235 |
// If f is a 2D windows, it will create with 2D specific animation type. |
|
232 | 236 |
if (f instanceof View) { |
237 |
|
|
238 |
// Finding if there are an 3D animation track. |
|
233 | 239 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_3D"); |
234 | 240 |
if (trackAux != null) { |
241 |
// if there are one, it will disable. |
|
235 | 242 |
trackAux.setEnabale(false); |
236 | 243 |
} |
237 |
AnimationLayer2D animationLayer2D = null;
|
|
244 |
IAnimationType animationLayer2D = null;
|
|
238 | 245 |
try { |
239 |
animationLayer2D = (AnimationLayer2D) extPoint
|
|
246 |
animationLayer2D = (IAnimationType) extPoint
|
|
240 | 247 |
.create("AnimationLayer2D"); |
241 | 248 |
} catch (InstantiationException e) { |
242 | 249 |
// TODO Auto-generated catch block |
... | ... | |
245 | 252 |
// TODO Auto-generated catch block |
246 | 253 |
e.printStackTrace(); |
247 | 254 |
} |
255 |
// Setting up the track properties |
|
248 | 256 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
249 | 257 |
at.setName(name); |
250 | 258 |
at.setEnabale(true); |
259 |
// Setting up the animated object |
|
251 | 260 |
View view = (View) f; |
252 | 261 |
at.setAnimatedObject(object2D); |
253 |
// Create the interpolator |
|
254 |
Interpolator2D inter2D = new Interpolator2D(); |
|
255 |
object2D.setAnimatedView(view); |
|
256 |
inter2D.setAnimatedObject(object2D); |
|
262 |
|
|
263 |
// Getting the interpolator |
|
264 |
IInterpolator inter2D = InterpolatorFactory.createObject("Interpolator2D"); |
|
265 |
object2D.addAnimatedObject("view", view); |
|
266 |
// Getting the interpolator funcion |
|
257 | 267 |
IInterpolatorFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
258 | 268 |
inter2D.setFuntion(funtion); |
259 | 269 |
|
... | ... | |
262 | 272 |
animationLayer2D.setAnimatedObject(object2D); |
263 | 273 |
} |
264 | 274 |
if (f instanceof View3D) { |
275 |
// Finding if there are an 2D animation track. |
|
265 | 276 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_2D"); |
266 | 277 |
if (trackAux != null) { |
278 |
// if there are one, it will disable. |
|
267 | 279 |
trackAux.setEnabale(false); |
268 | 280 |
} |
269 |
AnimationLayer3DFlat animationLayer3DFlat = null;
|
|
281 |
IAnimationType animationLayer3DFlat = null;
|
|
270 | 282 |
try { |
271 |
animationLayer3DFlat = (AnimationLayer3DFlat) extPoint
|
|
283 |
animationLayer3DFlat = (IAnimationType) extPoint
|
|
272 | 284 |
.create("AnimationLayer3DFlat"); |
273 | 285 |
} catch (InstantiationException e) { |
274 | 286 |
// TODO Auto-generated catch block |
... | ... | |
278 | 290 |
} |
279 | 291 |
at = (AnimationTimeTrack) ac |
280 | 292 |
.CreateTimeTrack(animationLayer3DFlat); |
293 |
|
|
281 | 294 |
at.setName(name); |
282 | 295 |
at.setEnabale(true); |
296 |
|
|
283 | 297 |
BaseView view = (BaseView) f; |
284 |
object3D.setAnimatedView(view);
|
|
298 |
object3D.addAnimatedObject("view", view);
|
|
285 | 299 |
at.setAnimatedObject(object3D); |
286 |
Interpolator3DFlat inter3DFlat = new Interpolator3DFlat(); |
|
287 |
inter3DFlat.setAnimatedObject(object3D);
|
|
300 |
|
|
301 |
IInterpolator inter3DFlat = InterpolatorFactory.createObject("Interpolator3DFlat");
|
|
288 | 302 |
IInterpolatorFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
289 | 303 |
inter3DFlat.setFuntion(funtion); |
290 | 304 |
animationLayer3DFlat.setInterpolator(inter3DFlat); |
Also available in: Unified diff