I don't manage texturization

Hello

please, maybe someone could help me: I'd like to texturize a simple face with a bitmap but my code don't do it.

My code:

Handle_Geom_Surface masurf;
TopoDS_Shape aShapetopo = BRepBuilderAPI_MakeFace(masurf);

TopTools_IndexedMapOfShape aFaces;
TopExp::MapShapes(aShapetopo, TopAbs_FACE, aFaces);

Handle_AIS_Shape aShapeIO = drawShape(aShapetopo, Graphic3d_NOM_BRASS, Standard_False);
GetAISContext()->SetDisplayMode(aShapeIO, AIS_Shaded, Standard_False);

GetAISContext()->Display(aShapeIO, Standard_False);

Handle_AIS_TexturedShape aTFace1 = Texturize(aFaces(1), "InterferenceintradoT4.bmp", 1, 1, 3, 2,0,0);
GetAISContext()->Display(aTFace1, Standard_False);

GetViewer()->Update();

Handle_AIS_TexturedShape CAISSelectDoc::Texturize
( const TopoDS_Shape& aShape,
TCollection_AsciiString aTFileName,
Standard_Real toScaleU,
Standard_Real toScaleV,
Standard_Real toRepeatU,
Standard_Real toRepeatV,
Standard_Real originU,
Standard_Real originV)
{

Handle_AIS_TexturedShape aTShape = new AIS_TexturedShape(aShape);

aTShape->SetTextureFileName(aTFileName);
aTShape->SetTextureMapOn();
aTShape->SetTextureScale(Standard_True, toScaleU, toScaleV);
aTShape->SetTextureRepeat(Standard_True, toRepeatU, toRepeatV);
aTShape->SetTextureOrigin(Standard_True, originU, originV);

aTShape->SetDisplayMode(3);

return aTShape;
}

Roman Lygin's picture

Hi Manu,

Make sure your initialize texture use in your 3D view calling V3d_View::SetSurfaceDetail(V3d_TEX_ALL). Have a look at TexturedShapes shapes supplied with OCC on Windows.

Hope this helps.
Roman

MANU's picture

Thank you very much Roman Lygin

My face is now texturized, but I have another trouble:

There remain orange colour behind the picture i have mapped on the face . I've tried many things to avoid it, but I don't manage to change the face background color when it is textured, or to reduce the transparency aspect (white pixels of my picture appear in orange). Beside, I notice that this aspect is present in the mfc sample ( Textured shapes ) .

Do you know a way I can walk to solve my problem ?

Roman Lygin's picture

Hello Manu,

Frankly, I didn't understand the point here. Perhaps a screenshot would help or tell me what to do in the TexturedShapes sample.
Roman

MANU's picture

I apologize for my poor speaking english.

How can I send you my screenshots ?

my mail: manu56manu@yahoo.fr

Roman Lygin's picture

Hi Manu, I sent you an email from my private address.
Roman

Roman Lygin's picture

Hi Manu,

I decided to post the answer here to let other community members benefit. First, the context: textures over shapes look quite different from original graphical images (most noticable - yellow hue).

The problem you describe is not that the color gets transparent. It's linked with light reflection on textured shapes. If you take the Textured Shapes example and open a sample with a kitchen furniture (most representative one) then rotate, or apply top/left/right view, then you will notice that image's color gets closer to its native one when being perpendicular to the eye direction.

The cause is that texture is mapped on a shape using Brass material (default one for OCC shapes - you may remember their yellow hue). In order to ensure more natural color you would need to apply another material but AIS_TexturedShape has a limitation (or a bug ?) ignoring associated material and always using brass inside.

On my own I created a custom class taking the materials into account. You should also be able to accomplish that, e.g. subclassing AIS_TexturedShape and redefining Compute() method (you might want to use AIS_TexturedShape::Compute(), Prs3d_ShadedShape::Add() as references).

Hope this helps you.
Roman

Patrik Mueller's picture

Hi Roman,

good to see you so active at the forum (and nicer to hear from you again). I have a similar problem doing environment mapping and posted the question already to this forum. Could you give me a hint?

Greets,

Patrik

Roman Lygin's picture

Hi Patrik,

Please repeat your post or link to it (URL), as I don’t remember what it was. Just post some update into initial thread to make it pop up.

Roman

Patrik Mueller's picture

Hi Roman,

here it was:

http://www.opencascade.org/org/forum/thread_7150/

Greets,

Patrik