The RasterStreamand ProjectionStreamclasses allow for implementers to stream new data to a Rasterand Projectionover time. Since they implement Raster and Projection respectively, they can be passed to any class that accepts 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 MarkerBatchand SurfaceMeshprimitives. Similarly, the ProjectedRasterOverlayglobe overlay, which projects an image onto the ellipsoid or terrain, can be used with a RasterStream and ProjectionStream to display video while transforming how it is projected.
|
|
|
Subsequent time steps of a SurfaceMeshprimitive using a texture created from a RasterStream. |
Both the RasterStream and ProjectionStream classes within Insight3D contain an Updatemethod for updating the objects at a specific time. Below, RasterStream.Updateis 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 returns true:
public override bool Update(JulianDate Time, JulianDate NextTime) { Bitmap currentFrame = m_RasterProvider.GetNextFrame(); CopyFromBitmap(currentFrame); return true; }
Similarly, the ProjectionStream.Updatemethod is implemented below to set the projection data in ProjectionStreamdynamically 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 = 174532925; NearPlane = 20.0; FarPlane = 10000.0; return true; }
|
|
|
Subsequent animation steps of a ProjectedRasterOverlayglobe overlay using a RasterStream and ProjectionStream. |
The relationship between the Orientationof a ProjectionStreamand 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.
|
|
|
|
A frame from a video with the x and y orientation axes shown. The -z axis is into the frame. |
The same frame projected onto terrain with the orientation axes shown. |
Updating of raster and projection streams is tied to the current SceneManagertime and uses the UpdateDeltaproperty of RasterStream and ProjectionStream to allow a user to control the update rate of the data. The UpdateDeltais a Duration, so an UpdateDeltaof .1 seconds will update 10 times per second while animating. If the UpdateDeltais set to 0, the stream's Updatemethod is called every time the SceneManager's time changes. Below, the UpdateDeltaproperty is set to 60 updates per second:
public SatelliteRasterStream() { UpdateDelta = new Duration( 0, 0.01667); }
Since RasterStream and ProjectionStream implement 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:
AGI.Foundation.Graphics.Imaging.RasterStream rasterStream =
new SatelliteRasterStream();
Texture2D texture2D =
SceneManager.Textures.FromRaster(rasterStream);
|
|
|
Subsequent time steps of a MarkerBatchprimitive using a texture from a RasterStream. |
See the HowTofor the complete set of RasterStream and ProjectionStream examples shown in this overview.