3DAnalyst


Supported with:
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, Geodatabase, GISClient, ArcWeb, DataSourcesFile, DataSourcesGDB, DataSourcesOleDB, DataSourcesRaster, DataSourcesNetCDF, GeoDatabaseDistributed, GeoDatabaseExtensions, Carto, NetworkAnalysis, Location, GeoAnalyst, Animation, Maplex, Geoprocessing, NetworkAnalyst, Schematic, SpatialAnalyst

Additional library information: Contents, Object Model Diagram

The 3DAnalyst library contains objects for working with 3D scenes in a similar way that the Carto library contains objects for working with 2D maps. The Scene object is one of the main objects of the library; it is the container for data similar to the Map object. The Camera object specifies how the scene is viewed regarding the positioning of the features relative to the observer. A scene consists of one or more layers that specify the data in the scene and how the data is drawn. The 3DAnalyst library provides the base for customization of the scene, although it also addresses some aspects of globe (see the GlobeCore library for more details).
 
A SceneControl and a set of scene commands exists in the Controls library together with a ToolbarControl, TOCControl, and helper objects for creating your own custom commands.

The objects that implement this functionality are grouped into a number of library subsystems. These library subsystems are:

Scene

The Scene coclass is central to 3D Analyst and allows you to access the 3D view and the data it contains. Although developers can directly use the Scene object in their applications, it is more common for developers to use a higher-level object, such as the SceneControl or ArcGIS Desktop application. The higher-level object allows the developer to further control the 3D view and implement interfaces such as IScene, ISceneBookmarks, IAGAnimationTracks, and so on. There is only one Scene object instantiated in an ArcScene application or a SceneControl. Contained in a Scene object, the SceneGraph coclass handles the 3D drawing and rendering functionalities. The general relationship is shown in the following illustration:
 
 
When creating custom commands, tools, or menus, you can use the SceneHookHelper object, which makes it straightforward to create a command that works with the SceneControl and ToolbarControl and the ArcScene application. The SceneHookHelper object is used to hold on to the hook, and the ISceneHookHelper interface it implements can return the SceneViewer, Scene, SceneGraph, and Camera regardless of the type of hook that is passed. The following code example in the ICommand.Create() function shows how to get a handle to the scene using the SceneHookHelper:
 

[C#]
  ISceneHookHelper m_pSceneHookHelper;
  IScene m_pScene;
  ..
  public void OnCreate(object hook)
  {
m_pSceneHookHelper = new SceneHookHelperClass ();
m_pSceneHookHelper.Hook = hook;
m_pScene = m_pSceneHookHelper.Scene;
  }

SceneGraph

The SceneGraph in 3DAnalyst, internally implemented as a directed acyclic graph (DAG), provides a hierarchical organization of the scene that makes some processes more efficient in 3D graphics applications. It performs the following three main functions:
 
In addition to these functions, the SceneGraph coclass also helps with the 3D rendering by implementing the IDisplay3D interface, which converts the layer data and symbology into drawing calls. Therefore, the SceneGraph coclass plays a pivotal role in visualization in 3D Analyst.
 
The SceneGraph coclass is often the access point to other 3D rendering-related coclasses. The most important interfaces that the SceneGraph coclass implements are ISceneGraph, IViewer3D, and IDisplay3D. Use ISceneGraph to handle general rendering operations, IViewer3D to manage scene viewers, IDisplay3D to perform flashings, and so on. Another useful interface is ISceneGraphEvents. If you need to make some OpenGL calls to assist your visualization, you could embed those calls in a BeforeDraw event or an AfterDraw event. The following code example shows a common way to get a handle of the SceneGraph:
 

[C#]
 //To get the SceneGraph.
 IScene pScene = GetScene();
 ISceneGraph pSG = pScene.SceneGraph;

 //To get a camera of the active viewer.
 ICamera pCamera = pSG.ActiveViewer.Camera;

 //Some actions...

 //To refresh/redraw all viewers:
 pSG.RefreshViewers();

 //To redraw an individual viewer (for example, the active viewer), use
 pSG.ActiveViewer.Redraw(true);

3D properties

There are several types of layers frequently used in the Scene coclass including graphics, features, triangulated irregular networks (TINs), and raster layers. Each of these layers can have its own 3D properties, such as base height, extrusions, and so on, which are available on their respective layer property pages on the user interface. Through ArcObjects, you can get and set these properties and reapply them to accommodate your specific 3D visualization needs. See the following illustration for their relationships:
 
 
Layer 3D properties should be accessed via LayerExtension collections. At ArcGIS 9, there was only one layer extension—of I3DProperties type—used by scene; therefore, getting a handle to it is straightforward. The following code example allows you to get a handle to the 3D properties of the first layer in the scene:
 

[C#]
 IScene pScene = GetScene();

 IFeatureLayer pFeatLyr = (IFeatureLayer) pScene.get_Layer(0);
 I3DProperties p3DProp = null;
 ILayerExtensions pLyrExt = (ILayerExtensions) pFeatLyr;

 for(int i=0; i<pLyrExt.ExtensionCount; i++)
 {
   if(pLyrExt.get_Extension(i) is I3DProperties)
   {
 p3DProp = (I3DProperties) pLyrExt.get_Extension(i);
 break;
   }
 }

 //Get or set the feature layer 3D properties.
 p3DProp.SmoothShading = true;

Scene exporters

Scene exporters convert scenes to formats for use in other applications. Available exporters include VRMLExporter, AVIExporter, and QuickTimeExporter. The Virtual Reality Modeling Language (VRML) exporter, for use in scene only, converts the scene to VRML 2.0 format. This is an open, industry-standard, 3D graphics format. The Audio Video Interleaved (AVI) and QuickTime exporters can be used in both scene and globe and convert the animation defined in a document to one of these two common video formats. The following illustration shows that all three coclasses implement the ISceneExporter3D interface:
 
 
At ArcGIS 9.2, animations in scene can be created using ArcObjects available in the newly introduced Animation library. It is important to mention that the ArcObjects in the 3DAnalyst library for creating animations at ArcGIS 9 and 9.1 can still be used to export the animations to AVI or QuickTime formats, but it is highly recommended that you use the new objects in the Animation library for ArcGIS 9.2 projects. For more information, see the Animations section in this document.
 
The following code example shows the minimum way to export the scene to a VRML model. The assumption is that you have some data already added to the scene. The script exports a VRML model using the default settings. If you want to customize your settings, query interface (QI) to ISceneVideoExporter and IVRMLExporter for VRMLExporter.
 

[C#]
IScene pScene = GetScene();
ISceneViewer pSV = pScene.SceneGraph.ActiveViewer;

//Export VRML.

ISceneExporter3d pVRML = new VRMLExporterClass();
pVRML.ExportFileName = "C:\\temp\\test.wrl";
pVRML.ExportScene(pScene);

Scene and globe viewer

The scene viewer represents a 3D display window in scene. The equivalent in ArcGlobe is the globe viewer. Both application programs support one or more viewers. The primary viewer is displayed in the main application window. Subviewers are opened in separate floating windows. The viewer with current focus is the active viewer. The perspective of a scene viewer is controlled by the Camera of the Scene (the equivalent for Globe is GlobeCamera). I3DViewer extracts some common properties and methods applicable to both scene and globe viewers and adds others—for example, full-screen viewing—so it can be used by both a scene and a globe. The following illustration shows these relationships for the scene and scene viewer and the globe and globe viewer:
 
 
 
The following code example shows a way to get the Camera object of the active scene viewer using both the ISceneViewer and I3DViewer interfaces. The usage for both interfaces is similar. The camera object returned is the same using either interface because both pointers (pSV and p3DV) are pointing to the same viewer (the active viewer) and there is only one camera object for each viewer.
 

[C#]
 IScene pScene = GetScene();
 ISceneGraph pSceneGraph = pScene.SceneGraph;
 ISceneViewer pSceneViewer = pSceneGraph.ActiveViewer;
 I3DViewer p3DViewer = (I3DViewer) pSceneGraph.ActiveViewer;
 ICamera pCam1 = pSceneViewer.Camera;
 ICamera pCam2 = p3DViewer.Camera;
 if(pCam1.Equals(pCam2)) MessageBox.Show("pCam1 is equal to pCam2");

3D symbols

3D symbols provide enhanced capabilities for feature representation in 3D viewing environments. There are several types of 3D symbols for points, polylines, and polygons. They offer simple geometry primitives—for example, cubes, spheres, and tubes. They can also use complex and textured geometry, such as, models of buildings or planes. This variety of capabilities is useful for the more abstract demands of scientific visualization as well as photo-realism for simulation. Supported 3D marker symbols are SimpleMarker3DSymbol, Marker3DSymbol, and CharacterMarker3DSymbol. Supported 3D line symbols are SimpleLine3DSymbol and TextureLineSymbol. TextureFillSymbol is used for polygons. The following illustration provides an overview of these symbols. For a detailed view of these 3D symbol components, see the 3DAnalyst Object Model diagram.
 
 
TextureLineSymbol and TextureFillSymbol have one associated GeometryMaterial; it can be read and set (by reference) using the symbol's Texture property. A 3D marker symbol can have multiple instances of GeometryMaterial. Each is maintained by the GeometryMaterialList coclass that is associated with a Multipatch geometry. This, in turn, can be instantiated by using the GeneralMultipatchCreator coclass or imported using the Import3DFile coclass. In fact, all symbol templates stored in the ESRI-provided 3D Marker Symbol styles are created by using either the GeneralMultipatchCreator coclass or the Import3DFile coclass. The end result of using these two coclasses is a MultiPatch geometry that, when used with GeometryMaterial, can have color, texture (that is, image), or both.
 
To get the properties of a MultiPatch geometry, whether it is textured or not, use the IGeneralMultipatchInfo interface of the Multipatch coclass from the Geometry library. Beginning with ArcGIS 9, a Multipatch can be persisted as the geometry (shape) of a feature in a feature class in either a personal geodatabase (*.mdb) or in ArcSDE. The same geometry, if persisted as the shape of a feature in a shapefile, would lose its GeometryMaterial (color and texture). See the following illustration:
 
 
The following code example allows you to get the GeometryMaterial count for the first feature of the first layer (assuming it is a feature layer) in the scene. It shows both ways to query the property when the layer consists of a textured multipatch feature class (query multipatch geometry property) or a point feature layer symbolized using a 3D marker symbol (query 3D marker symbol property).
 

[C#]
 IScene pScene = GetScene();

 IFeatureLayer pFeatLyr = (IFeatureLayer) pScene.get_Layer(0);

 IFeatureClass pFeatCls = pFeatLyr.FeatureClass;

 IFeatureCursor pFeatCur = pFeatCls.Search(null,true);

 IFeature pFeature = pFeatCur.NextFeature();

 //If textured Multipatch:

 if(pFeatCls.ShapeType == esriGeometryType.esriGeometryMultiPatch)
 {
IGeneralMultiPatchInfo pMltPchInfo = (IGeneralMultiPatchInfo) pFeature.Shape;
MessageBox.Show(string.Format("Material Count in the 1st Feature of the 1st Layer: {0} ", pMltPchInfo.MaterialCount));
 }

 //Else if point feature layer:

 else if(pFeatCls.ShapeType == esriGeometryType.esriGeometryPoint)
 {
IGeoFeatureLayer pGeoFtrLyr = (IGeoFeatureLayer) pFeatLyr;
IFeatureRenderer pRenderer = pGeoFtrLyr.Renderer;
ISymbol pSymbol = pRenderer.get_SymbolByFeature(pFeature);

//If 3D marker symbol:
if(pSymbol is IMarker3DSymbol)
{
 IMarker3DSymbol p3DMarker = (IMarker3DSymbol) pSymbol;
 MessageBox.Show(p3DMarker.MaterialCount.ToString());
}
 }

Animations

Animations allow you to create dynamic visual effects by storing actions (behavior of objects), which can be replayed later. In scene, you can create animations to visualize changes in the view, scene properties, and layer properties as well as temporal changes in the data. At ArcGIS 9.2, animations can be created using the newly introduced Animation library.
 
ArcObjects in the 3DAnalyst library used for creating animations at ArcGIS 9 and 9.1 can still be used, and existing projects using these objects should still compile. If you see any issues with compilation of projects, please be sure to reference the new Animation library; however, it is highly recommended that you use the new objects in the Animation library for ArcGIS 9.2 projects.
 
As described in the Animation library overview, an animation consists of one or more animation tracks (AGAnimationTracks), which control changes of the properties of an object, such as the scene's background color, the visibility of a layer, or a camera location. Each track is associated to a certain AGAnimationType. AGAnimationType properties—AnimationTypeCamera, AnimationTypeLayer, AnimationTypeScene, and AnimationTypeTimeLayer—are available out of the box in scene. Developers can optionally implement custom types.