Revision 23595
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/animatedObject/AnimationObject3DFlat.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
1 | 20 |
package com.iver.cit.gvsig.animation.animatedObject; |
2 | 21 |
|
3 | 22 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/animationType/AnimationTypeFactoryLayer3DFlat.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
1 | 20 |
package com.iver.cit.gvsig.animation.animationType; |
2 | 21 |
|
3 | 22 |
import com.iver.cit.gvsig.animation.AnimationFactory; |
... | ... | |
40 | 59 |
register(registerName, new AnimationTypeFactoryLayer3DFlat(), "com.iver.cit.gvsig.animation.AnimationLayer3DFlat"); |
41 | 60 |
} |
42 | 61 |
|
62 |
/** |
|
63 |
* Return the register name of this animation type. |
|
64 |
*/ |
|
65 |
|
|
43 | 66 |
public String getRegisterName() { |
44 | 67 |
return registerName; |
45 | 68 |
} |
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/animationType/AnimationLayer3DFlat.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.animationType; |
|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
2 | 19 |
|
3 |
//import org.gvsig.gvsig3dgui.view.View3D; |
|
4 | 20 |
|
21 |
package com.iver.cit.gvsig.animation.animationType; |
|
22 |
|
|
5 | 23 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
6 | 24 |
|
7 | 25 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
... | ... | |
27 | 45 |
private String name = "Animacion vista 3D plana"; |
28 | 46 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
29 | 47 |
private IInterpolator interpolator; |
30 |
// private String nameClassView; |
|
31 | 48 |
|
32 | 49 |
private IAnimatedObject animationObject3DFlat = new AnimationObject3DFlat() ; |
33 | 50 |
private String titleWindow; |
... | ... | |
64 | 81 |
|
65 | 82 |
public void AppliesToObject(Object animated) { |
66 | 83 |
|
67 |
// TODO implementar esta funcion para vistas 3D esfericas. |
|
68 | 84 |
KeyFrame3DFlat keyf = (KeyFrame3DFlat) animated; |
69 | 85 |
ProjectCamera projectCamera = (ProjectCamera) keyf.getAnimatedObject(); |
70 | 86 |
|
71 | 87 |
m_canvas3d = (IViewerContainer) ((AnimationObject3DFlat)animationObject3DFlat).getAnimatedCanvas3D(); |
72 | 88 |
m_canvas3d.getOSGViewer().setCamera(projectCamera.getCamera()); |
73 |
|
|
74 |
// View3D view3D = (View3D) animationObject3DFlat.getAnimatedObject("view"); |
|
75 |
// view3D.setCamera(projectCamera.getCamera()); |
|
76 |
|
|
77 |
// Hud hud = (Hud) view.getCanvas3d().getOSGViewer().getNodeFromHUD(0); |
|
78 |
// hud.setAnimationTime(AnimationPlayer.getCurrentTime()/1000); |
|
79 |
// hud.updateHud(); |
|
80 |
|
|
81 |
|
|
82 |
//view3D.getCanvas3d().repaint(); |
|
89 |
|
|
83 | 90 |
m_canvas3d.repaint(); |
84 | 91 |
} |
85 | 92 |
|
... | ... | |
109 | 116 |
IWindow[] viewArray = PluginServices.getMDIManager().getAllWindows(); |
110 | 117 |
for (int i = 0; i < viewArray.length; i++) { |
111 | 118 |
IWindow window = viewArray[i]; |
112 |
//if the view is a view3D |
|
113 |
//if (window.getClass().getName().equals(this.nameClassView)){ |
|
114 |
// get the actual name of the view, and compare it with the view saved in xml. |
|
115 | 119 |
if(window.getWindowInfo().getTitle().equals(this.titleWindow)){ |
116 | 120 |
BaseView newView = (BaseView)window;// Working with base view |
117 | 121 |
((AnimationObject3DFlat) this.animationObject3DFlat).setAnimatedView(newView); |
... | ... | |
131 | 135 |
public void setAnimatedObject(Object object) { |
132 | 136 |
if (object instanceof AnimationObject3DFlat) |
133 | 137 |
this.animationObject3DFlat = (IAnimatedObject) object; |
134 |
|
|
135 | 138 |
} |
136 | 139 |
|
137 | 140 |
public XMLEntity getXMLEntity() { |
138 | 141 |
|
139 |
|
|
140 | 142 |
XMLEntity xml = new XMLEntity(); |
141 | 143 |
xml.putProperty("className", this.getClassName()); |
142 | 144 |
xml.putProperty("description", description); |
143 | 145 |
xml.putProperty("animationTrackTipe", typeTrack); |
144 | 146 |
|
145 | 147 |
BaseView myActualView = (BaseView) animationObject3DFlat.getAnimatedObject("view"); |
146 |
//xml.putProperty("nameClassView", myActualView.getClass().getName()); |
|
147 | 148 |
|
148 | 149 |
titleWindow = myActualView.getWindowInfo().getTitle(); |
149 | 150 |
xml.putProperty("titleWindow", titleWindow); |
... | ... | |
156 | 157 |
this.className= xml.getStringProperty("className"); |
157 | 158 |
if (xml.contains("animationTrackTipe")) |
158 | 159 |
this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
159 |
// if (xml.contains("nameClassView")) |
|
160 |
// this.nameClassView = xml.getStringProperty("nameClassView"); |
|
161 | 160 |
if (xml.contains("titleWindow")) |
162 | 161 |
this.titleWindow = xml.getStringProperty("titleWindow"); |
163 | 162 |
|
... | ... | |
165 | 164 |
|
166 | 165 |
try { |
167 | 166 |
String class_name = xmlInterpolator.getStringProperty("className"); |
168 |
Class classInterpolator = Class.forName(class_name); |
|
167 |
Class<?> classInterpolator = Class.forName(class_name);
|
|
169 | 168 |
Object obj = classInterpolator .newInstance(); |
170 | 169 |
IPersistence objPersist = (IPersistence) obj; |
171 | 170 |
objPersist.setXMLEntity(xmlInterpolator); |
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/interpolator/Interpolator3DFlat.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
1 | 19 |
package com.iver.cit.gvsig.animation.interpolator; |
2 | 20 |
|
3 | 21 |
import java.util.List; |
... | ... | |
18 | 36 |
private String description = "Interpolaci?n basada en encuadres"; |
19 | 37 |
private String name = "Interpolator3DFlat"; |
20 | 38 |
|
21 |
public IKeyFrame interpolate(List kfList, int index, double time) { |
|
39 |
public IKeyFrame interpolate(List<IKeyFrame> kfList, int index, double time) {
|
|
22 | 40 |
KeyFrame3DFlat KF = new KeyFrame3DFlat(); |
23 | 41 |
|
24 | 42 |
if (kfList == null) |
... | ... | |
47 | 65 |
ProjectCamera vp1 = (ProjectCamera) kf1.getAnimatedObject(); |
48 | 66 |
ProjectCamera vp2 = (ProjectCamera) kf2.getAnimatedObject(); |
49 | 67 |
|
50 |
// ViewPort vp = view.getMapControl().getViewPort(); |
|
51 |
|
|
52 | 68 |
Camera cam1 = vp1.getCamera(); |
53 | 69 |
Camera cam2 = vp2.getCamera(); |
54 | 70 |
double time1 = kf1.getTime(); |
... | ... | |
130 | 146 |
} |
131 | 147 |
|
132 | 148 |
public void setXMLEntity(XMLEntity xml) { |
133 |
// if (xml.contains("className")) |
|
134 |
// this.className= xml.getStringProperty("className"); |
|
135 | 149 |
if (xml.contains("description")) |
136 | 150 |
this.description = xml.getStringProperty("description"); |
137 | 151 |
|
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/interpolator/Interpolator3DSpherical.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
1 | 20 |
package com.iver.cit.gvsig.animation.interpolator; |
2 | 21 |
|
3 | 22 |
import java.util.List; |
... | ... | |
17 | 36 |
public class Interpolator3DSpherical implements IInterpolator { |
18 | 37 |
|
19 | 38 |
private IInterpolatorTimeFuntion function; |
20 |
private String description = "Interpolaci�n basada en encuadres";
|
|
39 |
private String description = "Interpolaci?n basada en encuadres";
|
|
21 | 40 |
private String name = "Interpolator3DSpherical"; |
22 | 41 |
|
23 |
public IKeyFrame interpolate(List kfList, int index, double time) { |
|
42 |
public IKeyFrame interpolate(List<IKeyFrame> kfList, int index, double time) {
|
|
24 | 43 |
KeyFrame3DFlat KF = new KeyFrame3DFlat(); |
25 | 44 |
|
26 | 45 |
if (kfList == null) |
27 | 46 |
return null; |
28 | 47 |
|
29 | 48 |
|
30 |
/*Interpolaci�n por cuaterniones.*/
|
|
49 |
/*Interpolaci?n por quaterniones.*/
|
|
31 | 50 |
|
32 | 51 |
double newTime = this.getFuntion().interpolate(time); |
33 | 52 |
|
... | ... | |
57 | 76 |
|
58 | 77 |
newTime = (newTime-time1)/(time2-time1);//normalize time 0..1 |
59 | 78 |
|
60 |
|
|
61 | 79 |
Quat from = cam1.getViewMatrix().getRotate(); |
62 | 80 |
Quat to = cam2.getViewMatrix().getRotate(); |
63 | 81 |
|
... | ... | |
70 | 88 |
Matrix m = Matrix.rotate(q); |
71 | 89 |
Matrix m2 = m.prod(m1); |
72 | 90 |
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 | 91 |
Camera c = new Camera(); |
81 | 92 |
c.setViewMatrix(m2); |
82 | 93 |
|
... | ... | |
100 | 111 |
|
101 | 112 |
} |
102 | 113 |
|
103 |
private double doubleInterpolate(double from, double to, double time) { |
|
104 |
if (from == to) |
|
105 |
return from; |
|
106 |
return from + (to - from) * time; |
|
107 |
} |
|
114 |
// private double doubleInterpolate(double from, double to, double time) {
|
|
115 |
// if (from == to)
|
|
116 |
// return from;
|
|
117 |
// return from + (to - from) * time;
|
|
118 |
// }
|
|
108 | 119 |
|
109 | 120 |
private Vec3 vec3LinearInterpolate(Vec3 from, Vec3 to, double time) { |
110 | 121 |
if (from.equals(to)) |
trunk/libraries/libAnimation3D/src/main/java/com/iver/cit/gvsig/animation/keyFrame/KeyFrame3DFlat.java | ||
---|---|---|
24 | 24 |
} |
25 | 25 |
|
26 | 26 |
public String getName() { |
27 |
// TODO Auto-generated method stub |
|
28 | 27 |
return this.name; |
29 | 28 |
} |
30 | 29 |
|
31 |
public List getPropertiesList() { |
|
32 |
// TODO Auto-generated method stub |
|
30 |
public List<IKeyFrame> getPropertiesList() { |
|
33 | 31 |
return null; |
34 | 32 |
} |
35 | 33 |
|
... | ... | |
38 | 36 |
|
39 | 37 |
} |
40 | 38 |
|
41 |
public void setPropertiesList(List list) { |
|
39 |
public void setPropertiesList(List<IKeyFrame> list) {
|
|
42 | 40 |
// TODO Auto-generated method stub |
43 |
|
|
44 | 41 |
} |
45 | 42 |
|
46 | 43 |
public String toString() { |
... | ... | |
48 | 45 |
result = " keyframe3DFlats:\n"; |
49 | 46 |
result += " tiempo: " + this.time; |
50 | 47 |
result += " nombre del extent: " + this.projectCamera.getDescription(); |
51 |
|
|
52 |
// result= "Name: " + this.getName(); |
|
53 | 48 |
return result; |
54 | 49 |
} |
55 | 50 |
|
56 | 51 |
|
57 | 52 |
|
58 | 53 |
public Object getAnimatedObject() { |
59 |
// TODO Auto-generated method stub |
|
60 | 54 |
return projectCamera; |
61 | 55 |
} |
62 | 56 |
public void setAnimatedObject(Object object) { |
... | ... | |
90 | 84 |
|
91 | 85 |
public void setXMLEntity(XMLEntity xml) { |
92 | 86 |
|
93 |
// if (xml.contains("keyFrameName")) |
|
94 |
// this.name = xml.getStringProperty("keyFrameName"); |
|
95 | 87 |
if (xml.contains("time")) |
96 | 88 |
this.time = xml.getDoubleProperty("time"); |
97 | 89 |
if (xml.contains("keyFrameAlias")) |
98 | 90 |
this.aliasKeyFrame = xml.getStringProperty("keyFrameAlias"); |
99 | 91 |
|
100 |
//this.projectCamera.setXMLEntity(xml.getChild(0)); |
|
101 |
|
|
102 | 92 |
// Get camera |
103 | 93 |
XMLEntity xmlProp = xml.getChild(0); |
104 | 94 |
if (xmlProp.contains("eyeX")) { |
105 | 95 |
try { |
106 | 96 |
String className = xmlProp.getStringProperty("className"); |
107 |
Class classProp = Class.forName(className); |
|
97 |
Class<?> classProp = Class.forName(className);
|
|
108 | 98 |
Object obj = classProp.newInstance(); |
109 | 99 |
IPersistence objPersist = (IPersistence) obj; |
110 | 100 |
objPersist.setXMLEntity(xmlProp); |
trunk/libraries/libAnimation3D/src/test/java/com/iver/cit/gvsig/animation/CreateKeyFrame3DTest.java | ||
---|---|---|
11 | 11 |
public class CreateKeyFrame3DTest extends TestCase { |
12 | 12 |
|
13 | 13 |
|
14 |
private IKeyFrame keyframe; |
|
15 |
|
|
16 | 14 |
public void test1() { |
17 | 15 |
|
18 | 16 |
AnimationKeyFrame3DFlatFactory.register(); |
... | ... | |
24 | 22 |
//System.out.println("Creating ..."); |
25 | 23 |
try { |
26 | 24 |
System.out.println("Creating ..."); |
27 |
keyframe = (IKeyFrame) extPoint.create("KeyFrame3DFlat"); |
|
25 |
IKeyFrame keyframe = (IKeyFrame) extPoint.create("KeyFrame3DFlat"); |
|
26 |
keyframe.getName(); |
|
28 | 27 |
} catch (InstantiationException e) { |
29 | 28 |
// TODO Auto-generated catch block |
30 | 29 |
e.printStackTrace(); |
Also available in: Unified diff