How to apply texture (image) to an AIS object

I am attempting to apply a texture to the bottle in the tutorial located in $OPENCASCADEROOT/samples/qt/Tutorial.

// Here the AIS_shape is created.
DocumentTut.cxx:26: Handle(AIS_Shape) AISBottle=new AIS_Shape(aBottle);

I assume I'll have to grab a reference to the shape somehow, somewhere...

For inspiration, I'm going to look at how the buttons in the example toggle the surface from shaded display to wireframe display.

I've taken a look at Doxygen documentation and I found some texture stuff, in particular, the class OpenGl_Texture.

So, I will need to get a reference to AISBottle, create an OpenGl_Texture object, and somehow put these together. Am I on the right path?

I know there are also lower level ways to access presentable/selectable objects, this isn't one of the cases where I need to do that is it?

Nageswara Rao Dasari's picture

Hi Adam !

    Even I have to implement same functionality in my project.Can you please let me know if you find the solution.

Regards

Forum supervisor's picture

Dear Adam,

The simplest way to attach texture to the shape is to use AIS_TexturedShape presentation object instead of AIS_Shape.
MFC samples (see $(CASROOT)\samples\mfc\) provides a code sample for using it (the appropriate Draw Harness command is vtexture),
but I think the documentation of this and related class should be sufficient to understand how to use it.
OpenGl_Texture is a low-level texture management class, you don't have to know it for using textures.
Best regards
FSR