DiscussionsIssue archiveVisualization and 3D Viewer

Archived discussion

How to apply texture (image) to an AIS object

Visualization and 3D ViewerThu, 05/07/2015 - 23:502 replies

Browse this forum
QuestionAuthor

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?

Discussion

2 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hi Author !

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

Regards

02Commenter-2

Dear Author,

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