idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
148,500
protected boolean computeOffset ( CacheDataSet cache ) { // offset computation: update offset for all items in the cache float startDataOffset = getStartingOffset ( ( cache . getTotalSizeWithPadding ( ) ) ) ; float layoutOffset = getLayoutOffset ( ) ; boolean inBounds = startDataOffset < - layoutOffset ; for ( int pos = 0 ; pos < cache . count ( ) ; ++ pos ) { int id = cache . getId ( pos ) ; if ( id != - 1 ) { float endDataOffset = cache . setDataAfter ( id , startDataOffset ) ; inBounds = inBounds && endDataOffset > layoutOffset && startDataOffset < - layoutOffset ; startDataOffset = endDataOffset ; Log . d ( LAYOUT , TAG , "computeOffset [%d] = %f" , id , cache . getDataOffset ( id ) ) ; } } return inBounds ; }
Compute the offset for the item in the layout based on the offsets of neighbors in the layout . The other offsets are not patched . If neighbors offsets have not been computed the offset of the item will not be set .
199
44
148,501
protected float computeUniformPadding ( final CacheDataSet cache ) { float axisSize = getViewPortSize ( getOrientationAxis ( ) ) ; float totalPadding = axisSize - cache . getTotalSize ( ) ; float uniformPadding = totalPadding > 0 && cache . count ( ) > 1 ? totalPadding / ( cache . count ( ) - 1 ) : 0 ; return uniformPadding ; }
Compute the proportional padding for all items in the cache
91
11
148,502
public String [ ] getString ( ) { String [ ] valueDestination = new String [ string . size ( ) ] ; this . string . getValue ( valueDestination ) ; return valueDestination ; }
Provide array of String results from inputOutput MFString field named string .
44
15
148,503
public void setString ( String [ ] newValue ) { if ( newValue != null ) { this . string . setValue ( newValue . length , newValue ) ; } }
Assign float value within allowed range of [ 0 infinity ) to initializeOnly SFFloat field named spacing .
38
23
148,504
public int findAnimation ( GVRAnimation findme ) { int index = 0 ; for ( GVRAnimation anim : mAnimations ) { if ( anim == findme ) { return index ; } ++ index ; } return - 1 ; }
Find the index of this animation if it is in this animator .
50
14
148,505
public void setDuration ( float start , float end ) { for ( GVRAnimation anim : mAnimations ) { anim . setDuration ( start , end ) ; } }
Sets the duration for the animations in this animator .
36
12
148,506
public static void init ( Context cx , Scriptable scope , boolean sealed ) throws RhinoException { JSAdapter obj = new JSAdapter ( cx . newObject ( scope ) ) ; obj . setParentScope ( scope ) ; obj . setPrototype ( getFunctionPrototype ( scope ) ) ; obj . isPrototype = true ; ScriptableObject . defineProperty ( scope , "JSAdapter" , obj , ScriptableObject . DONTENUM ) ; }
initializer to setup JSAdapter prototype in the given scope
95
11
148,507
private Object mapToId ( Object tmp ) { if ( tmp instanceof Double ) { return new Integer ( ( ( Double ) tmp ) . intValue ( ) ) ; } else { return Context . toString ( tmp ) ; } }
map a property id . Property id can only be an Integer or String
49
14
148,508
public void setList ( List < T > list ) { if ( list != mList ) { mList = list ; if ( mList == null ) { notifyInvalidated ( ) ; } else { notifyChanged ( ) ; } } }
Set new list data set
50
5
148,509
public void register ( ) { synchronized ( loaders ) { loaders . add ( this ) ; maximumHeaderLength = 0 ; for ( GVRCompressedTextureLoader loader : loaders ) { int headerLength = loader . headerLength ( ) ; if ( headerLength > maximumHeaderLength ) { maximumHeaderLength = headerLength ; } } } }
Register a loader with the sniffer .
72
8
148,510
public static GVRSceneObject loadModel ( final GVRContext gvrContext , final String modelFile ) throws IOException { return loadModel ( gvrContext , modelFile , new HashMap < String , Integer > ( ) ) ; }
Load model from file
50
4
148,511
public int getFaceNumIndices ( int face ) { if ( null == m_faceOffsets ) { if ( face >= m_numFaces || face < 0 ) { throw new IndexOutOfBoundsException ( "Index: " + face + ", Size: " + m_numFaces ) ; } return 3 ; } else { /* * no need to perform bound checks here as the array access will * throw IndexOutOfBoundsExceptions if the index is invalid */ if ( face == m_numFaces - 1 ) { return m_faces . capacity ( ) / 4 - m_faceOffsets . getInt ( face * 4 ) ; } return m_faceOffsets . getInt ( ( face + 1 ) * 4 ) - m_faceOffsets . getInt ( face * 4 ) ; } }
Returns the number of vertex indices for a single face .
176
11
148,512
public float getPositionX ( int vertex ) { if ( ! hasPositions ( ) ) { throw new IllegalStateException ( "mesh has no positions" ) ; } checkVertexIndexBounds ( vertex ) ; return m_vertices . getFloat ( vertex * 3 * SIZEOF_FLOAT ) ; }
Returns the x - coordinate of a vertex position .
70
10
148,513
public float getPositionY ( int vertex ) { if ( ! hasPositions ( ) ) { throw new IllegalStateException ( "mesh has no positions" ) ; } checkVertexIndexBounds ( vertex ) ; return m_vertices . getFloat ( ( vertex * 3 + 1 ) * SIZEOF_FLOAT ) ; }
Returns the y - coordinate of a vertex position .
74
10
148,514
public float getPositionZ ( int vertex ) { if ( ! hasPositions ( ) ) { throw new IllegalStateException ( "mesh has no positions" ) ; } checkVertexIndexBounds ( vertex ) ; return m_vertices . getFloat ( ( vertex * 3 + 2 ) * SIZEOF_FLOAT ) ; }
Returns the z - coordinate of a vertex position .
74
10
148,515
public float getNormalX ( int vertex ) { if ( ! hasNormals ( ) ) { throw new IllegalStateException ( "mesh has no normals" ) ; } checkVertexIndexBounds ( vertex ) ; return m_normals . getFloat ( vertex * 3 * SIZEOF_FLOAT ) ; }
Returns the x - coordinate of a vertex normal .
71
10
148,516
public float getNormalY ( int vertex ) { if ( ! hasNormals ( ) ) { throw new IllegalStateException ( "mesh has no normals" ) ; } checkVertexIndexBounds ( vertex ) ; return m_normals . getFloat ( ( vertex * 3 + 1 ) * SIZEOF_FLOAT ) ; }
Returns the y - coordinate of a vertex normal .
75
10
148,517
public float getNormalZ ( int vertex ) { if ( ! hasNormals ( ) ) { throw new IllegalStateException ( "mesh has no normals" ) ; } checkVertexIndexBounds ( vertex ) ; return m_normals . getFloat ( ( vertex * 3 + 2 ) * SIZEOF_FLOAT ) ; }
Returns the z - coordinate of a vertex normal .
75
10
148,518
public float getTangentY ( int vertex ) { if ( ! hasTangentsAndBitangents ( ) ) { throw new IllegalStateException ( "mesh has no bitangents" ) ; } checkVertexIndexBounds ( vertex ) ; return m_tangents . getFloat ( ( vertex * 3 + 1 ) * SIZEOF_FLOAT ) ; }
Returns the y - coordinate of a vertex bitangent .
82
12
148,519
public float getBitangentY ( int vertex ) { if ( ! hasTangentsAndBitangents ( ) ) { throw new IllegalStateException ( "mesh has no bitangents" ) ; } checkVertexIndexBounds ( vertex ) ; return m_bitangents . getFloat ( ( vertex * 3 + 1 ) * SIZEOF_FLOAT ) ; }
Returns the y - coordinate of a vertex tangent .
83
11
148,520
public float getColorR ( int vertex , int colorset ) { if ( ! hasColors ( colorset ) ) { throw new IllegalStateException ( "mesh has no colorset " + colorset ) ; } checkVertexIndexBounds ( vertex ) ; /* bound checks for colorset are done by java for us */ return m_colorsets [ colorset ] . getFloat ( vertex * 4 * SIZEOF_FLOAT ) ; }
Returns the red color component of a color from a vertex color set .
98
14
148,521
public float getTexCoordU ( int vertex , int coords ) { if ( ! hasTexCoords ( coords ) ) { throw new IllegalStateException ( "mesh has no texture coordinate set " + coords ) ; } checkVertexIndexBounds ( vertex ) ; /* bound checks for coords are done by java for us */ return m_texcoords [ coords ] . getFloat ( vertex * m_numUVComponents [ coords ] * SIZEOF_FLOAT ) ; }
Returns the u component of a coordinate from a texture coordinate set .
111
13
148,522
@ SuppressWarnings ( "WeakerAccess" ) public String getProperty ( Enum < ? > key , boolean lowerCase ) { final String keyName ; if ( lowerCase ) { keyName = key . name ( ) . toLowerCase ( Locale . ENGLISH ) ; } else { keyName = key . name ( ) ; } return getProperty ( keyName ) ; }
Gets the property by key converted to lowercase if requested
84
12
148,523
public JSONObject toJSON ( ) { try { return new JSONObject ( properties ) . putOpt ( "name" , getName ( ) ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; Log . e ( TAG , e , "toJSON()" ) ; throw new RuntimeAssertion ( "NodeEntry.toJSON() failed for '%s'" , this ) ; } }
Converts the node to JSON
89
6
148,524
@ Override public void onRotationSensor ( long timeStamp , float rotationW , float rotationX , float rotationY , float rotationZ , float gyroX , float gyroY , float gyroZ ) { GVRCameraRig cameraRig = null ; if ( mMainScene != null ) { cameraRig = mMainScene . getMainCameraRig ( ) ; } if ( cameraRig != null ) { cameraRig . setRotationSensorData ( timeStamp , rotationW , rotationX , rotationY , rotationZ , gyroX , gyroY , gyroZ ) ; updateSensoredScene ( ) ; } }
Called to reset current sensor data .
143
8
148,525
protected synchronized void setStream ( InputStream s ) { if ( stream != null ) { throw new UnsupportedOperationException ( "Cannot set the stream of an open resource" ) ; } stream = s ; streamState = StreamStates . OPEN ; }
Sets the stream for a resource . This function allows you to provide a stream that is already open to an existing resource . It will throw an exception if that resource already has an open stream .
52
39
148,526
public synchronized final void closeStream ( ) { try { if ( ( stream != null ) && ( streamState == StreamStates . OPEN ) ) { stream . close ( ) ; stream = null ; } streamState = StreamStates . CLOSED ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Close the open stream .
69
5
148,527
public String getResourcePath ( ) { switch ( resourceType ) { case ANDROID_ASSETS : return assetPath ; case ANDROID_RESOURCE : return resourceFilePath ; case LINUX_FILESYSTEM : return filePath ; case NETWORK : return url . getPath ( ) ; case INPUT_STREAM : return inputStreamName ; default : return null ; } }
Returns the full path of the resource file with extension .
82
11
148,528
public String getResourceFilename ( ) { switch ( resourceType ) { case ANDROID_ASSETS : return assetPath . substring ( assetPath . lastIndexOf ( File . separator ) + 1 ) ; case ANDROID_RESOURCE : return resourceFilePath . substring ( resourceFilePath . lastIndexOf ( File . separator ) + 1 ) ; case LINUX_FILESYSTEM : return filePath . substring ( filePath . lastIndexOf ( File . separator ) + 1 ) ; case NETWORK : return url . getPath ( ) . substring ( url . getPath ( ) . lastIndexOf ( "/" ) + 1 ) ; case INPUT_STREAM : return inputStreamName ; default : return null ; } }
Returns the filename of the resource with extension .
161
9
148,529
public void loadModel ( GVRAndroidResource avatarResource ) { EnumSet < GVRImportSettings > settings = GVRImportSettings . getRecommendedSettingsWith ( EnumSet . of ( GVRImportSettings . OPTIMIZE_GRAPH , GVRImportSettings . NO_ANIMATION ) ) ; GVRContext ctx = mAvatarRoot . getGVRContext ( ) ; GVRResourceVolume volume = new GVRResourceVolume ( ctx , avatarResource ) ; GVRSceneObject modelRoot = new GVRSceneObject ( ctx ) ; mAvatarRoot . addChildObject ( modelRoot ) ; ctx . getAssetLoader ( ) . loadModel ( volume , modelRoot , settings , false , mLoadModelHandler ) ; }
Load the avatar base model
160
5
148,530
public void loadModel ( GVRAndroidResource avatarResource , String attachBone ) { EnumSet < GVRImportSettings > settings = GVRImportSettings . getRecommendedSettingsWith ( EnumSet . of ( GVRImportSettings . OPTIMIZE_GRAPH , GVRImportSettings . NO_ANIMATION ) ) ; GVRContext ctx = mAvatarRoot . getGVRContext ( ) ; GVRResourceVolume volume = new GVRResourceVolume ( ctx , avatarResource ) ; GVRSceneObject modelRoot = new GVRSceneObject ( ctx ) ; GVRSceneObject boneObject ; int boneIndex ; if ( mSkeleton == null ) { throw new IllegalArgumentException ( "Cannot attach model to avatar - there is no skeleton" ) ; } boneIndex = mSkeleton . getBoneIndex ( attachBone ) ; if ( boneIndex < 0 ) { throw new IllegalArgumentException ( attachBone + " is not a bone in the avatar skeleton" ) ; } boneObject = mSkeleton . getBone ( boneIndex ) ; if ( boneObject == null ) { throw new IllegalArgumentException ( attachBone + " does not have a bone object in the avatar skeleton" ) ; } boneObject . addChildObject ( modelRoot ) ; ctx . getAssetLoader ( ) . loadModel ( volume , modelRoot , settings , false , mLoadModelHandler ) ; }
Load a model to attach to the avatar
298
8
148,531
public void loadAnimation ( GVRAndroidResource animResource , String boneMap ) { String filePath = animResource . getResourcePath ( ) ; GVRContext ctx = mAvatarRoot . getGVRContext ( ) ; GVRResourceVolume volume = new GVRResourceVolume ( ctx , animResource ) ; if ( filePath . endsWith ( ".bvh" ) ) { GVRAnimator animator = new GVRAnimator ( ctx ) ; animator . setName ( filePath ) ; try { BVHImporter importer = new BVHImporter ( ctx ) ; GVRSkeletonAnimation skelAnim ; if ( boneMap != null ) { GVRSkeleton skel = importer . importSkeleton ( animResource ) ; skelAnim = importer . readMotion ( skel ) ; animator . addAnimation ( skelAnim ) ; GVRPoseMapper retargeter = new GVRPoseMapper ( mSkeleton , skel , skelAnim . getDuration ( ) ) ; retargeter . setBoneMap ( boneMap ) ; animator . addAnimation ( retargeter ) ; } else { skelAnim = importer . importAnimation ( animResource , mSkeleton ) ; animator . addAnimation ( skelAnim ) ; } addAnimation ( animator ) ; ctx . getEventManager ( ) . sendEvent ( this , IAvatarEvents . class , "onAnimationLoaded" , GVRAvatar . this , animator , filePath , null ) ; } catch ( IOException ex ) { ctx . getEventManager ( ) . sendEvent ( this , IAvatarEvents . class , "onAnimationLoaded" , GVRAvatar . this , null , filePath , ex . getMessage ( ) ) ; } } else { EnumSet < GVRImportSettings > settings = GVRImportSettings . getRecommendedSettingsWith ( EnumSet . of ( GVRImportSettings . OPTIMIZE_GRAPH , GVRImportSettings . NO_TEXTURING ) ) ; GVRSceneObject animRoot = new GVRSceneObject ( ctx ) ; ctx . getAssetLoader ( ) . loadModel ( volume , animRoot , settings , false , mLoadAnimHandler ) ; } }
Load an animation for the current avatar .
493
8
148,532
public void start ( String name ) { GVRAnimator anim = findAnimation ( name ) ; if ( name . equals ( anim . getName ( ) ) ) { start ( anim ) ; return ; } }
Starts the named animation .
44
6
148,533
public GVRAnimator findAnimation ( String name ) { for ( GVRAnimator anim : mAnimations ) { if ( name . equals ( anim . getName ( ) ) ) { return anim ; } } return null ; }
Find the animation associated with this avatar with the given name .
49
12
148,534
public GVRAnimator start ( int animIndex ) { if ( ( animIndex < 0 ) || ( animIndex >= mAnimations . size ( ) ) ) { throw new IndexOutOfBoundsException ( "Animation index out of bounds" ) ; } GVRAnimator anim = mAnimations . get ( animIndex ) ; start ( anim ) ; return anim ; }
Starts the animation with the given index .
79
9
148,535
public GVRAnimator animate ( int animIndex , float timeInSec ) { if ( ( animIndex < 0 ) || ( animIndex >= mAnimations . size ( ) ) ) { throw new IndexOutOfBoundsException ( "Animation index out of bounds" ) ; } GVRAnimator anim = mAnimations . get ( animIndex ) ; anim . animate ( timeInSec ) ; return anim ; }
Evaluates the animation with the given index at the specified time .
88
14
148,536
public void stop ( ) { synchronized ( mAnimQueue ) { if ( mIsRunning && ( mAnimQueue . size ( ) > 0 ) ) { mIsRunning = false ; GVRAnimator animator = mAnimQueue . get ( 0 ) ; mAnimQueue . clear ( ) ; animator . stop ( ) ; } } }
Stops the currently running animation if any .
72
9
148,537
public GVRTexture getSplashTexture ( GVRContext gvrContext ) { Bitmap bitmap = BitmapFactory . decodeResource ( // gvrContext . getContext ( ) . getResources ( ) , // R . drawable . __default_splash_screen__ ) ; GVRTexture tex = new GVRTexture ( gvrContext ) ; tex . setImage ( new GVRBitmapImage ( gvrContext , bitmap ) ) ; return tex ; }
Override this method to supply a custom splash screen image .
100
11
148,538
public void onSplashScreenCreated ( GVRSceneObject splashScreen ) { GVRTransform transform = splashScreen . getTransform ( ) ; transform . setPosition ( 0 , 0 , DEFAULT_SPLASH_Z ) ; }
Override this method to change the default splash screen size or position .
49
13
148,539
public void setPosition ( float x , float y , float z ) { if ( isActive ( ) ) { mIODevice . setPosition ( x , y , z ) ; } }
Set a new Cursor position if active and enabled .
41
11
148,540
void close ( ) { mIODevice = null ; GVRSceneObject owner = getOwnerObject ( ) ; if ( owner . getParent ( ) != null ) { owner . getParent ( ) . removeChildObject ( owner ) ; } }
Perform all Cursor cleanup here .
53
8
148,541
public GVRMesh findMesh ( GVRSceneObject model ) { class MeshFinder implements GVRSceneObject . ComponentVisitor { private GVRMesh meshFound = null ; public GVRMesh getMesh ( ) { return meshFound ; } public boolean visit ( GVRComponent comp ) { GVRRenderData rdata = ( GVRRenderData ) comp ; meshFound = rdata . getMesh ( ) ; return ( meshFound == null ) ; } } ; MeshFinder findMesh = new MeshFinder ( ) ; model . forAllComponents ( findMesh , GVRRenderData . getComponentType ( ) ) ; return findMesh . getMesh ( ) ; }
Finds the first mesh in the given model .
143
10
148,542
@ Override public boolean invokeFunction ( String funcName , Object [ ] params ) { // Run script if it is dirty. This makes sure the script is run // on the same thread as the caller (suppose the caller is always // calling from the same thread). checkDirty ( ) ; // Skip bad functions if ( isBadFunction ( funcName ) ) { return false ; } String statement = getInvokeStatementCached ( funcName , params ) ; synchronized ( mEngineLock ) { localBindings = mLocalEngine . getBindings ( ScriptContext . ENGINE_SCOPE ) ; if ( localBindings == null ) { localBindings = mLocalEngine . createBindings ( ) ; mLocalEngine . setBindings ( localBindings , ScriptContext . ENGINE_SCOPE ) ; } } fillBindings ( localBindings , params ) ; try { mLocalEngine . eval ( statement ) ; } catch ( ScriptException e ) { // The function is either undefined or throws, avoid invoking it later addBadFunction ( funcName ) ; mLastError = e . getMessage ( ) ; return false ; } finally { removeBindings ( localBindings , params ) ; } return true ; }
Invokes a function defined in the script .
256
9
148,543
private boolean isInInnerCircle ( float x , float y ) { return GearWearableUtility . isInCircle ( x , y , CENTER_X , CENTER_Y , INNER_RADIUS ) ; }
Check if position is in inner circle
52
7
148,544
@ SuppressWarnings ( "unchecked" ) public < V3 , M4 , C , N , Q > V3 getUp ( AiWrapperProvider < V3 , M4 , C , N , Q > wrapperProvider ) { return ( V3 ) m_up ; }
Returns the Up - vector of the camera coordinate system .
62
11
148,545
public void dispatchKeyEvent ( int code , int action ) { int keyCode = 0 ; int keyAction = 0 ; if ( code == BUTTON_1 ) { keyCode = KeyEvent . KEYCODE_BUTTON_1 ; } else if ( code == BUTTON_2 ) { keyCode = KeyEvent . KEYCODE_BUTTON_2 ; } if ( action == ACTION_DOWN ) { keyAction = KeyEvent . ACTION_DOWN ; } else if ( action == ACTION_UP ) { keyAction = KeyEvent . ACTION_UP ; } KeyEvent keyEvent = new KeyEvent ( keyAction , keyCode ) ; setKeyEvent ( keyEvent ) ; }
Synthesize and forward a KeyEvent to the library .
144
13
148,546
void setState ( final WidgetState . State state ) { Log . d ( TAG , "setState(%s): state is %s, setting to %s" , mWidget . getName ( ) , mState , state ) ; if ( state != mState ) { final WidgetState . State nextState = getNextState ( state ) ; Log . d ( TAG , "setState(%s): next state '%s'" , mWidget . getName ( ) , nextState ) ; if ( nextState != mState ) { Log . d ( TAG , "setState(%s): setting state to '%s'" , mWidget . getName ( ) , nextState ) ; setCurrentState ( false ) ; mState = nextState ; setCurrentState ( true ) ; } } }
Sets current state
172
4
148,547
public void setEnable ( boolean flag ) { if ( mEnabled == flag ) { return ; } mEnabled = flag ; if ( flag ) { mContext . registerDrawFrameListener ( this ) ; mContext . getApplication ( ) . getEventReceiver ( ) . addListener ( this ) ; mAudioEngine . resume ( ) ; } else { mContext . unregisterDrawFrameListener ( this ) ; mContext . getApplication ( ) . getEventReceiver ( ) . removeListener ( this ) ; mAudioEngine . pause ( ) ; } }
Enables or disables sound . When sound is disabled nothing is played but the audio sources remain intact .
116
21
148,548
public void addSource ( GVRAudioSource audioSource ) { synchronized ( mAudioSources ) { if ( ! mAudioSources . contains ( audioSource ) ) { audioSource . setListener ( this ) ; mAudioSources . add ( audioSource ) ; } } }
Adds an audio source to the audio manager . An audio source cannot be played unless it is added to the audio manager . A source cannot be added twice .
58
31
148,549
public void removeSource ( GVRAudioSource audioSource ) { synchronized ( mAudioSources ) { audioSource . setListener ( null ) ; mAudioSources . remove ( audioSource ) ; } }
Removes an audio source from the audio manager .
43
10
148,550
public void clearSources ( ) { synchronized ( mAudioSources ) { for ( GVRAudioSource source : mAudioSources ) { source . setListener ( null ) ; } mAudioSources . clear ( ) ; } }
Remove all of the audio sources from the audio manager . This will stop all sound from playing .
48
19
148,551
private float [ ] generateParticleTimeStamps ( float totalTime ) { float timeStamps [ ] = new float [ mEmitRate * 2 ] ; if ( burstMode ) { for ( int i = 0 ; i < mEmitRate * 2 ; i += 2 ) { timeStamps [ i ] = totalTime ; timeStamps [ i + 1 ] = 0 ; } } else { for ( int i = 0 ; i < mEmitRate * 2 ; i += 2 ) { timeStamps [ i ] = totalTime + mRandom . nextFloat ( ) ; timeStamps [ i + 1 ] = 0 ; } } return timeStamps ; }
Generate random time stamps from the current time upto the next one second . Passed as texture coordinates to the vertex shader ; an unused field is present with every pair passed .
144
35
148,552
private float [ ] generateParticleVelocities ( ) { float [ ] particleVelocities = new float [ mEmitRate * 3 ] ; Vector3f temp = new Vector3f ( 0 , 0 , 0 ) ; for ( int i = 0 ; i < mEmitRate * 3 ; i += 3 ) { temp . x = mParticlePositions [ i ] ; temp . y = mParticlePositions [ i + 1 ] ; temp . z = mParticlePositions [ i + 2 ] ; float velx = mRandom . nextFloat ( ) * ( maxVelocity . x - minVelocity . x ) + minVelocity . x ; float vely = mRandom . nextFloat ( ) * ( maxVelocity . y - minVelocity . y ) + minVelocity . y ; float velz = mRandom . nextFloat ( ) * ( maxVelocity . z - minVelocity . z ) + minVelocity . z ; temp = temp . normalize ( ) ; temp . mul ( velx , vely , velz , temp ) ; particleVelocities [ i ] = temp . x ; particleVelocities [ i + 1 ] = temp . y ; particleVelocities [ i + 2 ] = temp . z ; } return particleVelocities ; }
Generate random velocities for every particle . The direction is obtained by assuming the position of a particle as a vector . This normalised vector is scaled by the speed range .
282
36
148,553
public static void launchPermissionSettings ( Activity activity ) { Intent intent = new Intent ( ) ; intent . setAction ( Settings . ACTION_APPLICATION_DETAILS_SETTINGS ) ; intent . setData ( Uri . fromParts ( "package" , activity . getPackageName ( ) , null ) ) ; activity . startActivity ( intent ) ; }
Launch Application Setting to grant permission .
77
7
148,554
public void setFromJSON ( Context context , JSONObject properties ) { String backgroundResStr = optString ( properties , Properties . background ) ; if ( backgroundResStr != null && ! backgroundResStr . isEmpty ( ) ) { final int backgroundResId = getId ( context , backgroundResStr , "drawable" ) ; setBackGround ( context . getResources ( ) . getDrawable ( backgroundResId , null ) ) ; } setBackgroundColor ( getJSONColor ( properties , Properties . background_color , getBackgroundColor ( ) ) ) ; setGravity ( optInt ( properties , TextContainer . Properties . gravity , getGravity ( ) ) ) ; setRefreshFrequency ( optEnum ( properties , Properties . refresh_freq , getRefreshFrequency ( ) ) ) ; setTextColor ( getJSONColor ( properties , Properties . text_color , getTextColor ( ) ) ) ; setText ( optString ( properties , Properties . text , ( String ) getText ( ) ) ) ; setTextSize ( optFloat ( properties , Properties . text_size , getTextSize ( ) ) ) ; final JSONObject typefaceJson = optJSONObject ( properties , Properties . typeface ) ; if ( typefaceJson != null ) { try { Typeface typeface = WidgetLib . getTypefaceManager ( ) . getTypeface ( typefaceJson ) ; setTypeface ( typeface ) ; } catch ( Throwable e ) { Log . e ( TAG , e , "Couldn't set typeface from properties: %s" , typefaceJson ) ; } } }
Set text parameters from properties
342
5
148,555
public void onLayoutApplied ( final WidgetContainer container , final Vector3Axis viewPortSize ) { mContainer = container ; mViewPort . setSize ( viewPortSize ) ; if ( mContainer != null ) { mContainer . onLayoutChanged ( this ) ; } }
Called when the layout is applied to the data
60
10
148,556
public void invalidate ( ) { synchronized ( mMeasuredChildren ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "invalidate all [%d]" , mMeasuredChildren . size ( ) ) ; mMeasuredChildren . clear ( ) ; } }
Invalidate layout setup .
63
5
148,557
public void invalidate ( final int dataIndex ) { synchronized ( mMeasuredChildren ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "invalidate [%d]" , dataIndex ) ; mMeasuredChildren . remove ( dataIndex ) ; } }
Invalidate the item in layout
62
6
148,558
public float getChildSize ( final int dataIndex , final Axis axis ) { float size = 0 ; Widget child = mContainer . get ( dataIndex ) ; if ( child != null ) { switch ( axis ) { case X : size = child . getLayoutWidth ( ) ; break ; case Y : size = child . getLayoutHeight ( ) ; break ; case Z : size = child . getLayoutDepth ( ) ; break ; default : throw new RuntimeAssertion ( "Bad axis specified: %s" , axis ) ; } } return size ; }
Calculate the child size along the axis
118
9
148,559
public float getSize ( final Axis axis ) { float size = 0 ; if ( mViewPort != null && mViewPort . isClippingEnabled ( axis ) ) { size = mViewPort . get ( axis ) ; } else if ( mContainer != null ) { size = getSizeImpl ( axis ) ; } return size ; }
Calculate the layout container size along the axis
71
10
148,560
public void setDividerPadding ( float padding , final Axis axis ) { if ( ! equal ( mDividerPadding . get ( axis ) , padding ) ) { mDividerPadding . set ( padding , axis ) ; if ( mContainer != null ) { mContainer . onLayoutChanged ( this ) ; } } }
Set the amount of padding between child objects .
70
9
148,561
public void setOffset ( float offset , final Axis axis ) { if ( ! equal ( mOffset . get ( axis ) , offset ) ) { mOffset . set ( offset , axis ) ; if ( mContainer != null ) { mContainer . onLayoutChanged ( this ) ; } } }
Set the amount of offset between child objects and parent .
61
11
148,562
public synchronized Widget measureChild ( final int dataIndex , boolean calculateOffset ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "measureChild dataIndex = %d" , dataIndex ) ; Widget widget = mContainer . get ( dataIndex ) ; if ( widget != null ) { synchronized ( mMeasuredChildren ) { mMeasuredChildren . add ( dataIndex ) ; } } return widget ; }
Calculate the child size along the axis and measure the offset inside the layout container
94
17
148,563
public boolean measureAll ( List < Widget > measuredChildren ) { boolean changed = false ; for ( int i = 0 ; i < mContainer . size ( ) ; ++ i ) { if ( ! isChildMeasured ( i ) ) { Widget child = measureChild ( i , false ) ; if ( child != null ) { if ( measuredChildren != null ) { measuredChildren . add ( child ) ; } changed = true ; } } } if ( changed ) { postMeasurement ( ) ; } return changed ; }
Measure all children from container if needed
110
7
148,564
public void layoutChildren ( ) { Set < Integer > copySet ; synchronized ( mMeasuredChildren ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "layoutChildren [%d] layout = %s" , mMeasuredChildren . size ( ) , this ) ; copySet = new HashSet <> ( mMeasuredChildren ) ; } for ( int nextMeasured : copySet ) { Widget child = mContainer . get ( nextMeasured ) ; if ( child != null ) { child . preventTransformChanged ( true ) ; layoutChild ( nextMeasured ) ; postLayoutChild ( nextMeasured ) ; child . preventTransformChanged ( false ) ; } } }
Layout children inside the layout container
150
6
148,565
protected float getViewPortSize ( final Axis axis ) { float size = mViewPort == null ? 0 : mViewPort . get ( axis ) ; Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "getViewPortSize for %s %f mViewPort = %s" , axis , size , mViewPort ) ; return size ; }
Get viewport size along the axis
80
7
148,566
protected void layoutChild ( final int dataIndex ) { Widget child = mContainer . get ( dataIndex ) ; if ( child != null ) { float offset = mOffset . get ( Axis . X ) ; if ( ! equal ( offset , 0 ) ) { updateTransform ( child , Axis . X , offset ) ; } offset = mOffset . get ( Axis . Y ) ; if ( ! equal ( offset , 0 ) ) { updateTransform ( child , Axis . Y , offset ) ; } offset = mOffset . get ( Axis . Z ) ; if ( ! equal ( offset , 0 ) ) { updateTransform ( child , Axis . Z , offset ) ; } } }
Position the child inside the layout based on the offset and axis - s factors
142
15
148,567
protected void postLayoutChild ( final int dataIndex ) { if ( ! mContainer . isDynamic ( ) ) { boolean visibleInLayout = ! mViewPort . isClippingEnabled ( ) || inViewPort ( dataIndex ) ; ViewPortVisibility visibility = visibleInLayout ? ViewPortVisibility . FULLY_VISIBLE : ViewPortVisibility . INVISIBLE ; Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "onLayout: child with dataId [%d] viewportVisibility = %s" , dataIndex , visibility ) ; Widget childWidget = mContainer . get ( dataIndex ) ; if ( childWidget != null ) { childWidget . setViewPortVisibility ( visibility ) ; } } }
Do post exam of child inside the layout after it has been positioned in parent
160
15
148,568
static GVRCollider lookup ( long nativePointer ) { synchronized ( sColliders ) { WeakReference < GVRCollider > weakReference = sColliders . get ( nativePointer ) ; return weakReference == null ? null : weakReference . get ( ) ; } }
Lookup a native pointer to a collider and return its Java object .
61
15
148,569
private void createSimpleCubeSixMeshes ( GVRContext gvrContext , boolean facingOut , String vertexDesc , ArrayList < GVRTexture > textureList ) { GVRSceneObject [ ] children = new GVRSceneObject [ 6 ] ; GVRMesh [ ] meshes = new GVRMesh [ 6 ] ; GVRVertexBuffer vbuf = new GVRVertexBuffer ( gvrContext , vertexDesc , SIMPLE_VERTICES . length / 3 ) ; if ( facingOut ) { vbuf . setFloatArray ( "a_position" , SIMPLE_VERTICES , 3 , 0 ) ; vbuf . setFloatArray ( "a_normal" , SIMPLE_OUTWARD_NORMALS , 3 , 0 ) ; vbuf . setFloatArray ( "a_texcoord" , SIMPLE_OUTWARD_TEXCOORDS , 2 , 0 ) ; meshes [ 0 ] = createMesh ( vbuf , SIMPLE_OUTWARD_FRONT_INDICES ) ; meshes [ 1 ] = createMesh ( vbuf , SIMPLE_OUTWARD_RIGHT_INDICES ) ; meshes [ 2 ] = createMesh ( vbuf , SIMPLE_OUTWARD_BACK_INDICES ) ; meshes [ 3 ] = createMesh ( vbuf , SIMPLE_OUTWARD_LEFT_INDICES ) ; meshes [ 4 ] = createMesh ( vbuf , SIMPLE_OUTWARD_TOP_INDICES ) ; meshes [ 5 ] = createMesh ( vbuf , SIMPLE_OUTWARD_BOTTOM_INDICES ) ; } else { vbuf . setFloatArray ( "a_position" , SIMPLE_VERTICES , 3 , 0 ) ; vbuf . setFloatArray ( "a_normal" , SIMPLE_INWARD_NORMALS , 3 , 0 ) ; vbuf . setFloatArray ( "a_texcoord" , SIMPLE_INWARD_TEXCOORDS , 2 , 0 ) ; meshes [ 0 ] = createMesh ( vbuf , SIMPLE_INWARD_FRONT_INDICES ) ; meshes [ 1 ] = createMesh ( vbuf , SIMPLE_INWARD_RIGHT_INDICES ) ; meshes [ 2 ] = createMesh ( vbuf , SIMPLE_INWARD_BACK_INDICES ) ; meshes [ 3 ] = createMesh ( vbuf , SIMPLE_INWARD_LEFT_INDICES ) ; meshes [ 4 ] = createMesh ( vbuf , SIMPLE_INWARD_TOP_INDICES ) ; meshes [ 5 ] = createMesh ( vbuf , SIMPLE_INWARD_BOTTOM_INDICES ) ; } for ( int i = 0 ; i < 6 ; i ++ ) { children [ i ] = new GVRSceneObject ( gvrContext , meshes [ i ] , textureList . get ( i ) ) ; addChildObject ( children [ i ] ) ; } // attached an empty renderData for parent object, so that we can set some common properties GVRRenderData renderData = new GVRRenderData ( gvrContext ) ; attachRenderData ( renderData ) ; }
Creates a cube with each face as a separate mesh using a different texture . The meshes will share a common vertex array but will have separate index buffers .
663
31
148,570
protected void update ( float scale ) { GVRSceneObject owner = getOwnerObject ( ) ; if ( isEnabled ( ) && ( owner != null ) && owner . isEnabled ( ) ) { float w = getWidth ( ) ; float h = getHeight ( ) ; mPose . update ( mARPlane . getCenterPose ( ) , scale ) ; Matrix4f m = new Matrix4f ( ) ; m . set ( mPose . getPoseMatrix ( ) ) ; m . scaleLocal ( w * 0.95f , h * 0.95f , 1.0f ) ; owner . getTransform ( ) . setModelMatrix ( m ) ; } }
Update the plane based on arcore best knowledge of the world
145
12
148,571
public void setValue ( Vector3f pos ) { mX = pos . x ; mY = pos . y ; mZ = pos . z ; }
Sets the position vector of the keyframe .
33
10
148,572
public void getKey ( int keyIndex , float [ ] values ) { int index = keyIndex * mFloatsPerKey ; System . arraycopy ( mKeys , index + 1 , values , 0 , values . length ) ; }
Returns the key value in the given array .
49
9
148,573
public void setKey ( int keyIndex , float time , final float [ ] values ) { int index = keyIndex * mFloatsPerKey ; Integer valSize = mFloatsPerKey - 1 ; if ( values . length != valSize ) { throw new IllegalArgumentException ( "This key needs " + valSize . toString ( ) + " float per value" ) ; } mKeys [ index ] = time ; System . arraycopy ( values , 0 , mKeys , index + 1 , values . length ) ; }
Set the time and value of the key at the given index
112
12
148,574
public void resizeKeys ( int numKeys ) { int n = numKeys * mFloatsPerKey ; if ( mKeys . length == n ) { return ; } float [ ] newKeys = new float [ n ] ; n = Math . min ( n , mKeys . length ) ; System . arraycopy ( mKeys , 0 , newKeys , 0 , n ) ; mKeys = newKeys ; mFloatInterpolator . setKeyData ( mKeys ) ; }
Resize the key data area . This function will truncate the keys if the initial setting was too large .
100
22
148,575
public void setEnable ( boolean flag ) { if ( flag == mIsEnabled ) return ; mIsEnabled = flag ; if ( getNative ( ) != 0 ) { NativeComponent . setEnable ( getNative ( ) , flag ) ; } if ( flag ) { onEnable ( ) ; } else { onDisable ( ) ; } }
Enable or disable this component .
70
6
148,576
public void registerDatatype ( Class < ? extends GVRHybridObject > textureClass , AsyncLoaderFactory < ? extends GVRHybridObject , ? > asyncLoaderFactory ) { mFactories . put ( textureClass , asyncLoaderFactory ) ; }
Loaders call this method to register themselves . This method can be called by loaders provided by the application .
55
22
148,577
public void assertGLThread ( ) { if ( Thread . currentThread ( ) . getId ( ) != mGLThreadID ) { RuntimeException e = new RuntimeException ( "Should not run GL functions from a non-GL thread!" ) ; e . printStackTrace ( ) ; throw e ; } }
Throws an exception if the current thread is not a GL thread .
65
14
148,578
public void logError ( String message , Object sender ) { getEventManager ( ) . sendEvent ( this , IErrorEvents . class , "onError" , new Object [ ] { message , sender } ) ; }
Logs an error by sending an error event to all listeners .
46
13
148,579
public synchronized void stopDebugServer ( ) { if ( mDebugServer == null ) { Log . e ( TAG , "Debug server is not running." ) ; return ; } mDebugServer . shutdown ( ) ; mDebugServer = null ; }
Stops the current debug server . Active connections are not affected .
51
13
148,580
public void showToast ( final String message , float duration ) { final float quadWidth = 1.2f ; final GVRTextViewSceneObject toastSceneObject = new GVRTextViewSceneObject ( this , quadWidth , quadWidth / 5 , message ) ; toastSceneObject . setTextSize ( 6 ) ; toastSceneObject . setTextColor ( Color . WHITE ) ; toastSceneObject . setGravity ( Gravity . CENTER_HORIZONTAL | Gravity . TOP ) ; toastSceneObject . setBackgroundColor ( Color . DKGRAY ) ; toastSceneObject . setRefreshFrequency ( GVRTextViewSceneObject . IntervalFrequency . REALTIME ) ; final GVRTransform t = toastSceneObject . getTransform ( ) ; t . setPositionZ ( - 1.5f ) ; final GVRRenderData rd = toastSceneObject . getRenderData ( ) ; final float finalOpacity = 0.7f ; rd . getMaterial ( ) . setOpacity ( 0 ) ; rd . setRenderingOrder ( 2 * GVRRenderData . GVRRenderingOrder . OVERLAY ) ; rd . setDepthTest ( false ) ; final GVRCameraRig rig = getMainScene ( ) . getMainCameraRig ( ) ; rig . addChildObject ( toastSceneObject ) ; final GVRMaterialAnimation fadeOut = new GVRMaterialAnimation ( rd . getMaterial ( ) , duration / 4.0f ) { @ Override protected void animate ( GVRHybridObject target , float ratio ) { final GVRMaterial material = ( GVRMaterial ) target ; material . setOpacity ( finalOpacity - ratio * finalOpacity ) ; } } ; fadeOut . setOnFinish ( new GVROnFinish ( ) { @ Override public void finished ( GVRAnimation animation ) { rig . removeChildObject ( toastSceneObject ) ; } } ) ; final GVRMaterialAnimation fadeIn = new GVRMaterialAnimation ( rd . getMaterial ( ) , 3.0f * duration / 4.0f ) { @ Override protected void animate ( GVRHybridObject target , float ratio ) { final GVRMaterial material = ( GVRMaterial ) target ; material . setOpacity ( ratio * finalOpacity ) ; } } ; fadeIn . setOnFinish ( new GVROnFinish ( ) { @ Override public void finished ( GVRAnimation animation ) { getAnimationEngine ( ) . start ( fadeOut ) ; } } ) ; getAnimationEngine ( ) . start ( fadeIn ) ; }
Show a toast - like message for the specified duration
552
10
148,581
public void append ( float [ ] newValue ) { if ( ( newValue . length % 2 ) == 0 ) { for ( int i = 0 ; i < ( newValue . length / 2 ) ; i ++ ) { value . add ( new SFVec2f ( newValue [ i * 2 ] , newValue [ i * 2 + 1 ] ) ) ; } } else { Log . e ( TAG , "X3D MFVec3f append set with array length not divisible by 2" ) ; } }
Places a new value at the end of the existing value array increasing the field length accordingly .
112
19
148,582
public void insertValue ( int index , float [ ] newValue ) { if ( newValue . length == 2 ) { try { value . add ( index , new SFVec2f ( newValue [ 0 ] , newValue [ 1 ] ) ) ; } catch ( IndexOutOfBoundsException e ) { Log . e ( TAG , "X3D MFVec2f get1Value(index) out of bounds." + e ) ; } catch ( Exception e ) { Log . e ( TAG , "X3D MFVec2f get1Value(index) exception " + e ) ; } } else { Log . e ( TAG , "X3D MFVec2f insertValue set with array length not equal to 2" ) ; } }
Insert a new value prior to the index location in the existing value array increasing the field length accordingly .
163
20
148,583
public void setOuterConeAngle ( float angle ) { setFloat ( "outer_cone_angle" , ( float ) Math . cos ( Math . toRadians ( angle ) ) ) ; mChanged . set ( true ) ; }
Set the inner angle of the spotlight cone in degrees .
52
11
148,584
public void setCastShadow ( boolean enableFlag ) { GVRSceneObject owner = getOwnerObject ( ) ; if ( owner != null ) { GVRShadowMap shadowMap = ( GVRShadowMap ) getComponent ( GVRRenderTarget . getComponentType ( ) ) ; if ( enableFlag ) { if ( shadowMap != null ) { shadowMap . setEnable ( true ) ; } else { float angle = ( float ) Math . acos ( getFloat ( "outer_cone_angle" ) ) * 2.0f ; GVRCamera shadowCam = GVRShadowMap . makePerspShadowCamera ( getGVRContext ( ) . getMainScene ( ) . getMainCameraRig ( ) . getCenterCamera ( ) , angle ) ; shadowMap = new GVRShadowMap ( getGVRContext ( ) , shadowCam ) ; owner . attachComponent ( shadowMap ) ; } mChanged . set ( true ) ; } else if ( shadowMap != null ) { shadowMap . setEnable ( false ) ; } } mCastShadow = enableFlag ; }
Enables or disabled shadow casting for a spot light . Enabling shadows attaches a GVRShadowMap component to the GVRSceneObject which owns the light and provides the component with an perspective camera for shadow casting .
228
43
148,585
public GVRCursorController findCursorController ( GVRControllerType type ) { for ( int index = 0 , size = cache . size ( ) ; index < size ; index ++ ) { int key = cache . keyAt ( index ) ; GVRCursorController controller = cache . get ( key ) ; if ( controller . getControllerType ( ) . equals ( type ) ) { return controller ; } } return null ; }
Get the first controller of a specified type
91
8
148,586
public int clear ( ) { int n = 0 ; for ( GVRCursorController c : controllers ) { c . stopDrag ( ) ; removeCursorController ( c ) ; ++ n ; } return n ; }
Remove all controllers but leave input manager running .
46
9
148,587
public void close ( ) { inputManager . unregisterInputDeviceListener ( inputDeviceListener ) ; mouseDeviceManager . forceStopThread ( ) ; gamepadDeviceManager . forceStopThread ( ) ; controllerIds . clear ( ) ; cache . clear ( ) ; controllers . clear ( ) ; }
Shut down the input manager .
62
6
148,588
private GVRCursorController getUniqueControllerId ( int deviceId ) { GVRCursorController controller = controllerIds . get ( deviceId ) ; if ( controller != null ) { return controller ; } return null ; }
returns null if no device is found .
48
9
148,589
private int getCacheKey ( InputDevice device , GVRControllerType controllerType ) { if ( controllerType != GVRControllerType . UNKNOWN && controllerType != GVRControllerType . EXTERNAL ) { // Sometimes a device shows up using two device ids // here we try to show both devices as one using the // product and vendor id int key = device . getVendorId ( ) ; key = 31 * key + device . getProductId ( ) ; key = 31 * key + controllerType . hashCode ( ) ; return key ; } return - 1 ; // invalid key }
Return the key if there is one else return - 1
124
11
148,590
private GVRCursorController addDevice ( int deviceId ) { InputDevice device = inputManager . getInputDevice ( deviceId ) ; GVRControllerType controllerType = getGVRInputDeviceType ( device ) ; if ( mEnabledControllerTypes == null ) { return null ; } if ( controllerType == GVRControllerType . GAZE && ! mEnabledControllerTypes . contains ( GVRControllerType . GAZE ) ) { return null ; } int key ; if ( controllerType == GVRControllerType . GAZE ) { // create the controller if there isn't one. if ( gazeCursorController == null ) { gazeCursorController = new GVRGazeCursorController ( context , GVRControllerType . GAZE , GVRDeviceConstants . OCULUS_GEARVR_DEVICE_NAME , GVRDeviceConstants . OCULUS_GEARVR_TOUCHPAD_VENDOR_ID , GVRDeviceConstants . OCULUS_GEARVR_TOUCHPAD_PRODUCT_ID ) ; } // use the cached gaze key key = GAZE_CACHED_KEY ; } else { key = getCacheKey ( device , controllerType ) ; } if ( key != - 1 ) { GVRCursorController controller = cache . get ( key ) ; if ( controller == null ) { if ( ( mEnabledControllerTypes == null ) || ! mEnabledControllerTypes . contains ( controllerType ) ) { return null ; } if ( controllerType == GVRControllerType . MOUSE ) { controller = mouseDeviceManager . getCursorController ( context , device . getName ( ) , device . getVendorId ( ) , device . getProductId ( ) ) ; } else if ( controllerType == GVRControllerType . GAMEPAD ) { controller = gamepadDeviceManager . getCursorController ( context , device . getName ( ) , device . getVendorId ( ) , device . getProductId ( ) ) ; } else if ( controllerType == GVRControllerType . GAZE ) { controller = gazeCursorController ; } cache . put ( key , controller ) ; controllerIds . put ( device . getId ( ) , controller ) ; return controller ; } else { controllerIds . put ( device . getId ( ) , controller ) ; } } return null ; }
returns controller if a new device is found
504
9
148,591
public List < GVRAtlasInformation > getAtlasInformation ( ) { if ( ( mImage != null ) && ( mImage instanceof GVRImageAtlas ) ) { return ( ( GVRImageAtlas ) mImage ) . getAtlasInformation ( ) ; } return null ; }
Returns the list of atlas information necessary to map the texture atlas to each scene object .
63
19
148,592
public void setImage ( final GVRImage imageData ) { mImage = imageData ; if ( imageData != null ) NativeTexture . setImage ( getNative ( ) , imageData , imageData . getNative ( ) ) ; else NativeTexture . setImage ( getNative ( ) , null , 0 ) ; }
Changes the image data associated with a GVRTexture . This can be a simple bitmap a compressed bitmap a cubemap or a compressed cubemap .
67
33
148,593
public static void sendEvent ( Context context , Parcelable event ) { Intent intent = new Intent ( EventManager . ACTION_ACCESSORY_EVENT ) ; intent . putExtra ( EventManager . EXTRA_EVENT , event ) ; context . sendBroadcast ( intent ) ; }
Send an event to other applications
61
6
148,594
public static AiScene importFile ( String filename ) throws IOException { return importFile ( filename , EnumSet . noneOf ( AiPostProcessSteps . class ) ) ; }
Imports a file via assimp without post processing .
38
11
148,595
public void addChannel ( String boneName , GVRAnimationChannel channel ) { int boneId = mSkeleton . getBoneIndex ( boneName ) ; if ( boneId >= 0 ) { mBoneChannels [ boneId ] = channel ; mSkeleton . setBoneOptions ( boneId , GVRSkeleton . BONE_ANIMATE ) ; Log . d ( "BONE" , "Adding animation channel %d %s " , boneId , boneName ) ; } }
Add a channel to the animation to animate the named bone .
103
12
148,596
public GVRAnimationChannel findChannel ( String boneName ) { int boneId = mSkeleton . getBoneIndex ( boneName ) ; if ( boneId >= 0 ) { return mBoneChannels [ boneId ] ; } return null ; }
Find the channel in the animation that animates the named bone .
52
13
148,597
public void animate ( float timeInSec ) { GVRSkeleton skel = getSkeleton ( ) ; GVRPose pose = skel . getPose ( ) ; computePose ( timeInSec , pose ) ; skel . poseToBones ( ) ; skel . updateBonePose ( ) ; skel . updateSkinPose ( ) ; }
Compute pose of skeleton at the given time from the animation channels .
80
14
148,598
public void put ( GVRAndroidResource androidResource , T resource ) { Log . d ( TAG , "put resource %s to cache" , androidResource ) ; super . put ( androidResource , resource ) ; }
Save a weak reference to the resource
45
7
148,599
public void removeControl ( String name ) { Widget control = findChildByName ( name ) ; if ( control != null ) { removeChild ( control ) ; if ( mBgResId != - 1 ) { updateMesh ( ) ; } } }
Remove control from the control bar . Size of control bar is updated based on new number of controls .
54
20