Click or drag to resize

Raster and Projection Streams

The RasterStream and ProjectionStream classes allow for implementers to stream new data to a Raster and Projection over time. These subclasses can be used in locations that accept those base types, but in contrast to the base types, their data can change over time.

For example, this pattern allows for a projection to move and change orientation with time, or a raster within Insight3D to stream video. Since textures can be created from rasters, users can place video and other dynamic raster data on any object within Insight3D that supports textures, such as the Marker Batch Primitive and Surface Mesh Primitive. Similarly, the ProjectedRaster primitive, which projects an image onto the ellipsoid or terrain, can be used with RasterStream and ProjectionStream to display video while transforming how it is projected.

Raster Stream as Surface Mesh
A sequence of frames of a surface mesh primitive using a texture created from a raster stream.
Updating Streams

Both the RasterStream and ProjectionStream classes within Insight3D contain an Update method for updating the objects at a specific time. In the following code sample, Update is implemented to provide raster data from the successive frames of an animated GIF, by copying each frame into the Raster from a Bitmap. Since the stream was updated, the method then returns true.

public override bool Update(JulianDate time, JulianDate nextTime)
    Bitmap currentFrame = m_rasterProvider.GetNextFrame();
    return true;
Note Note

When implementing a derived class of RasterStream, the Attributes property should be set in the constructor of the derived class.

Similarly, the Update method is implemented in the following code sample to set the projection data in ProjectionStream dynamically on each animation step:

public override bool Update(JulianDate time, JulianDate nextTime)
    ProjectionProviderData providerData = m_projectionProvider.Evaluate(time);
    Position = providerData.Position;
    Orientation = providerData.Rotation;
    FieldOfViewHorizontal = 0.230908805;
    FieldOfViewVertical = 0.174532925;
    NearPlane = 20.0;
    FarPlane = 10000.0;
    return true;
Raster Stream as Globe Overlay
A sequence of frames of a projected raster using a raster stream and projection stream.

The relationship between the Orientation of a ProjectionStream and a Raster is shown below. In the left image, the orientation axes are shown on a raster, a frame from the video. The X axis is along the horizontal from left to right. The Y axis is along the vertical from bottom to top. The -Z axis is into the raster. In the right image, the orientation axes are drawn over a projection of that raster onto terrain.

Raster Orientation
A frame from a video with the X and Y orientation axes shown. The -Z axis is into the frame.
Projection Stream Orientation
The same frame projected onto terrain with the orientation axes shown.

Updating of raster and projection streams is tied to the current SceneManager time and uses the RasterStreamUpdateDelta and ProjectionStreamUpdateDelta properties to allow a user to control the update rate of the data. These properties are Durations, so an update delta of 0.1 seconds will update 10 times per second while animating. If the update delta is set to 0, the stream's Update method is called every time SceneManagerTime changes. Below, the UpdateDelta property is set to 60 updates per second:

public SatelliteRasterStream()
    UpdateDelta = new Duration(0, 1.0 / 60.0);
    Attributes = m_rasterProvider.Attributes;
Note Note

VideoStream, which derives from RasterStream, can be used within Insight3D for easy reading of video and provides functionality to synchronize a video with the SceneManager time.

Using Streams

Since RasterStream and ProjectionStream derive from Raster and Projection, respectively, they can be passed to any class that accepts those base types. Below, a texture is created from a RasterStream, which is then used to create a Marker Batch Primitive:

RasterStream rasterStream = new SatelliteRasterStream();
Texture2D texture2D = SceneManager.Textures.FromRaster(rasterStream);
Raster Stream as Marker
A sequence of frames of a marker batch primitive using a texture from a raster stream.

You can configure various visual attributes of the ProjectedRaster, such as changing the color and translucency, and also individually controlling the color and translucency of shadows, the frustum, far plane, and footprint border.

Note Note

To enable rendering of shadows, or the projection's frustum or far plane, set the ShowShadows, ShowFrustum, or ShowFarPlane properties to true. To enable a border around the projection's foot print, set the BorderWidth property.

The following example enables rendering of the frustum and far plane, and sets various visual properties:

EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;

ProjectedRaster projectedRaster = new ProjectedRaster(earth)
    ReferenceFrame = earth.FixedFrame,
    Raster = videoStream,
    Projection = projectionStream,
    ShowFrustum = true,
    FrustumColor = Color.Black,
    FrustumTranslucency = 0.5f,
    ShowShadows = true,
    ShadowColor = Color.Orange,
    ShadowTranslucency = 0.5f,
    ShowFarPlane = true,
    Translucency = 0.2f
Raster Stream Show Far Plane
The far plane of the projection when ShowFarPlane is enabled.

See the HowTo for the complete set of RasterStream and ProjectionStream examples shown in this overview.