Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing sceneform asset does not generate .sfa and .sfb files

When i'm trying to import sceneform assets and press finish on the window that pops up,nothing happens.No .sfa, .sfb files are generated.Nothing is generated in the build.gradle file also.I have to mention that i imported sceneform assets in the same project before and everything worked fine,but now (after a while) when i'm trying to do it again it doesn't work.

like image 714
Tiberiu Paduraru Avatar asked Jun 01 '20 00:06

Tiberiu Paduraru


People also ask

What is .SFA file?

The Sceneform Asset Definition ( *. sfa ) file is a human-readable description of the Sceneform Binary asset ( *. sfb ). It points to the models, material definitions, and textures in your source asset and also provides material parameters for Sceneform's physically-based materials.

What is a SFA file in sceneform?

The Sceneform Asset Definition ( *.sfa) file is a human-readable description of the Sceneform Binary asset ( *.sfb ). It points to the models, material definitions, and textures in your source asset and also provides material parameters for Sceneform’s physically-based materials.

How do I import a 3D model in sceneform?

The values are used by the sceneform.asset () entry in the app's build.gradle, and determine where the *.sfa and *.sfb files will be generated in your project. If you're importing a model for the first time, use the default values. Filename of the OBJ, FBX, or glTF 3D model asset to import.

How do I import a sceneform file to Android?

Go to Android Preferences > Plugins and search for "Google Sceneform Tools (Beta)" Clicking with the right button on the .obj you can select "Import Sceneform Asset" This will create the .sfb and .sfa file, already ready to use.

What is the default path to import material in sceneform?

Filename of the OBJ, FBX, or glTF 3D model asset to import. default tells Sceneform's to use the built-in default material or the path to a custom material *.mat file. Use the default, or specify another path under the sampledata folder.


2 Answers

From https://developers.google.com/sceneform/develop/

enter image description here

Considering 1.15 and 1.17.1 identical, and these issues

  • https://github.com/google-ar/sceneform-android-sdk/issues/1078
  • https://github.com/google-ar/sceneform-android-sdk/issues/989
  • https://github.com/google-ar/sceneform-android-sdk/issues/912

It looks like it's no longer in development and they are not going to fix it. It is problem with android studio version 3.6 and later.


There is no solution, either you can rollback to Android studio 3.5, or you can use a quick workaround.

  1. Create a new sampledata directory in your application.

    Right-click on top app level directory > New > Sample Data Directory

  2. place your 3D assets and its dependencies (obj, mtl, fbx, png) into sampledata directory.

  3. Add classpath 'com.google.ar.sceneform:plugin:1.15.0' to your project level gradle. make sure you have google() in repositories.

    // Top-level build file where you can add configuration options. common to all sub-projects/modules
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
             classpath "com.android.tools.build:gradle:4.0.1"
             classpath 'com.google.ar.sceneform:plugin:1.15.0'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
         }
    }
    
  4. sceneform requires a specific version of NDK and Java. And you need to apply plugin and dependencies since it will not be automatically added in recent versions of the android studio. apply plugin: 'com.android.application' apply plugin: 'com.google.ar.sceneform.plugin'

     android {
         ...
    
         defaultConfig {
             ...
    
             ndk {
                 /*
                 * Sceneform is available for the following ABIs: arm64-v8a, armv7a,
                 * x86_64 and x86. This sample app enables arm64-v8a to run on
                 * devices and x86 to run on the emulator. Your application should
                 * list the ABIs most appropriate to minimize APK size (arm64-v8a recommended).
                 */
                 abiFilters 'arm64-v8a', 'x86'
             }
             compileOptions {
                 sourceCompatibility JavaVersion.VERSION_1_8
                 targetCompatibility JavaVersion.VERSION_1_8
             }
         }
    
         buildTypes {
             ...
         }
     }
    
     dependencies {
         ...
         implementation 'com.google.ar.sceneform:core:1.15.0'
     }
    
     < sceneform.asset code - 7th step >
    
  5. I have added Mars 3D asset from Poly to my sampledata. Directory structure will look something like enter image description here

  6. Add raw data directory to resources.
    Right-click on res > New > folder > Raw resources folder.

  7. Add this to the end of app-level gradle file.

     sceneform.asset('sampledata/mars.obj', // 'Source Asset Path' specified during import.
         'default',                         // 'Material Path' specified during import.
         'sampledata/mars.sfa',             // '.sfa Output Path' specified during import.
         'src/main/res/raw/mars')
    
  8. Sync files and it should work now.

Sceneform has Deprecates support for SFB & the SFB Sceneform Android Studio plugin (glTF can be used instead) - Release Notes

The documentation is available for sceneform 1.15.0 only -- which does not include glTF workflow. You can check out this demo for working with glTF.

like image 166
Aniket Kariya Avatar answered Oct 19 '22 07:10

Aniket Kariya


I had the same problem, I noticed that you can do this without the plug-in by adding your model with sceneform.asset(...) in build.gradle and building the project, related .sfa and .sfb files are then created.

like image 37
Jouni Peltonen Avatar answered Oct 19 '22 09:10

Jouni Peltonen