Creating a layer animation 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 > Creating a layer animation in globe (ArcObjects .NET 10.6 SDK)

Creating a layer animation in globe


Summary
This topic explains how to create a layer animation track in globe. By using a layer animation track, you can change the visibility and transparency of a layer at different time stamps in an animation.

The following variables are used within the code and are defined as:
  • m_globe is an IGlobe
  • m_layer is an ILayer

In this topic


Animation extension

To create an animation in globe, first get a handle to the animation extension as shown in the following code example:
[C#]
IGlobeDisplay globeDisplay=m_globe.GlobeDisplay;
IScene scene=globeDisplay.Scene;

IBasicScene2 basicScene2=(IBasicScene2)scene; // Explicit cast.
IAnimationExtension animationExtension=basicScene2.AnimationExtension;
[VB.NET]
Dim globeDisplay As IGlobeDisplay=m_globe.GlobeDisplay
Dim scene As IScene=globeDisplay.Scene

Dim basicScene2 As IBasicScene2=CType(scene, IBasicScene2) ' Explicit cast.
Dim animationExtension As IAnimationExtension=basicScene2.AnimationExtension

Composition of an animation

An animation is composed of one or more animation tracks that can be of the same type or a different type. This means that you can create multiple tracks and play those in an animation to show dynamic visual effects. For example, you can have a layer animation track, which makes a layer transparent and a globe camera track, that moves the camera from one position to the other in the same animation.
Each animation track describes the properties of the object (a layer in this case) to be animated over the animation duration. It is very important to associate the animation track to an animation type before adding any keyframes.
See the following code example:
[C#]
IAGAnimationTrack animationTrack=new AnimationTrackClass();
IAGAnimationType animationType=new AnimationTypeGlobeLayerClass();

animationTrack.AnimationType=animationType;
[VB.NET]
Dim animationTrack As IAGAnimationTrack=New AnimationTrackClass()
Dim animationType As IAGAnimationType=New AnimationTypeGlobeLayerClass()

animationTrack.AnimationType=animationType

Keyframes

Animation tracks are a collection of keyframes of the same type. Keyframes basically store the properties of the object (a layer in this case) at different time stamps along the animation duration. The keyframes are stored in the IAGAnimationTrackKeyframes animation track.
In globe, you can change the transparency property values (from 0 to 100) and store the layer properties in keyframes. Also, the visibility of the layer can be changed to make it visible or not visible.
The following code example shows how to create four keyframes and store the value of the transparency of the layer at different time stamps in the animation. The parameters (propIndex and pValue) passed into the IAGKeyframe.set_PropertyValue() method represent the property to be changed and the value of the property.
For layer keyframes, the following are used:
  • propIndex=0 represents the visibility property of the layer. The value to be passed must be of type Boolean.
  • propIndex = 1 represents the transparency property of the layer. The value to be passed must be of type double.
[C#]
// Create four keyframes and add them to the track.
IAGAnimationTrackKeyframes animationTrackKeyframes=(IAGAnimationTrackKeyframes)
    animationTrack; //Explicit cast.

ESRI.ArcGIS.Animation.IAGKeyframe keyframe;
int nKeyframes=4;
int numKeyframe;

for (numKeyframe=0; numKeyframe <= nKeyframes - 1; numKeyframe++)
{
    keyframe=new GlobeLayerKeyframeClass();
    animationTrackKeyframes.InsertKeyframe(keyframe,  - 1);
    keyframe.TimeStamp=1.0 * numKeyframe / (nKeyframes - 1); 
        // Set transparency values.

    keyframe.set_PropertyValue(0, true); // Set visibility.
    keyframe.set_PropertyValue(1, 100 * numKeyframe / (nKeyframes - 1)); 
        // Set transparency.
}
[VB.NET]
' Create four keyframes and add them to the track.
Dim animationTrackKeyframes As IAGAnimationTrackKeyframes=CType(animationTrack, IAGAnimationTrackKeyframes) 'Explicit cast.

Dim keyframe As ESRI.ArcGIS.Animation.IAGKeyframe
Dim nKeyframes As Integer=4
Dim numKeyframe As Integer

For numKeyframe=0 To nKeyframes - 1
    keyframe=New GlobeLayerKeyframeClass()
    animationTrackKeyframes.InsertKeyframe(keyframe, -1)
    keyframe.TimeStamp=1.0 * numKeyframe / (nKeyframes - 1) ' Set transparency values.
    
    keyframe.PropertyValue(0)=True ' Set visibility.
    keyframe.PropertyValue(1)=(100 * numKeyframe / (nKeyframes - 1)) ' Set transparency.
Next numKeyframe

Setting the active properties

After adding the animation track and keyframes, the active properties of the animation track have to be set. This is useful in cases when you want to have some of the properties active in an animation. See the following code example:
[C#]
ILongArray longArrayCls=new LongArrayClass();
longArrayCls.Add(0);
longArrayCls.Add(1);
animationTrackKeyframes.ActiveProperties=longArrayCls;
[VB.NET]
Dim longArrayCls As ILongArray=New LongArrayClass()
longArrayCls.Add(0)
longArrayCls.Add(1)
animationTrackKeyframes.ActiveProperties=longArrayCls
As previously mentioned, each animation track is bound to the object that is to be animated. In this case, you're changing the transparency of the layer; consequently, the layer is your object.
The following code example attaches the animation track to a layer:
[C#]
animationTrack.AttachObject(m_layer);
[VB.NET]
animationTrack.AttachObject(m_layer)

Adding the track

Finally, the track must be added to the animation tracks container. The animation tracks container, in the case of globe, refers to the globe object. Once the track is added to the globe, the animation can be played as follows:
  • For ArcGIS Desktop applications—The animation can be played using the Animation Controls dialog box in the ArcGlobe application.
  • For ArcGIS Engine applications—The animation can be played using the IAGAnimationPlayer.PlayAnimation() method. 
See the following code example:
[C#]
IAGAnimationTracks animationTracks=(IAGAnimationTracks)m_globe; // Explicit cast.
animationTracks.AddTrack(animationTrack);
[VB.NET]
Dim animationTracks As IAGAnimationTracks=CType(m_globe, IAGAnimationTracks) ' Explicit cast.
animationTracks.AddTrack(animationTrack)






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