FileDocCategorySizeDatePackage
FileA3D.javaAPI DocAndroid 5.1 API9174Thu Mar 12 22:22:42 GMT 2015android.renderscript

FileA3D

public class FileA3D extends BaseObj
hide
deprecated
in API 16 FileA3D allows users to load RenderScript objects from files or resources stored on disk. It could be used to load items such as 3D geometry data converted to a RenderScript format from content creation tools. Currently only meshes are supported in FileA3D. When successfully loaded, FileA3D will contain a list of index entries for all the objects stored inside it.

Fields Summary
IndexEntry[]
mFileEntries
InputStream
mInputStream
Constructors Summary
FileA3D(long id, RenderScript rs, InputStream stream)

        super(id, rs);
        mInputStream = stream;
    
Methods Summary
public static android.renderscript.FileA3DcreateFromAsset(RenderScript rs, android.content.res.AssetManager mgr, java.lang.String path)

deprecated
in API 16 Creates a FileA3D object from an asset stored on disk
param
rs Context to which the object will belong.
param
mgr asset manager used to load asset
param
path location of the file to load
return
a3d file containing renderscript objects

        rs.validate();
        long fileId = rs.nFileA3DCreateFromAsset(mgr, path);

        if(fileId == 0) {
            throw new RSRuntimeException("Unable to create a3d file from asset " + path);
        }
        FileA3D fa3d = new FileA3D(fileId, rs, null);
        fa3d.initEntries();
        return fa3d;
    
public static android.renderscript.FileA3DcreateFromFile(RenderScript rs, java.lang.String path)

deprecated
in API 16 Creates a FileA3D object from a file stored on disk
param
rs Context to which the object will belong.
param
path location of the file to load
return
a3d file containing renderscript objects

        long fileId = rs.nFileA3DCreateFromFile(path);

        if(fileId == 0) {
            throw new RSRuntimeException("Unable to create a3d file from " + path);
        }
        FileA3D fa3d = new FileA3D(fileId, rs, null);
        fa3d.initEntries();
        return fa3d;
    
public static android.renderscript.FileA3DcreateFromFile(RenderScript rs, java.io.File path)

deprecated
in API 16 Creates a FileA3D object from a file stored on disk
param
rs Context to which the object will belong.
param
path location of the file to load
return
a3d file containing renderscript objects

        return createFromFile(rs, path.getAbsolutePath());
    
public static android.renderscript.FileA3DcreateFromResource(RenderScript rs, android.content.res.Resources res, int id)

deprecated
in API 16 Creates a FileA3D object from an application resource
param
rs Context to which the object will belong.
param
res resource manager used for loading
param
id resource to create FileA3D from
return
a3d file containing renderscript objects


        rs.validate();
        InputStream is = null;
        try {
            is = res.openRawResource(id);
        } catch (Exception e) {
            throw new RSRuntimeException("Unable to open resource " + id);
        }

        long fileId = 0;
        if (is instanceof AssetManager.AssetInputStream) {
            long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
            fileId = rs.nFileA3DCreateFromAssetStream(asset);
        } else {
            throw new RSRuntimeException("Unsupported asset stream");
        }

        if(fileId == 0) {
            throw new RSRuntimeException("Unable to create a3d file from resource " + id);
        }
        FileA3D fa3d = new FileA3D(fileId, rs, is);
        fa3d.initEntries();
        return fa3d;

    
public android.renderscript.FileA3D$IndexEntrygetIndexEntry(int index)

deprecated
in API 16 Returns an index entry from the list of all objects inside FileA3D
param
index number of the entry from the list to return
return
entry in the a3d file described by the index

        if(getIndexEntryCount() == 0 || index < 0 || index >= mFileEntries.length) {
            return null;
        }
        return mFileEntries[index];
    
public intgetIndexEntryCount()

deprecated
in API 16 Returns the number of objects stored inside the a3d file
return
the number of objects stored inside the a3d file

        if(mFileEntries == null) {
            return 0;
        }
        return mFileEntries.length;
    
private voidinitEntries()

        int numFileEntries = mRS.nFileA3DGetNumIndexEntries(getID(mRS));
        if(numFileEntries <= 0) {
            return;
        }

        mFileEntries = new IndexEntry[numFileEntries];
        int[] ids = new int[numFileEntries];
        String[] names = new String[numFileEntries];

        mRS.nFileA3DGetIndexEntries(getID(mRS), numFileEntries, ids, names);

        for(int i = 0; i < numFileEntries; i ++) {
            mFileEntries[i] = new IndexEntry(mRS, i, getID(mRS), names[i], EntryType.toEntryType(ids[i]));
        }