Reputation: 292
The following is my code for building a 3D Earth and showing it:
com.google.ar.sceneform.rendering.Texture.Builder builder= com.google.ar.sceneform.rendering.Texture.builder();
builder.setSource(context,R.drawable.earth);
builder.build().thenAccept(texture ->
MaterialFactory.makeOpaqueWithTexture(context, texture).
thenAccept(material -> {
earthSphereRenderable =
ShapeFactory.makeSphere(0.1f, new Vector3(0.0f, 0.0f, 0.0f), material);
Toast.makeText(context,"All done",Toast.LENGTH_SHORT).show();})
);
The Toast message is coming but I am not able to see any object. Please note that R.drawable.earth is the Earth.jpg file that I put in there, which I want to show in AR.
Here is where I am rendering it
cornerNode = new Node();
cornerNode.setParent(this);
cornerNode.setLocalPosition(localPosition);
cornerNode.setRenderable(earthSphereRenderable);
Moreover, if I replace makeOpaqueWithTexture with makeOpaqueWithColor and but color as Red then the whole thing is working fine (i.e. I can see the sphere)
What must I change here in order to be able to see the sphere with Earth's texture on it?
Upvotes: 2
Views: 1932
Reputation: 58503
At this time Google Sceneform 1.8
supports 3D assets in the following formats: .obj
, .glTF
for which animations not supported) and .fbx
with or without animations. Supported textures' formats are: .mtl
, .bin
, .png
and .jpg
.
Verify that your project's app folder contains a sampledata folder. To create the folder, right-click on the app folder in the Project window, then select New
> Sample Data Directory
.
The sampledata folder is part of your Android Studio project, but its contents will not be included in your APK. Copy your 3D model source asset file (.obj
, .fbx
, or .gltf
), and all of its dependencies in any of the following formats:
.mtl
.bin
.png
.jpg
into the sampledata folder.
Do not copy these source files into your project's assets or
res
folder, as this will cause them to be included in your APK unnecessarily. Right click the 3D model source asset and selectImport Sceneform Asset
to begin the import process.
The values are used by the sceneform.asset()
entry in the app's build.gradle
, and determine where the .sfa
and .sfb
– ascii and binary asset definition – files (as well as their corresponding texture files .sfm
) will be generated in your project. If you're importing a model for the first time, use the default values.
Hope this helps.
Upvotes: 1
Reputation: 292
Ok, I got the answer to this. It does not accept jpg files but it accepts png files. Weird stuff!
Upvotes: 0