问题
I am creating an app where I need to change textures(pattern) of my 3d object. I am using AR Core SDK and android. I have used the below code but it is not working.
Texture.builder()
.setSource(this,R.drawable.fabric3)
.build()
.thenAccept(t -> {
BaseTransformableNode node =
arFragment.getTransformationSystem().getSelectedNode();
if(node!=null){
node.getRenderable().getMaterial().setTexture("baseColorMap",t);
}
});
Documentation is also not helping me much. This is my SFA file
{
animations: [
{
clips: [
{
name: 'Take 001',
runtime_name: 'cylinder',
},
],
path: 'sampledata/models/cylinder.fbx',
},
],
materials: [
{
name: 'Blue',
parameters: [
{
baseColor: [
1,
1,
1,
1,
],
},
{
baseColorMap: 'fabric2',
},
{
normalMap: null,
},
{
interpolatedColor: null,
},
{
metallic: 0,
},
{
metallicMap: null,
},
{
roughness: 1,
},
{
roughnessMap: null,
},
{
opacity: null,
},
],
source: 'build/sceneform_sdk/default_materials/fbx_material.sfm',
},
{
name: 'Black',
parameters: [
{
baseColor: [
1,
1,
1,
1,
],
},
{
baseColorMap: 'fabric3',
},
{
normalMap: null,
},
{
interpolatedColor: null,
},
{
metallic: 0,
},
{
metallicMap: null,
},
{
roughness: 1,
},
{
roughnessMap: null,
},
{
opacity: null,
},
],
source: 'build/sceneform_sdk/default_materials/fbx_material.sfm',
},
],
model: {
attributes: [
'Position',
'TexCoord',
'Orientation',
'BoneIndices',
'BoneWeights',
],
collision: {},
file: 'sampledata/models/cylinder.fbx',
name: 'cylinder',
recenter: 'root',
},
samplers: [
{
file: 'sampledata/models\\cylinder.fbm\\fabric2.jpg',
name: 'fabric2',
pipeline_name: 'cylinder.fbm\\fabric2.jpg',
},
{
file: 'sampledata/models\\cylinder.fbm\\fabric3.jpg',
name: 'fabric3',
pipeline_name: 'cylinder.fbm\\fabric3.jpg',
},
],
version: '0.54:2',
}
I have 2 textures fabric 2 and 3 i want to change texture from fabric 2 to fabric 3 when a button is clicked. I am using .fbx files for my 3d models.
来源:https://stackoverflow.com/questions/59389203/changing-textures-of-object-in-ar-core-in-runtime