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