Can I change the material properties of AIS_TexturedShape?

Can I change the material properties of AIS_TexturedShape?

I have a set of shapes that need to be textured and when i use AIS_Textured shape and

AIS_InteractiveContext->SetDisplayMode(aShape,3);

The material is always the default gold shiny one. Even though i set the colour and material after. I've tried setting the colour with the AIS_Context and the AIS_Shape methods but it doesnt seem to work. Can anyone help?

Do you try to use the method AIS_Shape::SetMaterial() ?

...
aTexturedShape->SetMaterial(Graphic3d_NOM_PLASTIC);
...

Henry Durrant's picture

Yes, here is the code at the moment - i have tried using the AIS_InteractiveContext and AIS_Shape methods for amterial and colour.

Handle(AIS_TexturedShape) aShape = new AIS_TexturedShape(shape);

myAISContext->SetDisplayMode(aShape,3);

aShape->SetTextureFileName("textures/tex.bmp");
aShape->SetTextureMapOn();
aShape->SetColor(info.color);
aShape->SetMaterial(Graphic3d_NOM_PLASTIC);

//myAISContext->SetColor(aShape,info.color);
//myAISContext->SetMaterial(aShape,Graphic3d_NOM_PLASTIC);

myAISContext->Display(aShape);//myAISContext->Display(aShape);

try this :

...
aShape->SetDisplayMode(3);
...

use this instruction

...
myAISContext->Display(aShape, 3, -1);
...

instead of

myAISContext->Display(aShape);

Henry Durrant's picture

Thanks, i tried it but it still wont accept differernt colours or materials. Its only on display mode 3 that this happens. (AIS_ExactHLR)

You can directly modify the object Graphic3d_MaterialAspect with the inherited method SetMaterial() of AIS_InteractiveObject.

Good luck !

viviana's picture

Hi, Henry

I have a bigger problem, I can't display the image that I put like texture, Did you solve your problem? ...Can you give me some hints so I can solve mine? Here is my code...

Handle(AIS_InteractiveContext) aContext;
Standard_Integer aWidth=100,aHeight=100;
Handle(Image_Image) anImage;
if (AlienImage::LoadImageFile("/home/viviana/Modulos.bak/Logo.bmp",anImage,aWidth,aHeight))
{
TopoDS_Shape aFace= BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0,0,0),gp_Dir(0,0,1)),0,Standard_Real(aWidth),0,Standard_Real(aHeight));
Handle(AIS_TexturedShape) aTextShape=new AIS_TexturedShape(aFace);
aTextShape->SetTextureFileName("/home/viviana/Modulos.bak/Logo.bmp");
aTextShape->SetTextureMapOn();
//aTextShape->SetDisplayMode(3);
aContext->SetDisplayMode(aTextShape,3);
aContext->SetMaterial(aTextShape,Graphic3d_NOM_SATIN);
//aContext->Display(aTextShape,Standard_False);
aContext->Display(aTextShape);
aContext->UpdateCurrentViewer();
}

Thanks for your help.

Viviana

Vikas Tayal's picture

Hi Vivina,

Would you please tell me the solution?
I m also trying the same as you have done above.. but not getting success...

Thanks in advance...

Vikas

viviana's picture

I have already solved the problem, thanks anyway!