3dgeometrytexturesmetaio

Metaio Change Geometry Texture


I have tried to load a 3D model with its texture in metaio sdk. But now i have a new challenge:
Suppose that i have a 3D car model, i want to load it in Metaio sdk and change color of the car when user taps the screen. How can do that? In general, what is the relationship between a 3d model and its texture? Can we have a single 3d model and multiple textures for it, and bind them at runtime? How?

Thanks.


Solution

  • yes you can have multiple texture by using setTexture of the IGeometry object.

    Depending on the type of the model you are using the texture can be stored in the model itself or in a file with the same name. When I tried multiple texture stored in a MDL file it didn't worked and I had to store them separately.

    your code would be something like this:

    @Override
    protected void onGeometryTouched(IGeometry geometry) {
        MetaioDebug.log("Template.onGeometryTouched: " + geometry);
    
        geometry.setTexture(AssetsManager.getAssetPathAsFile(getApplicationContext(), "mytexture.png"));
    }
    

    to handle the touch if you don't already have you should register a gesture handler:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        //other init code here...
    
        mGestureMask = GestureHandler.GESTURE_ALL;
        mGestureHandler = new GestureHandlerAndroid(metaioSDK, mGestureMask);
    }