How to animate the camera along a path (line feature) in globe (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Interacting with the map display > Working with animations > Working with animations in 3D > How to animate the camera along a path (line feature) in globe (ArcObjects .NET 10.6 SDK)

How to animate the camera along a path (line feature) in globe

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:
  1. 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;
Dim globeDisplay As IGlobeDisplay=m_globe.GlobeDisplay
Dim scene As IScene=globeDisplay.Scene
  1. 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;
Dim basicScene2 As IBasicScene2=CType(scene, IBasicScene2) ' Explicit cast.
Dim animationExtension As IAnimationExtension=basicScene2.AnimationExtension
  1. 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;
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
  1. 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();
Dim AGAnimationUtilsCls As IAGAnimationUtils=New AGAnimationUtilsClass()
Dim AGImportPathOptionsCls As IAGImportPathOptions=New AGImportPathOptionsClass()
  1. 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:
AGImportPathOptionsCls.BasicMap=(IBasicMap)m_globe; // Explicit cast.
    // Explicit cast.
AGImportPathOptionsCls.AnimationType=new AnimationTypeGlobeCameraClass();

AGImportPathOptionsCls.ConversionType =

AGImportPathOptionsCls.AnimationEnvironment =
IAGAnimationContainer AGAnimationContainer =
AGImportPathOptionsCls.BasicMap=CType(m_globe, IBasicMap) ' Explicit cast.
AGImportPathOptionsCls.AnimationTracks=CType(m_globe, IAGAnimationTracks) ' Explicit cast.
AGImportPathOptionsCls.AnimationType=New AnimationTypeGlobeCameraClass()


Dim AGAnimationContainer As IAGAnimationContainer=animationExtension.AnimationTracks.AnimationObjectContainer
  1. Create the animation by calling the IAGAnimationUtils.CreateFlybyFromPath() method as shown in the following code example:
AGAnimationUtilsCls.CreateFlybyFromPath(AGAnimationContainer, AGImportPathOptionsCls)
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):
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