Remote textures – ShiVa Engine

Remote textures

Textures can be streamed directly off the Internet. This works well for JPG and TGA images. DDS, PVR, ETC are supported on GPUs that can handle those compressed file formats. To stay truly cross-platform, we recommend going with JPG and TGA.
Make sure that the whole file is loaded (query cache.getFileStatus until it equals 1) before you use the new image, otherwise you will not see any changes in your scene and the function will silently fail.
This function should run in a loop, preferably in its own state. As soon as the texture is cached, cache.getFileStatus will always return 1, so make sure you exit the loop after the “== 1″ branch has run exactly once. If you use states, switch to another state, and if you do everything in onEnterFrame, use a member control variable and encapsulate the whole preloading code into one if-branch this.bTexturesPreloaded() == false.

--onEnter state: cache texture
if ( cache.getFileStatus  ( "pictureWeb.tga" ) < 0 ) then
    cache.addFile ( "pictureWeb.tga", "" )
--onLoop state: display on model
--note: no extension again
if ( cache.getFileStatus  ( "pictureWeb.tga" ) == 1 ) then
    shape.overrideMeshSubsetMaterialEffectMap0  ( hYourObject, nMaterialSubsetIndex, "pictureWeb", shape.kMapTypeTexture )
    --now leave this loop/state either by entering another state...
    --...or by setting a control variable:

Need more answers?

  • slackBanner