The following global variable types are used in the code fragments where:
m_globe is an IGlobe
m_layer is an ILayer
m_featureID is a System.Int32
Animating the camera along a path (line feature) in globe
To animate the camera along a path in globe, perform the following steps:
- Get a handle to the IGlobe object. By using a globe object, you can get the current globe display and the scene objects as shown in the following code example:
IGlobeDisplay globeDisplay=m_globe.GlobeDisplay;
IScene scene=globeDisplay.Scene;
[VB.NET] Dim globeDisplay As IGlobeDisplay=m_globe.GlobeDisplay
Dim scene As IScene=globeDisplay.Scene
- To create animations, get a handle to the animation extension via the IBasicScene2 interface. The animation extension can then be initialized. See the following code example:
IBasicScene2 basicScene2=(IBasicScene2)scene; // Explicit cast.
IAnimationExtension animationExtension=basicScene2.AnimationExtension;
[VB.NET] Dim basicScene2 As IBasicScene2=CType(scene, IBasicScene2) ' Explicit cast.
Dim animationExtension As IAnimationExtension=basicScene2.AnimationExtension
-
Since the camera has to be moved along a line feature stored in a feature class, you need to obtain the geometry of the line feature. First, get a handle to the feature class, then based on a unique feature ID, get the line feature geometry where the camera has to move. See the following code example:
IFeatureLayer featureLayer=(IFeatureLayer)m_layer; // Explicit cast.
IFeatureClass featureClass=featureLayer.FeatureClass;
IFeature feature=featureClass.GetFeature(m_featureID);
IGeometry geometry=feature.Shape;
[VB.NET] Dim featureLayer As IFeatureLayer=CType(m_layer, IFeatureLayer) ' Explicit cast.
Dim featureClass As IFeatureClass=featureLayer.FeatureClass
Dim feature As IFeature=featureClass.GetFeature(m_featureID)
Dim geometry As IGeometry=feature.Shape
- Create the animation. To create the camera fly from path, use the IAGAnimationUtils.CreateFlybyFromPath() method. To do this, first initialize the AGAnimationUtilsCls object, then initialize the AGImportPathOptionsCls object to set the path properties as shown in the following code example:
IAGAnimationUtils AGAnimationUtilsCls=new AGAnimationUtilsClass();
IAGImportPathOptions AGImportPathOptionsCls=new AGImportPathOptionsClass();
[VB.NET] Dim AGAnimationUtilsCls As IAGAnimationUtils=New AGAnimationUtilsClass()
Dim AGImportPathOptionsCls As IAGImportPathOptions=New AGImportPathOptionsClass()
- Set the properties for the AGImportPathOptions object, which defines the path (line feature) that the globe camera follows. Using this, you can set the properties of the globe camera (LookAheadFactor, RollFactor, and so on). One important property is the IAGImportPathOptions.ConversionType property. By setting this option appropriately, you can do the following:
- Move both the observer and target along the path. In this case, both the observer and target are changing. This is like flying along a path.
- Move only the observer along the path. In this case, the target is fixed. This is like flying along a path while looking at a fixed target on the surface.
- Move only the target along the path. In this case, the observer is fixed. This is like standing on the ground (as an observer) and looking at a moving target along a path.
See the following code example:
[C#] AGImportPathOptionsCls.BasicMap=(IBasicMap)m_globe; // Explicit cast.
AGImportPathOptionsCls.AnimationTracks=(IAGAnimationTracks)m_globe;
// Explicit cast.
AGImportPathOptionsCls.AnimationType=new AnimationTypeGlobeCameraClass();
AGImportPathOptionsCls.AnimatedObject=m_globe.GlobeDisplay.ActiveViewer.Camera;
AGImportPathOptionsCls.PathGeometry=geometry;
AGImportPathOptionsCls.ConversionType =
esriFlyFromPathType.esriFlyFromPathObsAndTarget;
AGImportPathOptionsCls.LookaheadFactor=0.05;
AGImportPathOptionsCls.RollFactor=0;
AGImportPathOptionsCls.AnimationEnvironment =
animationExtension.AnimationEnvironment;
IAGAnimationContainer AGAnimationContainer =
animationExtension.AnimationTracks.AnimationObjectContainer;
[VB.NET] AGImportPathOptionsCls.BasicMap=CType(m_globe, IBasicMap) ' Explicit cast.
AGImportPathOptionsCls.AnimationTracks=CType(m_globe, IAGAnimationTracks) ' Explicit cast.
AGImportPathOptionsCls.AnimationType=New AnimationTypeGlobeCameraClass()
AGImportPathOptionsCls.AnimatedObject=m_globe.GlobeDisplay.ActiveViewer.Camera
AGImportPathOptionsCls.PathGeometry=geometry
AGImportPathOptionsCls.ConversionType=esriFlyFromPathType.esriFlyFromPathObsAndTarget
AGImportPathOptionsCls.LookaheadFactor=0.05
AGImportPathOptionsCls.RollFactor=0
AGImportPathOptionsCls.AnimationEnvironment=animationExtension.AnimationEnvironment
Dim AGAnimationContainer As IAGAnimationContainer=animationExtension.AnimationTracks.AnimationObjectContainer
- Create the animation by calling the IAGAnimationUtils.CreateFlybyFromPath() method as shown in the following code example:
AGAnimationUtilsCls.CreateFlybyFromPath(AGAnimationContainer, AGImportPathOptionsCls)
;
[VB.NET] AGAnimationUtilsCls.CreateFlybyFromPath(AGAnimationContainer, AGImportPathOptionsCls)
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
- ESRI.ArcGIS.3DAnalyst (ESRI.ArcGIS.Analyst3D)
- ESRI.ArcGIS.Animation
- ESRI.ArcGIS.Carto
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.Geometry
- ESRI.ArcGIS.GlobeCore
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine: 3D Analyst |
ArcGIS Desktop Basic: 3D Analyst | ArcGIS Desktop Basic: 3D Analyst |
ArcGIS Desktop Standard: 3D Analyst | ArcGIS Desktop Standard: 3D Analyst |
ArcGIS Desktop Advanced: 3D Analyst | ArcGIS Desktop Advanced: 3D Analyst |