Video Streams on Models |
VideoStream can be used with many classes in Insight3D, 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 Insight3D 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 Insight3D. 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.
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 Insight3D and the ancillary file is present, the references to the placeholder images in the ancillary file are mapped to videos within Insight3D. When the COLLADA model has an ancillary file associated with it, it can be loaded and used like any standard model in Insight3D, as seen below. The actual COLLADA model is never modified.
CentralBody earth = CentralBodiesFacet.getFromContext().getEarth(); ModelPrimitive model = new ModelPrimitive(baseUri.resolve("hellfireflame.dae")); model.setPositionCartographic(earth, new Cartographic(Trig.degreesToRadians(49.88), Trig.degreesToRadians(-77.25), 5000.0)); model.setScale(100.0); SceneManager.getPrimitives().add(model);
Note |
---|
Currently, RasterStream support for COLLADA model textures is provided through the VideoStream interface, which is a derived class. 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 file extension replaced by .anc. Below, the ancillary file format is shown via the hellfireflame.anc ancillary file, included in the HowTo example, corresponding to the hellfireflame.dae COLLADA model:
<?xml version = "1.0" standalone = "yes"?> <ancillary_model_data version = "1.0"> <video_textures> <video_texture image_id = "smoketex_tga" init_from = "smoke.avi" video_loop="true" video_framerate="60" /> <video_texture image_id = "flametex_tga" init_from = "flame.mov" video_loop="true" video_framerate="60" /> </video_textures> </ancillary_model_data>
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:
<library_images> <image id="flametex_tga"> <init_from>flametex.tga</init_from> </image> <image id="flamealpha_tga"> <init_from>flamealpha.tga</init_from> </image> <image id="smokealpha_tga"> <init_from>smokealpha.tga</init_from> </image> <image id="smoketex_tga"> <init_from>smoketex.tga</init_from> </image> </library_images>
When Insight3D'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 | |
video_framerate | Optional | double | |
video_starttime | Optional | double | |
video_endtime | Optional | double | |
video_startframe | Optional | long | |
video_endframe | Optional | long | |
filter_alphafromluminance | Optional | boolean | When set to true, a AlphaFromLuminanceFilter will be applied to each frame of the video. |
filter_alphafrompixel | Optional | boolean | When set to true, a AlphaFromPixelFilter will be applied to each frame of the video. |