Video Streams on Models
STK Engine's VideoStream can be utilized by many classes within the library, including COLLADA models. This allows you to stream video to a model's textures. The models are self contained, so you can distribute the models and videos and they can be used in other STK Engine applications. Any image that is used by a COLLADA model for texturing can be replaced with a video. To allow for interoperability with different 3D modeling applications and for models to be self contained and redistributable, a separate ancillary file, corresponding to the COLLADA dae file, is used to provide mapping from the static images within the COLLADA model to the videos that will replace them during rendering in STK Engine. The ancillary file format also supports many options to tweak the playback of the video, and filter attributes to add effects to the video. See below for the complete list of attributes supported by the video_texture element.
|
A COLLADA model using an ancillary file to replace two textures in the model with videos. Since each texture contains a transparent attribute to apply an alpha mask, the mask is also applied to each frame of the video as it would be applied to the static images being replaced. |
The ancillary file allows for your COLLADA models to be edited with any 3D modeling application using placeholder images for textures. When the model is loaded into STK Engine and the ancillary file is present, the references to the placeholder images in the ancillary file are mapped to videos within STK Engine. When the COLLADA model has an ancillary file associated with it, it can be loaded and used like any standard model in STK Engine, as seen below. The actual COLLADA model is never modified.
Currently, RasterStream support for COLLADA model textures is provided through the VideoStream interface, which is a specialization of RasterStream. In the future, programmatic manipulation of model textures and the use of RasterStream classes in the ancillary file will be supported.
The ancillary file should exist in the same directory as the COLLADA model, and have the same name as the COLLADA dae file, but with the "dae" extension replaced with "anc." Below, the ancillary file format is shown via the hellfireflame.anc ancillary file, included in the GraphicsHowTo example, corresponding to the hellfireflame.dae COLLADA model:
[XML] | Copy Code | |
---|---|---|
|
The video_textures section of the ancillary file contains video_texture elements for each image that will be replaced within the COLLADA model, and relevant attributes to associate the image with a video. If we examine the library_images section of the hellfireflame.dae COLLADA model, we see that each video_texture element's image_id attribute in the ancillary file maps to an image element id attribute in the COLLADA model's dae file:
[XML] | Copy Code | |
---|---|---|
|
|
Individual frames of the smoke.avi and flame.mov videos that are mapped to replace placeholder images in the hellfireflame.anc ancillary file. Each placeholder image's alpha mask is shown below each frame of the replacement video. |
When STK Engine's COLLADA loader encounters a texture containing an image that is mapped to a video in the ancillary file, the video is loaded as a RasterStream in the image's place. The video textures also support common COLLADA texturing techniques that typically apply to static images, such as applying alpha masks with a texture sampler through the transparent attribute of the texture. When such a case is encountered, FilteringRasterStream is used to filter each frame of the video to apply the same effect that a static image would have applied. The ancillary file also has support for applying other common filters to the video, to achieve a variety of effects.
Attribute | Requirement | Type | Description |
---|---|---|---|
image_id | Required | string | The id attribute of the image in the COLLADA dae file that will be replaced with the video specified in the init_from attribute. The value of the image_id attribute corresponds to the id attribute value of the image element contained within the library_images section of the COLLADA dae file. |
init_from | Required | string | The filename or Uri of the video that will replace the init_from attribute of the COLLADA image element specified with the image_id attribute. |
video_loop | Optional | boolean | When set to true, enables looping of the video. |
video_framerate | Optional | double | Specifies the framerate of the video. |
video_starttime | Optional | double | The start time of the video in seconds. |
video_endtime | Optional | double | The end time of the video in seconds. |
video_startframe | Optional | long | The start frame of the video. |
video_endframe | Optional | long | The end frame of the video. |
filter_alphafromluminance | Optional | boolean | When set to true, the AlphaFromLuminanceFilter filter will be applied to each frame of the video. |
filter_alphafrompixel | Optional | boolean | When set to true, the AlphaFromPixelFilter filter will be applied to each frame of the video. |