我正在创建一个应用程序,我需要在其中更改 3d 对象的纹理(图案)。我正在使用 AR Core SDK 和 android。我已经使用了下面的代码,但它不起作用。
Texture.builder()
.setSource(this,R.drawable.fabric3)
.build()
.thenAccept(t -> {
BaseTransformableNode node =
arFragment.getTransformationSystem().getSelectedNode();
if(node!=null){
node.getRenderable().getMaterial().setTexture("baseColorMap",t);
}
});
文档也对我没有多大帮助。
这是我的 SFA 文件
{
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',
}
我有 2 个纹理织物 2 和 3,我想在单击按钮时将纹理从织物 2 更改为织物 3。
我正在为我的 3d 模型使用 .fbx 文件。