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.
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 BufferedImage. Since the stream was updated, the method then returns true.
@Override public boolean update(JulianDate time, JulianDate nextTime) { BufferedImage currentFrame = m_rasterProvider.getNextFrame(); copyFromBitmap(currentFrame); return true; }
Note |
---|
When implementing a derived class of RasterStream, the Attributes (get / set) 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:
@Override public boolean update(JulianDate time, JulianDate nextTime) { ProjectionProviderData providerData = m_projectionProvider.evaluate(time); setPosition(providerData.Position); setOrientation(providerData.Rotation); setFieldOfViewHorizontal(0.230908805); setFieldOfViewVertical(0.174532925); setNearPlane(20.0); setFarPlane(10000.0); return true; }
The relationship between the Orientation (get / set) 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.
Updating of raster and projection streams is tied to the current SceneManager time and uses the RasterStream.UpdateDelta (get / set) and ProjectionStream.UpdateDelta (get / set) 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 SceneManager.Time (get / set) changes. Below, the UpdateDelta (get / set) property is set to 60 updates per second:
public SatelliteRasterStream() { setUpdateDelta(new Duration(0, 1.0 / 60.0)); setAttributes(m_rasterProvider.getAttributes()); }
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. |
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.getTextures().fromRaster(rasterStream);
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 |
---|
To enable rendering of shadows, or the projection's frustum or far plane, set the ShowShadows (get / set), ShowFrustum (get / set), or ShowFarPlane (get / set) properties to true. To enable a border around the projection's foot print, set the BorderWidth (get / set) property. |
The following example enables rendering of the frustum and far plane, and sets various visual properties:
EarthCentralBody earth = CentralBodiesFacet.getFromContext().getEarth(); ProjectedRaster projectedRaster = new ProjectedRaster(earth); projectedRaster.setReferenceFrame(earth.getFixedFrame()); projectedRaster.setRaster(videoStream); projectedRaster.setProjection(projectionStream); projectedRaster.setShowFrustum(true); projectedRaster.setFrustumColor(Color.BLACK); projectedRaster.setFrustumTranslucency(0.5f); projectedRaster.setShowShadows(true); Color orange = new Color(0xFFA500); projectedRaster.setShadowColor(orange); projectedRaster.setShadowTranslucency(0.5f); projectedRaster.setShowFarPlane(true); projectedRaster.setTranslucency(0.2f);
See the HowTo for the complete set of RasterStream and ProjectionStream examples shown in this overview.