OpenCASCADE 7.1.0 AIS_TexturedShape has no texture

Hello,

I want to display a textured shape. The program doesn't crash, but the shapes are plain. I can change color, material, transparency, etc., but no textures.

I found in other forum posts that I have to call SetSurfaceDetail(V3d_TEX_ALL) from my V3d_Viewer.

However, this was deleted in OpenCASCADE 7.1.0.

I know that my BMP file exists, and I also tried using "1" in SetTextureFileName, but still nothing happens

Any ideas what might be wrong or what should I try?

Here's my code:


void UMAT_MainDoc::displayShape(Handle(AIS_Shape) shape, const Quantity_Color col, const Standard_Real transparency /*= 0.0*/)

{

Handle(AIS_TexturedShape) occ_aisTextured = new AIS_TexturedShape(shape->Shape());



TCollection_AsciiString fileName("C:\\Users\\serban.stoenescu\\Pictures\\bitmap.bmp");

//TCollection_AsciiString fileName("1");



occ_aisTextured->SetTextureFileName(fileName);

occ_aisTextured->SetTextureMapOn();

int nRepeat = 2;

double toScale = 0.5;

occ_aisTextured->SetTextureRepeat(Standard_True, nRepeat, nRepeat);

occ_aisTextured->SetTextureScale(Standard_True, toScale, toScale);

occ_aisTextured->SetTextureOrigin(Standard_True, 0, 0);

//occ_aisTextured->DisableTextureModulate();

occ_aisTextured->SetDisplayMode(3); // mode 3 is "textured" mode



occ_aisTextured->SetMaterial(Graphic3d_NOM_SILVER);



m_hAISContext->SetDisplayMode(occ_aisTextured, 3);

//m_hAISContext->Display(occ_aisTextured, 3,-1);

m_hAISContext->Display(occ_aisTextured);

m_hAISContext->UpdateCurrentViewer();

occ_aisTextured->UpdateAttributes();



}

 

anshi wang's picture

I have the same problem, have you resoved?  

florian_149749's picture

Hello,

I'm very interested in this solution as well, since I have the same problem!
I just created a Box and wanted to texture it. The texture is loaded, because I save it to another folder to check this.

TopoDS_Shape aTopoBox = BRepPrimAPI_MakeBox(3.0, 4.0, 5.0);
  Handle(AIS_TexturedShape) anAisBox = new AIS_TexturedShape(aTopoBox);
  Handle(Image_AlienPixMap) pixMap = new Image_AlienPixMap;
  pixMap->Load("D:/testimage.png");
  pixMap->Save("test.png");
  anAisBox->SetTexturePixMap(pixMap);
  anAisBox->SetTextureMapOn();
  anAisBox->SetDisplayMode(3);
  anAisBox->SetTextureRepeat(true, 1.0, 1.0);
  anAisBox->DisableTextureModulate();
  m_aisContext->Display(anAisBox, Standard_True);

Does anybody know, what I'm doing wrong here?

w d's picture

SOS! I meet the same problem ,have you found the solution?Could you share it?TKS.

Frank Martinez's picture

This code is working for me:

        Handle(AIS_TexturedShape) textured = new AIS_TexturedShape(shape);
        textured->SetTextureFileName("/...../texture.jpg");
        textured->SetTextureMapOn();
        textured->SetTextureRepeat(true, 1.0, 1.0);
        textured->DisableTextureModulate();
        textured->SetDisplayMode(3);

But I have another problem: The texture is applied to each face independently. Does anyone know how to map the texture to the whole solid?

screenshot: https://old.opencascade.com/system/files/forum/screenshot_29.png

Attachments: