idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
148,400
private long doMemoryManagementAndPerFrameCallbacks ( ) { long currentTime = GVRTime . getCurrentTime ( ) ; mFrameTime = ( currentTime - mPreviousTimeNanos ) / 1e9f ; mPreviousTimeNanos = currentTime ; /* * Without the sensor data, can't draw a scene properly. */ if ( ! ( mSensoredScene == null || ! mMainScene . equals ( mSensoredScene ) ) ) { Runnable runnable ; while ( ( runnable = mRunnables . poll ( ) ) != null ) { try { runnable . run ( ) ; } catch ( final Exception exc ) { Log . e ( TAG , "Runnable-on-GL %s threw %s" , runnable , exc . toString ( ) ) ; exc . printStackTrace ( ) ; } } final List < GVRDrawFrameListener > frameListeners = mFrameListeners ; for ( GVRDrawFrameListener listener : frameListeners ) { try { listener . onDrawFrame ( mFrameTime ) ; } catch ( final Exception exc ) { Log . e ( TAG , "DrawFrameListener %s threw %s" , listener , exc . toString ( ) ) ; exc . printStackTrace ( ) ; } } } return currentTime ; }
This is the code that needs to be executed before either eye is drawn .
285
15
148,401
protected void capture3DScreenShot ( GVRRenderTarget renderTarget , boolean isMultiview ) { if ( mScreenshot3DCallback == null ) { return ; } final Bitmap [ ] bitmaps = new Bitmap [ 6 ] ; renderSixCamerasAndReadback ( mMainScene . getMainCameraRig ( ) , bitmaps , renderTarget , isMultiview ) ; returnScreenshot3DToCaller ( mScreenshot3DCallback , bitmaps , mReadbackBufferWidth , mReadbackBufferHeight ) ; mScreenshot3DCallback = null ; }
capture 3D screenshot
126
5
148,402
private void captureEye ( GVRScreenshotCallback callback , GVRRenderTarget renderTarget , GVRViewManager . EYE eye , boolean useMultiview ) { if ( null == callback ) { return ; } readRenderResult ( renderTarget , eye , useMultiview ) ; returnScreenshotToCaller ( callback , mReadbackBufferWidth , mReadbackBufferHeight ) ; }
capture screenshot of an eye
81
6
148,403
protected void captureCenterEye ( GVRRenderTarget renderTarget , boolean isMultiview ) { if ( mScreenshotCenterCallback == null ) { return ; } // TODO: when we will use multithreading, create new camera using centercamera as we are adding posteffects into it final GVRCamera centerCamera = mMainScene . getMainCameraRig ( ) . getCenterCamera ( ) ; final GVRMaterial postEffect = new GVRMaterial ( this , GVRMaterial . GVRShaderType . VerticalFlip . ID ) ; centerCamera . addPostEffect ( postEffect ) ; GVRRenderTexture posteffectRenderTextureB = null ; GVRRenderTexture posteffectRenderTextureA = null ; if ( isMultiview ) { posteffectRenderTextureA = mRenderBundle . getEyeCapturePostEffectRenderTextureA ( ) ; posteffectRenderTextureB = mRenderBundle . getEyeCapturePostEffectRenderTextureB ( ) ; renderTarget = mRenderBundle . getEyeCaptureRenderTarget ( ) ; renderTarget . cullFromCamera ( mMainScene , centerCamera , mRenderBundle . getShaderManager ( ) ) ; renderTarget . beginRendering ( centerCamera ) ; } else { posteffectRenderTextureA = mRenderBundle . getPostEffectRenderTextureA ( ) ; posteffectRenderTextureB = mRenderBundle . getPostEffectRenderTextureB ( ) ; } renderTarget . render ( mMainScene , centerCamera , mRenderBundle . getShaderManager ( ) , posteffectRenderTextureA , posteffectRenderTextureB ) ; centerCamera . removePostEffect ( postEffect ) ; readRenderResult ( renderTarget , EYE . MULTIVIEW , false ) ; if ( isMultiview ) renderTarget . endRendering ( ) ; final Bitmap bitmap = Bitmap . createBitmap ( mReadbackBufferWidth , mReadbackBufferHeight , Bitmap . Config . ARGB_8888 ) ; mReadbackBuffer . rewind ( ) ; bitmap . copyPixelsFromBuffer ( mReadbackBuffer ) ; final GVRScreenshotCallback callback = mScreenshotCenterCallback ; Threads . spawn ( new Runnable ( ) { public void run ( ) { callback . onScreenCaptured ( bitmap ) ; } } ) ; mScreenshotCenterCallback = null ; }
capture center eye
502
4
148,404
public boolean runOnMainThreadNext ( Runnable r ) { assert handler != null ; if ( ! sanityCheck ( "runOnMainThreadNext " + r ) ) { return false ; } return handler . post ( r ) ; }
Queues a Runnable to be run on the main thread on the next iteration of the messaging loop . This is handy when code running on the main thread needs to run something else on the main thread but only after the current code has finished executing .
50
51
148,405
private void showSettingsMenu ( final Cursor cursor ) { Log . d ( TAG , "showSettingsMenu" ) ; enableSettingsCursor ( cursor ) ; context . runOnGlThread ( new Runnable ( ) { @ Override public void run ( ) { new SettingsView ( context , scene , CursorManager . this , settingsCursor . getIoDevice ( ) . getCursorControllerId ( ) , cursor , new SettingsChangeListener ( ) { @ Override public void onBack ( boolean cascading ) { disableSettingsCursor ( ) ; } @ Override public int onDeviceChanged ( IoDevice device ) { // we are changing the io device on the settings cursor removeCursorFromScene ( settingsCursor ) ; IoDevice clickedDevice = getAvailableIoDevice ( device ) ; settingsCursor . setIoDevice ( clickedDevice ) ; addCursorToScene ( settingsCursor ) ; return device . getCursorControllerId ( ) ; } } ) ; } } ) ; }
Presents the Cursor Settings to the User . Only works if scene is set .
213
17
148,406
private void updateCursorsInScene ( GVRScene scene , boolean add ) { synchronized ( mCursors ) { for ( Cursor cursor : mCursors ) { if ( cursor . isActive ( ) ) { if ( add ) { addCursorToScene ( cursor ) ; } else { removeCursorFromScene ( cursor ) ; } } } } }
Add or remove the active cursors from the provided scene .
79
12
148,407
public List < Widget > getAllViews ( ) { List < Widget > views = new ArrayList <> ( ) ; for ( Widget child : mContent . getChildren ( ) ) { Widget item = ( ( ListItemHostWidget ) child ) . getGuest ( ) ; if ( item != null ) { views . add ( item ) ; } } return views ; }
Get all views from the list content
82
7
148,408
public boolean clearSelection ( boolean requestLayout ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "clearSelection [%d]" , mSelectedItemsList . size ( ) ) ; boolean updateLayout = false ; List < ListItemHostWidget > views = getAllHosts ( ) ; for ( ListItemHostWidget host : views ) { if ( host . isSelected ( ) ) { host . setSelected ( false ) ; updateLayout = true ; if ( requestLayout ) { host . requestLayout ( ) ; } } } clearSelectedItemsList ( ) ; return updateLayout ; }
Clear the selection of all items .
135
7
148,409
public boolean updateSelectedItemsList ( int dataIndex , boolean select ) { boolean done = false ; boolean contains = isSelected ( dataIndex ) ; if ( select ) { if ( ! contains ) { if ( ! mMultiSelectionSupported ) { clearSelection ( false ) ; } Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "updateSelectedItemsList add index = %d" , dataIndex ) ; mSelectedItemsList . add ( dataIndex ) ; done = true ; } } else { if ( contains ) { Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "updateSelectedItemsList remove index = %d" , dataIndex ) ; mSelectedItemsList . remove ( dataIndex ) ; done = true ; } } return done ; }
Update the selection state of the item
176
7
148,410
private void onScrollImpl ( final Vector3Axis offset , final LayoutScroller . OnScrollListener listener ) { if ( ! isScrolling ( ) ) { mScroller = new ScrollingProcessor ( offset , listener ) ; mScroller . scroll ( ) ; } }
This method is called if the data set has been scrolled .
59
13
148,411
protected void recycleChildren ( ) { for ( ListItemHostWidget host : getAllHosts ( ) ) { recycle ( host ) ; } mContent . onTransformChanged ( ) ; mContent . requestLayout ( ) ; }
Recycle all views in the list . The host views might be reused for other data to save resources on creating new widgets .
47
25
148,412
private void onChangedImpl ( final int preferableCenterPosition ) { for ( ListOnChangedListener listener : mOnChangedListeners ) { listener . onChangedStart ( this ) ; } Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "onChangedImpl(%s): items [%d] views [%d] mLayouts.size() = %d " + "preferableCenterPosition = %d" , getName ( ) , getDataCount ( ) , getViewCount ( ) , mContent . mLayouts . size ( ) , preferableCenterPosition ) ; // TODO: selectively recycle data based on the changes in the data set mPreferableCenterPosition = preferableCenterPosition ; recycleChildren ( ) ; }
This method is called if the data set has been changed . Subclasses might want to override this method to add some extra logic .
160
26
148,413
static Shell createTerminalConsoleShell ( String prompt , String appName , ShellCommandHandler mainHandler , InputStream input , OutputStream output ) { try { PrintStream out = new PrintStream ( output ) ; // Build jline terminal jline . Terminal term = TerminalFactory . get ( ) ; final ConsoleReader console = new ConsoleReader ( input , output , term ) ; console . setBellEnabled ( true ) ; console . setHistoryEnabled ( true ) ; // Build console BufferedReader in = new BufferedReader ( new InputStreamReader ( new ConsoleReaderInputStream ( console ) ) ) ; ConsoleIO . PromptListener promptListener = new ConsoleIO . PromptListener ( ) { @ Override public boolean onPrompt ( String prompt ) { console . setPrompt ( prompt ) ; return true ; // suppress normal prompt } } ; return createConsoleShell ( prompt , appName , mainHandler , in , out , out , promptListener ) ; } catch ( Exception e ) { // Failover: use default shell BufferedReader in = new BufferedReader ( new InputStreamReader ( input ) ) ; PrintStream out = new PrintStream ( output ) ; return createConsoleShell ( prompt , appName , mainHandler , in , out , out , null ) ; } }
Facade method for operating the Unix - like terminal supporting line editing and command history .
264
17
148,414
static Shell createTelnetConsoleShell ( String prompt , String appName , ShellCommandHandler mainHandler , InputStream input , OutputStream output ) { try { // Set up nvt4j; ignore the initial clear & reposition final nvt4j . impl . Terminal nvt4jTerminal = new nvt4j . impl . Terminal ( input , output ) { private boolean cleared ; private boolean moved ; @ Override public void clear ( ) throws IOException { if ( this . cleared ) super . clear ( ) ; this . cleared = true ; } @ Override public void move ( int row , int col ) throws IOException { if ( this . moved ) super . move ( row , col ) ; this . moved = true ; } } ; nvt4jTerminal . put ( nvt4j . impl . Terminal . AUTO_WRAP_ON ) ; nvt4jTerminal . setCursor ( true ) ; // Have JLine do input & output through telnet terminal final InputStream jlineInput = new InputStream ( ) { @ Override public int read ( ) throws IOException { return nvt4jTerminal . get ( ) ; } } ; final OutputStream jlineOutput = new OutputStream ( ) { @ Override public void write ( int value ) throws IOException { nvt4jTerminal . put ( value ) ; } } ; return createTerminalConsoleShell ( prompt , appName , mainHandler , jlineInput , jlineOutput ) ; } catch ( Exception e ) { // Failover: use default shell BufferedReader in = new BufferedReader ( new InputStreamReader ( input ) ) ; PrintStream out = new PrintStream ( output ) ; return createConsoleShell ( prompt , appName , mainHandler , in , out , out , null ) ; } }
Facade method for operating the Telnet Shell supporting line editing and command history over a socket .
385
19
148,415
protected void AddLODSceneObject ( GVRSceneObject currentSceneObject ) { if ( this . transformLODSceneObject != null ) { GVRSceneObject levelOfDetailSceneObject = null ; if ( currentSceneObject . getParent ( ) == this . transformLODSceneObject ) { levelOfDetailSceneObject = currentSceneObject ; } else { GVRSceneObject lodSceneObj = root . getSceneObjectByName ( ( currentSceneObject . getName ( ) + TRANSFORM_TRANSLATION_ ) ) ; if ( lodSceneObj != null ) { if ( lodSceneObj . getParent ( ) == this . transformLODSceneObject ) { levelOfDetailSceneObject = lodSceneObj ; } } if ( levelOfDetailSceneObject == null ) { lodSceneObj = root . getSceneObjectByName ( ( currentSceneObject . getName ( ) + TRANSFORM_ROTATION_ ) ) ; if ( lodSceneObj != null ) { if ( lodSceneObj . getParent ( ) == this . transformLODSceneObject ) { levelOfDetailSceneObject = lodSceneObj ; } } } if ( levelOfDetailSceneObject == null ) { lodSceneObj = root . getSceneObjectByName ( ( currentSceneObject . getName ( ) + TRANSFORM_SCALE_ ) ) ; if ( lodSceneObj != null ) { if ( lodSceneObj . getParent ( ) == this . transformLODSceneObject ) { levelOfDetailSceneObject = lodSceneObj ; } } } } if ( levelOfDetailSceneObject != null ) { final GVRLODGroup lodGroup = ( GVRLODGroup ) this . transformLODSceneObject . getComponent ( GVRLODGroup . getComponentType ( ) ) ; lodGroup . addRange ( this . getMinRange ( ) , levelOfDetailSceneObject ) ; this . increment ( ) ; } } }
Add the currentSceneObject to an active Level - of - Detail
406
13
148,416
@ Override public boolean applyLayout ( Layout itemLayout ) { boolean applied = false ; if ( itemLayout != null && mItemLayouts . add ( itemLayout ) ) { // apply the layout to all visible pages List < Widget > views = getAllViews ( ) ; for ( Widget view : views ) { view . applyLayout ( itemLayout . clone ( ) ) ; } applied = true ; } return applied ; }
Apply the layout to the each page in the list
91
10
148,417
public LayoutScroller . ScrollableList getPageScrollable ( ) { return new LayoutScroller . ScrollableList ( ) { @ Override public int getScrollingItemsCount ( ) { return MultiPageWidget . super . getScrollingItemsCount ( ) ; } @ Override public float getViewPortWidth ( ) { return MultiPageWidget . super . getViewPortWidth ( ) ; } @ Override public float getViewPortHeight ( ) { return MultiPageWidget . super . getViewPortHeight ( ) ; } @ Override public float getViewPortDepth ( ) { return MultiPageWidget . super . getViewPortDepth ( ) ; } @ Override public boolean scrollToPosition ( int pos , final LayoutScroller . OnScrollListener listener ) { return MultiPageWidget . super . scrollToPosition ( pos , listener ) ; } @ Override public boolean scrollByOffset ( float xOffset , float yOffset , float zOffset , final LayoutScroller . OnScrollListener listener ) { return MultiPageWidget . super . scrollByOffset ( xOffset , yOffset , zOffset , listener ) ; } @ Override public void registerDataSetObserver ( DataSetObserver observer ) { MultiPageWidget . super . registerDataSetObserver ( observer ) ; } @ Override public void unregisterDataSetObserver ( DataSetObserver observer ) { MultiPageWidget . super . unregisterDataSetObserver ( observer ) ; } @ Override public int getCurrentPosition ( ) { return MultiPageWidget . super . getCurrentPosition ( ) ; } } ; }
Provides the scrollableList implementation for page scrolling
331
10
148,418
public void startAnimation ( ) { Date time = new Date ( ) ; this . beginAnimation = time . getTime ( ) ; this . endAnimation = beginAnimation + ( long ) ( animationTime * 1000 ) ; this . animate = true ; }
once animation is setup start the animation record the beginning and ending time for the animation
52
16
148,419
public void updateAnimation ( ) { Date time = new Date ( ) ; long currentTime = time . getTime ( ) - this . beginAnimation ; if ( currentTime > animationTime ) { this . currentQuaternion . set ( endQuaternion ) ; for ( int i = 0 ; i < 3 ; i ++ ) { this . currentPos [ i ] = this . endPos [ i ] ; } this . animate = false ; } else { float t = ( float ) currentTime / animationTime ; this . currentQuaternion = this . beginQuaternion . slerp ( this . endQuaternion , t ) ; for ( int i = 0 ; i < 3 ; i ++ ) { this . currentPos [ i ] = this . beginPos [ i ] + totalTranslation [ i ] * t ; } } }
called per frame of animation to update the camera position
178
10
148,420
public int [ ] getDefalutValuesArray ( ) { int [ ] defaultValues = new int [ 5 ] ; defaultValues [ 0 ] = GLES20 . GL_LINEAR_MIPMAP_NEAREST ; // MIN FILTER defaultValues [ 1 ] = GLES20 . GL_LINEAR ; // MAG FILTER defaultValues [ 2 ] = 1 ; // ANISO FILTER defaultValues [ 3 ] = GLES20 . GL_CLAMP_TO_EDGE ; // WRAP S defaultValues [ 4 ] = GLES20 . GL_CLAMP_TO_EDGE ; // WRAP T return defaultValues ; }
Returns an integer array that contains the default values for all the texture parameters .
137
15
148,421
public int [ ] getCurrentValuesArray ( ) { int [ ] currentValues = new int [ 5 ] ; currentValues [ 0 ] = getMinFilterType ( ) . getFilterValue ( ) ; // MIN FILTER currentValues [ 1 ] = getMagFilterType ( ) . getFilterValue ( ) ; // MAG FILTER currentValues [ 2 ] = getAnisotropicValue ( ) ; // ANISO FILTER currentValues [ 3 ] = getWrapSType ( ) . getWrapValue ( ) ; // WRAP S currentValues [ 4 ] = getWrapTType ( ) . getWrapValue ( ) ; // WRAP T return currentValues ; }
Returns an integer array that contains the current values for all the texture parameters .
143
15
148,422
public boolean hasProperties ( Set < PropertyKey > keys ) { for ( PropertyKey key : keys ) { if ( null == getProperty ( key . m_key ) ) { return false ; } } return true ; }
Checks whether the given set of properties is available .
47
11
148,423
public Integer getTextureMagFilter ( AiTextureType type , int index ) { checkTexRange ( type , index ) ; Property p = getProperty ( PropertyKey . TEX_MAG_FILTER . m_key ) ; if ( null == p || null == p . getData ( ) ) { return ( Integer ) m_defaults . get ( PropertyKey . TEX_MAG_FILTER ) ; } Object rawValue = p . getData ( ) ; if ( rawValue instanceof java . nio . ByteBuffer ) { java . nio . IntBuffer ibuf = ( ( java . nio . ByteBuffer ) rawValue ) . asIntBuffer ( ) ; return ibuf . get ( ) ; } else { return ( Integer ) rawValue ; } }
Returns the texture magnification filter
163
5
148,424
public float getMetallic ( ) { Property p = getProperty ( PropertyKey . METALLIC . m_key ) ; if ( null == p || null == p . getData ( ) ) { throw new IllegalArgumentException ( "Metallic property not found" ) ; } Object rawValue = p . getData ( ) ; if ( rawValue instanceof java . nio . ByteBuffer ) { java . nio . FloatBuffer fbuf = ( ( java . nio . ByteBuffer ) rawValue ) . asFloatBuffer ( ) ; return fbuf . get ( ) ; } else { return ( Float ) rawValue ; } }
Returns the metallic factor for PBR shading
135
8
148,425
public AiTextureInfo getTextureInfo ( AiTextureType type , int index ) { return new AiTextureInfo ( type , index , getTextureFile ( type , index ) , getTextureUVIndex ( type , index ) , getBlendFactor ( type , index ) , getTextureOp ( type , index ) , getTextureMapModeW ( type , index ) , getTextureMapModeW ( type , index ) , getTextureMapModeW ( type , index ) ) ; }
Returns all information related to a single texture .
100
9
148,426
private void checkTexRange ( AiTextureType type , int index ) { if ( index < 0 || index > m_numTextures . get ( type ) ) { throw new IndexOutOfBoundsException ( "Index: " + index + ", Size: " + m_numTextures . get ( type ) ) ; } }
Checks that index is valid an throw an exception if not .
68
13
148,427
@ SuppressWarnings ( "unused" ) private void setTextureNumber ( int type , int number ) { m_numTextures . put ( AiTextureType . fromRawValue ( type ) , number ) ; }
This method is used by JNI do not call or modify .
47
13
148,428
public void setFrustum ( float [ ] frustum ) { Matrix4f projMatrix = new Matrix4f ( ) ; projMatrix . setFrustum ( frustum [ 0 ] , frustum [ 3 ] , frustum [ 1 ] , frustum [ 4 ] , frustum [ 2 ] , frustum [ 5 ] ) ; setFrustum ( projMatrix ) ; }
Set the view frustum to pick against from the minimum and maximum corners . The viewpoint of the frustum is the center of the scene object the picker is attached to . The view direction is the forward direction of that scene object . The frustum will pick what a camera attached to the scene object with that view frustum would see . If the frustum is not attached to a scene object it defaults to the view frustum of the main camera of the scene .
85
94
148,429
public void setFrustum ( float fovy , float aspect , float znear , float zfar ) { Matrix4f projMatrix = new Matrix4f ( ) ; projMatrix . perspective ( ( float ) Math . toRadians ( fovy ) , aspect , znear , zfar ) ; setFrustum ( projMatrix ) ; }
Set the view frustum to pick against from the field of view aspect ratio and near far clip planes . The viewpoint of the frustum is the center of the scene object the picker is attached to . The view direction is the forward direction of that scene object . The frustum will pick what a camera attached to the scene object with that view frustum would see . If the frustum is not attached to a scene object it defaults to the view frustum of the main camera of the scene .
76
100
148,430
public void setFrustum ( Matrix4f projMatrix ) { if ( projMatrix != null ) { if ( mProjMatrix == null ) { mProjMatrix = new float [ 16 ] ; } mProjMatrix = projMatrix . get ( mProjMatrix , 0 ) ; mScene . setPickVisible ( false ) ; if ( mCuller != null ) { mCuller . set ( projMatrix ) ; } else { mCuller = new FrustumIntersection ( projMatrix ) ; } } mProjection = projMatrix ; }
Set the view frustum to pick against from the given projection matrix .
129
14
148,431
public static final GVRPickedObject [ ] pickVisible ( GVRScene scene ) { sFindObjectsLock . lock ( ) ; try { final GVRPickedObject [ ] result = NativePicker . pickVisible ( scene . getNative ( ) ) ; return result ; } finally { sFindObjectsLock . unlock ( ) ; } }
Returns the list of colliders attached to scene objects that are visible from the viewpoint of the camera .
76
20
148,432
public void setShortVec ( char [ ] data ) { if ( data == null ) { throw new IllegalArgumentException ( "Input data for indices cannot be null" ) ; } if ( getIndexSize ( ) != 2 ) { throw new UnsupportedOperationException ( "Cannot update integer indices with char array" ) ; } if ( ! NativeIndexBuffer . setShortArray ( getNative ( ) , data ) ) { throw new UnsupportedOperationException ( "Input array is wrong size" ) ; } }
Updates the indices in the index buffer from a Java char array . All of the entries of the input char array are copied into the storage for the index buffer . The new indices must be the same size as the old indices - the index buffer size cannot be changed .
108
54
148,433
public void setShortVec ( CharBuffer data ) { if ( data == null ) { throw new IllegalArgumentException ( "Input data for indices cannot be null" ) ; } if ( getIndexSize ( ) != 2 ) { throw new UnsupportedOperationException ( "Cannot update integer indices with char array" ) ; } if ( data . isDirect ( ) ) { if ( ! NativeIndexBuffer . setShortVec ( getNative ( ) , data ) ) { throw new UnsupportedOperationException ( "Input buffer is wrong size" ) ; } } else if ( data . hasArray ( ) ) { if ( ! NativeIndexBuffer . setShortArray ( getNative ( ) , data . array ( ) ) ) { throw new UnsupportedOperationException ( "Input buffer is wrong size" ) ; } } else { throw new UnsupportedOperationException ( "CharBuffer type not supported. Must be direct or have backing array" ) ; } }
Updates the indices in the index buffer from a Java CharBuffer . All of the entries of the input buffer are copied into the storage for the index buffer . The new indices must be the same size as the old indices - the index buffer size cannot be changed .
199
53
148,434
public void setIntVec ( int [ ] data ) { if ( data == null ) { throw new IllegalArgumentException ( "Input data for indices cannot be null" ) ; } if ( getIndexSize ( ) != 4 ) { throw new UnsupportedOperationException ( "Cannot update short indices with int array" ) ; } if ( ! NativeIndexBuffer . setIntArray ( getNative ( ) , data ) ) { throw new UnsupportedOperationException ( "Input array is wrong size" ) ; } }
Updates the indices in the index buffer from a Java int array . All of the entries of the input int array are copied into the storage for the index buffer . The new indices must be the same size as the old indices - the index buffer size cannot be changed .
108
54
148,435
public void setIntVec ( IntBuffer data ) { if ( data == null ) { throw new IllegalArgumentException ( "Input buffer for indices cannot be null" ) ; } if ( getIndexSize ( ) != 4 ) { throw new UnsupportedOperationException ( "Cannot update integer indices with short array" ) ; } if ( data . isDirect ( ) ) { if ( ! NativeIndexBuffer . setIntVec ( getNative ( ) , data ) ) { throw new UnsupportedOperationException ( "Input array is wrong size" ) ; } } else if ( data . hasArray ( ) ) { if ( ! NativeIndexBuffer . setIntArray ( getNative ( ) , data . array ( ) ) ) { throw new IllegalArgumentException ( "Data array incompatible with index buffer" ) ; } } else { throw new UnsupportedOperationException ( "IntBuffer type not supported. Must be direct or have backing array" ) ; } }
Updates the indices in the index buffer from a Java IntBuffer . All of the entries of the input int buffer are copied into the storage for the index buffer . The new indices must be the same size as the old indices - the index buffer size cannot be changed .
200
54
148,436
protected void emitWithBurstCheck ( float [ ] particlePositions , float [ ] particleVelocities , float [ ] particleTimeStamps ) { if ( burstMode ) { if ( executeOnce ) { emit ( particlePositions , particleVelocities , particleTimeStamps ) ; executeOnce = false ; } } else { emit ( particlePositions , particleVelocities , particleTimeStamps ) ; } }
If the burst mode is on emit the particles only once .
89
12
148,437
private void emit ( float [ ] particlePositions , float [ ] particleVelocities , float [ ] particleTimeStamps ) { float [ ] allParticlePositions = new float [ particlePositions . length + particleBoundingVolume . length ] ; System . arraycopy ( particlePositions , 0 , allParticlePositions , 0 , particlePositions . length ) ; System . arraycopy ( particleBoundingVolume , 0 , allParticlePositions , particlePositions . length , particleBoundingVolume . length ) ; float [ ] allSpawnTimes = new float [ particleTimeStamps . length + BVSpawnTimes . length ] ; System . arraycopy ( particleTimeStamps , 0 , allSpawnTimes , 0 , particleTimeStamps . length ) ; System . arraycopy ( BVSpawnTimes , 0 , allSpawnTimes , particleTimeStamps . length , BVSpawnTimes . length ) ; float [ ] allParticleVelocities = new float [ particleVelocities . length + BVVelocities . length ] ; System . arraycopy ( particleVelocities , 0 , allParticleVelocities , 0 , particleVelocities . length ) ; System . arraycopy ( BVVelocities , 0 , allParticleVelocities , particleVelocities . length , BVVelocities . length ) ; Particles particleMesh = new Particles ( mGVRContext , mMaxAge , mParticleSize , mEnvironmentAcceleration , mParticleSizeRate , mFadeWithAge , mParticleTexture , mColor , mNoiseFactor ) ; GVRSceneObject particleObject = particleMesh . makeParticleMesh ( allParticlePositions , allParticleVelocities , allSpawnTimes ) ; this . addChildObject ( particleObject ) ; meshInfo . add ( Pair . create ( particleObject , currTime ) ) ; }
Append the bounding volume particle positions times and velocities to the existing mesh before creating a new scene object with this mesh attached to it . Also append every created scene object and its creation time to corresponding array lists .
405
45
148,438
public void setVelocityRange ( final Vector3f minV , final Vector3f maxV ) { if ( null != mGVRContext ) { mGVRContext . runOnGlThread ( new Runnable ( ) { @ Override public void run ( ) { minVelocity = minV ; maxVelocity = maxV ; } } ) ; } }
The range of velocities that a particle generated from this emitter can have .
78
17
148,439
public static void logLong ( String TAG , String longString ) { InputStream is = new ByteArrayInputStream ( longString . getBytes ( ) ) ; @ SuppressWarnings ( "resource" ) Scanner scan = new Scanner ( is ) ; while ( scan . hasNextLine ( ) ) { Log . v ( TAG , scan . nextLine ( ) ) ; } }
Log long string using verbose tag
82
7
148,440
public static String readTextFile ( Context context , String asset ) { try { InputStream inputStream = context . getAssets ( ) . open ( asset ) ; return org . gearvrf . utility . TextFile . readTextFile ( inputStream ) ; } catch ( FileNotFoundException f ) { Log . w ( TAG , "readTextFile(): asset file '%s' doesn't exist" , asset ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; Log . e ( TAG , e , "readTextFile()" ) ; } return null ; }
Read a text file from assets into a single string
127
10
148,441
public static boolean equal ( Vector3f v1 , Vector3f v2 ) { return equal ( v1 . x , v2 . x ) && equal ( v1 . y , v2 . y ) && equal ( v1 . z , v2 . z ) ; }
Are these two numbers effectively equal?
59
7
148,442
public static int getId ( Context context , String id ) { final String defType ; if ( id . startsWith ( "R." ) ) { int dot = id . indexOf ( ' ' , 2 ) ; defType = id . substring ( 2 , dot ) ; } else { defType = "drawable" ; } Log . d ( TAG , "getId(): id: %s, extracted type: %s" , id , defType ) ; return getId ( context , id , defType ) ; }
Parses the resource String id and get back the int res id
111
14
148,443
public static int getId ( Context context , String id , String defType ) { String type = "R." + defType + "." ; if ( id . startsWith ( type ) ) { id = id . substring ( type . length ( ) ) ; } Resources r = context . getResources ( ) ; int resId = r . getIdentifier ( id , defType , context . getPackageName ( ) ) ; if ( resId > 0 ) { return resId ; } else { throw new RuntimeAssertion ( "Specified resource '%s' could not be found" , id ) ; } }
Get the int resource id with specified type definition
131
9
148,444
public String generateSignature ( HashMap < String , Integer > defined , GVRLight [ ] lightlist ) { return getClass ( ) . getSimpleName ( ) ; }
Create a unique signature for this shader . The signature for simple shaders is just the class name . For the more complex shaders generated by GVRShaderTemplate the signature includes information about the vertex attributes uniforms textures and lights used by the shader variant .
38
51
148,445
public int bindShader ( GVRContext context , IRenderable rdata , GVRScene scene , boolean isMultiview ) { String signature = getClass ( ) . getSimpleName ( ) ; GVRShaderManager shaderManager = context . getShaderManager ( ) ; GVRMaterial mtl = rdata . getMaterial ( ) ; synchronized ( shaderManager ) { int nativeShader = shaderManager . getShader ( signature ) ; if ( nativeShader == 0 ) { nativeShader = addShader ( shaderManager , signature , mtl ) ; } if ( nativeShader > 0 ) { rdata . setShader ( nativeShader , isMultiview ) ; } return nativeShader ; } }
Select the specific vertex and fragment shader to use .
156
10
148,446
public int bindShader ( GVRContext context , GVRShaderData material , String vertexDesc ) { String signature = getClass ( ) . getSimpleName ( ) ; GVRShaderManager shaderManager = context . getShaderManager ( ) ; synchronized ( shaderManager ) { int nativeShader = shaderManager . getShader ( signature ) ; if ( nativeShader == 0 ) { nativeShader = addShader ( shaderManager , signature , material ) ; } return nativeShader ; } }
Select the specific vertex and fragment shader to use with this material .
108
13
148,447
public GVRSceneObject startDrag ( GVRSceneObject dragMe , float relX , float relY , float relZ ) { synchronized ( mLock ) { if ( mCursorController == null ) { Log . w ( TAG , "Physics drag failed: Cursor controller not found!" ) ; return null ; } if ( mDragMe != null ) { Log . w ( TAG , "Physics drag failed: Previous drag wasn't finished!" ) ; return null ; } if ( mPivotObject == null ) { mPivotObject = onCreatePivotObject ( mContext ) ; } mDragMe = dragMe ; GVRTransform t = dragMe . getTransform ( ) ; /* It is not possible to drag a rigid body directly, we need a pivot object. We are using the pivot object's position as pivot of the dragging's physics constraint. */ mPivotObject . getTransform ( ) . setPosition ( t . getPositionX ( ) + relX , t . getPositionY ( ) + relY , t . getPositionZ ( ) + relZ ) ; mCursorController . startDrag ( mPivotObject ) ; } return mPivotObject ; }
Start the drag of the pivot object .
252
8
148,448
public void setTexCoord ( String texName , String texCoordAttr , String shaderVarName ) { synchronized ( textures ) { GVRTexture tex = textures . get ( texName ) ; if ( tex != null ) { tex . setTexCoord ( texCoordAttr , shaderVarName ) ; } else { throw new UnsupportedOperationException ( "Texture must be set before updating texture coordinate information" ) ; } } }
Designate the vertex attribute and shader variable for the texture coordinates associated with the named texture .
93
18
148,449
public String getTexCoordAttr ( String texName ) { GVRTexture tex = textures . get ( texName ) ; if ( tex != null ) { return tex . getTexCoordAttr ( ) ; } return null ; }
Gets the name of the vertex attribute containing the texture coordinates for the named texture .
51
17
148,450
public String getTexCoordShaderVar ( String texName ) { GVRTexture tex = textures . get ( texName ) ; if ( tex != null ) { return tex . getTexCoordShaderVar ( ) ; } return null ; }
Gets the name of the shader variable to get the texture coordinates for the named texture .
53
18
148,451
public String getProperty ( String key , String defaultValue ) { return mProperties . getProperty ( key , defaultValue ) ; }
Gets a property with a default value .
28
9
148,452
public synchronized void hide ( ) { if ( focusedQuad != null ) { mDefocusAnimationFactory . create ( focusedQuad ) . setRequestLayoutOnTargetChange ( false ) . start ( ) . finish ( ) ; focusedQuad = null ; } Log . d ( Log . SUBSYSTEM . WIDGET , TAG , "hide Picker!" ) ; }
It should be called when the picker is hidden
79
10
148,453
public void set1Value ( int index , String newValue ) { try { value . set ( index , newValue ) ; } catch ( IndexOutOfBoundsException e ) { Log . e ( TAG , "X3D MFString set1Value(int index, ...) out of bounds." + e ) ; } catch ( Exception e ) { Log . e ( TAG , "X3D MFString set1Value(int index, ...) exception " + e ) ; } }
Replace a single value at the appropriate location in the existing value array .
103
15
148,454
public void setValue ( int numStrings , String [ ] newValues ) { value . clear ( ) ; if ( numStrings == newValues . length ) { for ( int i = 0 ; i < newValues . length ; i ++ ) { value . add ( newValues [ i ] ) ; } } else { Log . e ( TAG , "X3D MFString setValue() numStrings not equal total newValues" ) ; } }
Assign a new value to this field .
96
9
148,455
public void update ( int width , int height , byte [ ] grayscaleData ) { NativeBitmapImage . updateFromMemory ( getNative ( ) , width , height , grayscaleData ) ; }
Copy new grayscale data to the GPU texture . This one is also safe even in a non - GL thread . An updateGPU request on a non - GL thread will be forwarded to the GL thread and be executed before main rendering happens .
44
49
148,456
public static void start ( final GVRContext context , final String appId , final ResultListener listener ) { if ( null == listener ) { throw new IllegalArgumentException ( "listener cannot be null" ) ; } final Activity activity = context . getActivity ( ) ; final long result = create ( activity , appId ) ; if ( 0 != result ) { throw new IllegalStateException ( "Could not initialize the platform sdk; error code: " + result ) ; } context . registerDrawFrameListener ( new GVRDrawFrameListener ( ) { @ Override public void onDrawFrame ( float frameTime ) { final int result = processEntitlementCheckResponse ( ) ; if ( 0 != result ) { context . unregisterDrawFrameListener ( this ) ; final Runnable runnable ; if ( - 1 == result ) { runnable = new Runnable ( ) { @ Override public void run ( ) { listener . onFailure ( ) ; } } ; } else { runnable = new Runnable ( ) { @ Override public void run ( ) { listener . onSuccess ( ) ; } } ; } activity . runOnUiThread ( runnable ) ; } } } ) ; }
Starts asynchronous check . Result will be delivered to the listener on the main thread .
260
17
148,457
public synchronized void tick ( ) { long currentTime = GVRTime . getMilliTime ( ) ; long cutoffTime = currentTime - BUFFER_SECONDS * 1000 ; ListIterator < Long > it = mTimestamps . listIterator ( ) ; while ( it . hasNext ( ) ) { Long timestamp = it . next ( ) ; if ( timestamp < cutoffTime ) { it . remove ( ) ; } else { break ; } } mTimestamps . add ( currentTime ) ; mStatColumn . addValue ( ( ( float ) mTimestamps . size ( ) ) / BUFFER_SECONDS ) ; }
Should be called each frame .
136
6
148,458
public void addControllerType ( GVRControllerType controllerType ) { if ( cursorControllerTypes == null ) { cursorControllerTypes = new ArrayList < GVRControllerType > ( ) ; } else if ( cursorControllerTypes . contains ( controllerType ) ) { return ; } cursorControllerTypes . add ( controllerType ) ; }
Enable the use of the given controller type by adding it to the cursor controller types list .
68
18
148,459
public static void checkStringNotNullOrEmpty ( String parameterName , String value ) { if ( TextUtils . isEmpty ( value ) ) { throw Exceptions . IllegalArgument ( "Current input string %s is %s." , parameterName , value == null ? "null" : "empty" ) ; } }
Check that the parameter string is not null or empty
68
10
148,460
public static void checkArrayLength ( String parameterName , int actualLength , int expectedLength ) { if ( actualLength != expectedLength ) { throw Exceptions . IllegalArgument ( "Array %s should have %d elements, not %d" , parameterName , expectedLength , actualLength ) ; } }
Check that the parameter array has exactly the right number of elements .
64
13
148,461
public static void checkMinimumArrayLength ( String parameterName , int actualLength , int minimumLength ) { if ( actualLength < minimumLength ) { throw Exceptions . IllegalArgument ( "Array %s should have at least %d elements, but it only has %d" , parameterName , minimumLength , actualLength ) ; } }
Check that the parameter array has at least as many elements as it should .
70
15
148,462
public static void checkFloatNotNaNOrInfinity ( String parameterName , float data ) { if ( Float . isNaN ( data ) || Float . isInfinite ( data ) ) { throw Exceptions . IllegalArgument ( "%s should never be NaN or Infinite." , parameterName ) ; } }
In common shader cases NaN makes little sense . Correspondingly GVRF is going to use Float . NaN as illegal flag in many cases . Therefore we need a function to check if there is any setX that is using NaN as input .
66
51
148,463
public void transformPose ( Matrix4f trans ) { Bone bone = mBones [ 0 ] ; bone . LocalMatrix . set ( trans ) ; bone . WorldMatrix . set ( trans ) ; bone . Changed = WORLD_POS | WORLD_ROT ; mNeedSync = true ; sync ( ) ; }
Transform the root bone of the pose by the given matrix .
66
12
148,464
public void inverse ( GVRPose src ) { if ( getSkeleton ( ) != src . getSkeleton ( ) ) throw new IllegalArgumentException ( "GVRPose.copy: input pose is incompatible with this pose" ) ; src . sync ( ) ; int numbones = getNumBones ( ) ; Bone srcBone = src . mBones [ 0 ] ; Bone dstBone = mBones [ 0 ] ; mNeedSync = true ; srcBone . WorldMatrix . invertAffine ( dstBone . WorldMatrix ) ; srcBone . LocalMatrix . set ( dstBone . WorldMatrix ) ; if ( sDebug ) { Log . d ( "BONE" , "invert: %s %s" , mSkeleton . getBoneName ( 0 ) , dstBone . toString ( ) ) ; } for ( int i = 1 ; i < numbones ; ++ i ) { srcBone = src . mBones [ i ] ; dstBone = mBones [ i ] ; srcBone . WorldMatrix . invertAffine ( dstBone . WorldMatrix ) ; dstBone . Changed = WORLD_ROT | WORLD_POS ; if ( sDebug ) { Log . d ( "BONE" , "invert: %s %s" , mSkeleton . getBoneName ( i ) , dstBone . toString ( ) ) ; } } sync ( ) ; }
Makes this pose the inverse of the input pose .
300
11
148,465
protected void calcWorld ( Bone bone , int parentId ) { getWorldMatrix ( parentId , mTempMtxB ) ; // WorldMatrix (parent) TempMtxB mTempMtxB . mul ( bone . LocalMatrix ) ; // WorldMatrix = WorldMatrix(parent) * LocalMatrix bone . WorldMatrix . set ( mTempMtxB ) ; }
Calculates the world matrix based on the local matrix .
78
12
148,466
protected void calcLocal ( Bone bone , int parentId ) { if ( parentId < 0 ) { bone . LocalMatrix . set ( bone . WorldMatrix ) ; return ; } /* * WorldMatrix = WorldMatrix(parent) * LocalMatrix * LocalMatrix = INVERSE[ WorldMatrix(parent) ] * WorldMatrix */ getWorldMatrix ( parentId , mTempMtxA ) ; // WorldMatrix(par) mTempMtxA . invert ( ) ; // INVERSE[ WorldMatrix(parent) ] mTempMtxA . mul ( bone . WorldMatrix , bone . LocalMatrix ) ; // LocalMatrix = INVERSE[ WorldMatrix(parent) ] * WorldMatrix }
Calculates the local translation and rotation for a bone . Assumes WorldRot and WorldPos have been calculated for the bone .
147
26
148,467
public void setVec3 ( String key , float x , float y , float z ) { checkKeyIsUniform ( key ) ; NativeLight . setVec3 ( getNative ( ) , key , x , y , z ) ; }
Set the value for a floating point vector of length 3 .
52
12
148,468
public void setVec4 ( String key , float x , float y , float z , float w ) { checkKeyIsUniform ( key ) ; NativeLight . setVec4 ( getNative ( ) , key , x , y , z , w ) ; }
Set the value for a floating point vector of length 4 .
57
12
148,469
public void setMat4 ( String key , float x1 , float y1 , float z1 , float w1 , float x2 , float y2 , float z2 , float w2 , float x3 , float y3 , float z3 , float w3 , float x4 , float y4 , float z4 , float w4 ) { checkKeyIsUniform ( key ) ; NativeLight . setMat4 ( getNative ( ) , key , x1 , y1 , z1 , w1 , x2 , y2 , z2 , w2 , x3 , y3 , z3 , w3 , x4 , y4 , z4 , w4 ) ; }
Set the value for a floating point 4x4 matrix .
147
12
148,470
public void onDrawFrame ( float frameTime ) { if ( ! isEnabled ( ) || ( owner == null ) || ( getFloat ( "enabled" ) <= 0.0f ) ) { return ; } float [ ] odir = getVec3 ( "world_direction" ) ; float [ ] opos = getVec3 ( "world_position" ) ; GVRSceneObject parent = owner ; Matrix4f worldmtx = parent . getTransform ( ) . getModelMatrix4f ( ) ; mOldDir . x = odir [ 0 ] ; mOldDir . y = odir [ 1 ] ; mOldDir . z = odir [ 2 ] ; mOldPos . x = opos [ 0 ] ; mOldPos . y = opos [ 1 ] ; mOldPos . z = opos [ 2 ] ; mNewDir . x = 0.0f ; mNewDir . y = 0.0f ; mNewDir . z = - 1.0f ; worldmtx . getTranslation ( mNewPos ) ; worldmtx . mul ( mLightRot ) ; worldmtx . transformDirection ( mNewDir ) ; if ( ( mOldDir . x != mNewDir . x ) || ( mOldDir . y != mNewDir . y ) || ( mOldDir . z != mNewDir . z ) ) { setVec4 ( "world_direction" , mNewDir . x , mNewDir . y , mNewDir . z , 0 ) ; } if ( ( mOldPos . x != mNewPos . x ) || ( mOldPos . y != mNewPos . y ) || ( mOldPos . z != mNewPos . z ) ) { setPosition ( mNewPos . x , mNewPos . y , mNewPos . z ) ; } }
Updates the position and direction of this light from the transform of scene object that owns it .
398
19
148,471
public void setProjectionMatrix ( float x1 , float y1 , float z1 , float w1 , float x2 , float y2 , float z2 , float w2 , float x3 , float y3 , float z3 , float w3 , float x4 , float y4 , float z4 , float w4 ) { NativeCustomCamera . setProjectionMatrix ( getNative ( ) , x1 , y1 , z1 , w1 , x2 , y2 , z2 , w2 , x3 , y3 , z3 , w3 , x4 , y4 , z4 , w4 ) ; }
Set the custom projection matrix with individual matrix elements .
136
10
148,472
private void loadCadidateString ( ) { volumeUp = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . volume_up ) ; volumeDown = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . volume_down ) ; zoomIn = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . zoom_in ) ; zoomOut = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . zoom_out ) ; invertedColors = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . inverted_colors ) ; talkBack = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . talk_back ) ; disableTalkBack = mGvrContext . getActivity ( ) . getResources ( ) . getString ( R . string . disable_talk_back ) ; }
Load all string recognize .
226
5
148,473
public void findMatch ( ArrayList < String > speechResult ) { loadCadidateString ( ) ; for ( String matchCandidate : speechResult ) { Locale localeDefault = mGvrContext . getActivity ( ) . getResources ( ) . getConfiguration ( ) . locale ; if ( volumeUp . equals ( matchCandidate ) ) { startVolumeUp ( ) ; break ; } else if ( volumeDown . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { startVolumeDown ( ) ; break ; } else if ( zoomIn . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { startZoomIn ( ) ; break ; } else if ( zoomOut . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { startZoomOut ( ) ; break ; } else if ( invertedColors . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { startInvertedColors ( ) ; break ; } else if ( talkBack . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { enableTalkBack ( ) ; } else if ( disableTalkBack . toLowerCase ( localeDefault ) . equals ( matchCandidate . toLowerCase ( localeDefault ) ) ) { disableTalkBack ( ) ; } } }
get the result speech recognize and find match in strings file .
320
12
148,474
private void enableTalkBack ( ) { GVRSceneObject [ ] sceneObjects = mGvrContext . getMainScene ( ) . getWholeSceneObjects ( ) ; for ( GVRSceneObject sceneObject : sceneObjects ) { if ( sceneObject instanceof GVRAccessiblityObject ) if ( ( ( GVRAccessiblityObject ) sceneObject ) . getTalkBack ( ) != null ) ( ( GVRAccessiblityObject ) sceneObject ) . getTalkBack ( ) . setActive ( true ) ; } }
find all accessibility object and set active true for enable talk back .
118
13
148,475
private void disableTalkBack ( ) { GVRSceneObject [ ] sceneObjects = mGvrContext . getMainScene ( ) . getWholeSceneObjects ( ) ; for ( GVRSceneObject sceneObject : sceneObjects ) { if ( sceneObject instanceof GVRAccessiblityObject ) if ( ( ( GVRAccessiblityObject ) sceneObject ) . getTalkBack ( ) != null ) ( ( GVRAccessiblityObject ) sceneObject ) . getTalkBack ( ) . setActive ( false ) ; } }
find all accessibility object and set active false for enable talk back .
118
13
148,476
private void startInvertedColors ( ) { if ( managerFeatures . getInvertedColors ( ) . isInverted ( ) ) { managerFeatures . getInvertedColors ( ) . turnOff ( mGvrContext . getMainScene ( ) ) ; } else { managerFeatures . getInvertedColors ( ) . turnOn ( mGvrContext . getMainScene ( ) ) ; } }
Active inverter colors
87
4
148,477
public static void dumpTexCoords ( AiMesh mesh , int coords ) { if ( ! mesh . hasTexCoords ( coords ) ) { System . out . println ( "mesh has no texture coordinate set " + coords ) ; return ; } for ( int i = 0 ; i < mesh . getNumVertices ( ) ; i ++ ) { int numComponents = mesh . getNumUVComponents ( coords ) ; System . out . print ( "[" + mesh . getTexCoordU ( i , coords ) ) ; if ( numComponents > 1 ) { System . out . print ( ", " + mesh . getTexCoordV ( i , coords ) ) ; } if ( numComponents > 2 ) { System . out . print ( ", " + mesh . getTexCoordW ( i , coords ) ) ; } System . out . println ( "]" ) ; } }
Dumps a texture coordinate set of a mesh to stdout .
198
13
148,478
public static void dumpMaterialProperty ( AiMaterial . Property property ) { System . out . print ( property . getKey ( ) + " " + property . getSemantic ( ) + " " + property . getIndex ( ) + ": " ) ; Object data = property . getData ( ) ; if ( data instanceof ByteBuffer ) { ByteBuffer buf = ( ByteBuffer ) data ; for ( int i = 0 ; i < buf . capacity ( ) ; i ++ ) { System . out . print ( Integer . toHexString ( buf . get ( i ) & 0xFF ) + " " ) ; } System . out . println ( ) ; } else { System . out . println ( data . toString ( ) ) ; } }
Dumps a single material property to stdout .
158
10
148,479
public static void dumpMaterial ( AiMaterial material ) { for ( AiMaterial . Property prop : material . getProperties ( ) ) { dumpMaterialProperty ( prop ) ; } }
Dumps all properties of a material to stdout .
37
11
148,480
public static void dumpNodeAnim ( AiNodeAnim nodeAnim ) { for ( int i = 0 ; i < nodeAnim . getNumPosKeys ( ) ; i ++ ) { System . out . println ( i + ": " + nodeAnim . getPosKeyTime ( i ) + " ticks, " + nodeAnim . getPosKeyVector ( i , Jassimp . BUILTIN ) ) ; } }
Dumps an animation channel to stdout .
88
9
148,481
public static String joinStrings ( List < String > strings , boolean fixCase , char withChar ) { if ( strings == null || strings . size ( ) == 0 ) { return "" ; } StringBuilder result = null ; for ( String s : strings ) { if ( fixCase ) { s = fixCase ( s ) ; } if ( result == null ) { result = new StringBuilder ( s ) ; } else { result . append ( withChar ) ; result . append ( s ) ; } } return result . toString ( ) ; }
Generic string joining function .
115
5
148,482
public int addCollidable ( GVRSceneObject sceneObj ) { synchronized ( mCollidables ) { int index = mCollidables . indexOf ( sceneObj ) ; if ( index >= 0 ) { return index ; } mCollidables . add ( sceneObj ) ; return mCollidables . size ( ) - 1 ; } }
Adds another scene object to pick against . Each frame all the colliders in the scene will be compared against the bounding volumes of all the collidables associated with this picker .
73
37
148,483
public static GVRCameraRig makeInstance ( GVRContext gvrContext ) { final GVRCameraRig result = gvrContext . getApplication ( ) . getDelegate ( ) . makeCameraRig ( gvrContext ) ; result . init ( gvrContext ) ; return result ; }
Constructs a camera rig with cameras attached . An owner scene object is automatically created for the camera rig .
66
21
148,484
public void removeAllChildren ( ) { for ( final GVRSceneObject so : headTransformObject . getChildren ( ) ) { final boolean notCamera = ( so != leftCameraObject && so != rightCameraObject && so != centerCameraObject ) ; if ( notCamera ) { headTransformObject . removeChildObject ( so ) ; } } }
Remove all children that have been added to the owner object of this camera rig ; except the camera objects .
72
21
148,485
public void setNearClippingDistance ( float near ) { if ( leftCamera instanceof GVRCameraClippingDistanceInterface && centerCamera instanceof GVRCameraClippingDistanceInterface && rightCamera instanceof GVRCameraClippingDistanceInterface ) { ( ( GVRCameraClippingDistanceInterface ) leftCamera ) . setNearClippingDistance ( near ) ; centerCamera . setNearClippingDistance ( near ) ; ( ( GVRCameraClippingDistanceInterface ) rightCamera ) . setNearClippingDistance ( near ) ; } }
Sets the distance from the origin to the near clipping plane for the whole camera rig .
116
18
148,486
public void setFarClippingDistance ( float far ) { if ( leftCamera instanceof GVRCameraClippingDistanceInterface && centerCamera instanceof GVRCameraClippingDistanceInterface && rightCamera instanceof GVRCameraClippingDistanceInterface ) { ( ( GVRCameraClippingDistanceInterface ) leftCamera ) . setFarClippingDistance ( far ) ; centerCamera . setFarClippingDistance ( far ) ; ( ( GVRCameraClippingDistanceInterface ) rightCamera ) . setFarClippingDistance ( far ) ; } }
Sets the distance from the origin to the far clipping plane for the whole camera rig .
116
18
148,487
public static String readTextFile ( File file ) { try { return readTextFile ( new FileReader ( file ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; return null ; } }
Read a text file into a single string
50
8
148,488
public static String readTextFile ( Context context , int resourceId ) { InputStream inputStream = context . getResources ( ) . openRawResource ( resourceId ) ; return readTextFile ( inputStream ) ; }
Read a text file resource into a single string
45
9
148,489
public static String readTextFile ( InputStream inputStream ) { InputStreamReader streamReader = new InputStreamReader ( inputStream ) ; return readTextFile ( streamReader ) ; }
Read a text stream into a single string .
38
9
148,490
private static Future < ? > spawn ( final int priority , final Runnable threadProc ) { return threadPool . submit ( new Runnable ( ) { @ Override public void run ( ) { Thread current = Thread . currentThread ( ) ; int defaultPriority = current . getPriority ( ) ; try { current . setPriority ( priority ) ; /* * We yield to give the foreground process a chance to run. * This also means that the new priority takes effect RIGHT * AWAY, not after the next blocking call or quantum * timeout. */ Thread . yield ( ) ; try { threadProc . run ( ) ; } catch ( Exception e ) { logException ( TAG , e ) ; } } finally { current . setPriority ( defaultPriority ) ; } } } ) ; }
Execute a Runnable on a thread pool thread
170
11
148,491
public static void assertUnlocked ( Object object , String name ) { if ( RUNTIME_ASSERTIONS ) { if ( Thread . holdsLock ( object ) ) { throw new RuntimeAssertion ( "Recursive lock of %s" , name ) ; } } }
This is an assertion method that can be used by a thread to confirm that the thread isn t already holding lock for an object before acquiring a lock
57
29
148,492
public void enableUniformSize ( final boolean enable ) { if ( mUniformSize != enable ) { mUniformSize = enable ; if ( mContainer != null ) { mContainer . onLayoutChanged ( this ) ; } } }
When set to true all items in layout will be considered having the size of the largest child . If false all items are measured normally . Disabled by default .
50
31
148,493
public void setDividerPadding ( float padding , final Axis axis ) { if ( axis == getOrientationAxis ( ) ) { super . setDividerPadding ( padding , axis ) ; } else { Log . w ( TAG , "Cannot apply divider padding for wrong axis [%s], orientation = %s" , axis , getOrientation ( ) ) ; } }
Sets divider padding for axis . If axis does not match the orientation it has no effect .
84
20
148,494
protected boolean isValidLayout ( Gravity gravity , Orientation orientation ) { boolean isValid = true ; switch ( gravity ) { case TOP : case BOTTOM : isValid = ( ! isUnlimitedSize ( ) && orientation == Orientation . VERTICAL ) ; break ; case LEFT : case RIGHT : isValid = ( ! isUnlimitedSize ( ) && orientation == Orientation . HORIZONTAL ) ; break ; case FRONT : case BACK : isValid = ( ! isUnlimitedSize ( ) && orientation == Orientation . STACK ) ; break ; case FILL : isValid = ! isUnlimitedSize ( ) ; break ; case CENTER : break ; default : isValid = false ; break ; } if ( ! isValid ) { Log . w ( TAG , "Cannot set the gravity %s and orientation %s - " + "due to unlimited bounds or incompatibility" , gravity , orientation ) ; } return isValid ; }
Check if the gravity and orientation are not in conflict one with other .
201
14
148,495
protected float getLayoutOffset ( ) { //final int offsetSign = getOffsetSign(); final float axisSize = getViewPortSize ( getOrientationAxis ( ) ) ; float layoutOffset = - axisSize / 2 ; Log . d ( LAYOUT , TAG , "getLayoutOffset(): dimension: %5.2f, layoutOffset: %5.2f" , axisSize , layoutOffset ) ; return layoutOffset ; }
Calculate the layout offset
93
6
148,496
protected float getStartingOffset ( final float totalSize ) { final float axisSize = getViewPortSize ( getOrientationAxis ( ) ) ; float startingOffset = 0 ; switch ( getGravityInternal ( ) ) { case LEFT : case FILL : case TOP : case FRONT : startingOffset = - axisSize / 2 ; break ; case RIGHT : case BOTTOM : case BACK : startingOffset = ( axisSize / 2 - totalSize ) ; break ; case CENTER : startingOffset = - totalSize / 2 ; break ; default : Log . w ( TAG , "Cannot calculate starting offset: " + "gravity %s is not supported!" , mGravity ) ; break ; } Log . d ( LAYOUT , TAG , "getStartingOffset(): totalSize: %5.4f, dimension: %5.4f, startingOffset: %5.4f" , totalSize , axisSize , startingOffset ) ; return startingOffset ; }
Calculate the starting content offset based on the layout orientation and Gravity
206
14
148,497
@ Override protected boolean changeDirection ( int currentIndex , int centerIndex , boolean inBounds ) { boolean changed = false ; if ( getGravityInternal ( ) == Gravity . CENTER && currentIndex <= centerIndex && currentIndex == 0 || ! inBounds ) { changed = true ; } return changed ; }
<<<<<< measureUntilFull helper methods
68
8
148,498
protected int getCenterChild ( CacheDataSet cache ) { if ( cache . count ( ) == 0 ) return - 1 ; int id = cache . getId ( 0 ) ; switch ( getGravityInternal ( ) ) { case TOP : case LEFT : case FRONT : case FILL : break ; case BOTTOM : case RIGHT : case BACK : id = cache . getId ( cache . count ( ) - 1 ) ; break ; case CENTER : int i = cache . count ( ) / 2 ; while ( i < cache . count ( ) && i >= 0 ) { id = cache . getId ( i ) ; if ( cache . getStartDataOffset ( id ) <= 0 ) { if ( cache . getEndDataOffset ( id ) >= 0 ) { break ; } else { i ++ ; } } else { i -- ; } } break ; default : break ; } Log . d ( LAYOUT , TAG , "getCenterChild = %d " , id ) ; return id ; }
>>>>>> measureUntilFull helper methods
213
7
148,499
protected boolean computeOffset ( final int dataIndex , CacheDataSet cache ) { float layoutOffset = getLayoutOffset ( ) ; int pos = cache . getPos ( dataIndex ) ; float startDataOffset = Float . NaN ; float endDataOffset = Float . NaN ; if ( pos > 0 ) { int id = cache . getId ( pos - 1 ) ; if ( id != - 1 ) { startDataOffset = cache . getEndDataOffset ( id ) ; if ( ! Float . isNaN ( startDataOffset ) ) { endDataOffset = cache . setDataAfter ( dataIndex , startDataOffset ) ; } } } else if ( pos == 0 ) { int id = cache . getId ( pos + 1 ) ; if ( id != - 1 ) { endDataOffset = cache . getStartDataOffset ( id ) ; if ( ! Float . isNaN ( endDataOffset ) ) { startDataOffset = cache . setDataBefore ( dataIndex , endDataOffset ) ; } } else { startDataOffset = getStartingOffset ( ( cache . getTotalSizeWithPadding ( ) ) ) ; endDataOffset = cache . setDataAfter ( dataIndex , startDataOffset ) ; } } Log . d ( LAYOUT , TAG , "computeOffset [%d, %d]: startDataOffset = %f endDataOffset = %f" , dataIndex , pos , startDataOffset , endDataOffset ) ; boolean inBounds = ! Float . isNaN ( cache . getDataOffset ( dataIndex ) ) && endDataOffset > layoutOffset && startDataOffset < - layoutOffset ; return inBounds ; }
Compute the offset for the item in the layout cache
351
11