The shape takes the transformation (mirroring), but in the Viewer the Shading representation "change color" it becomes darkest (in shadow). See the screenshot :
Are you using the OCC provided visualization services ?
Saretto
2009/11/30 11:21
"Are you using the OCC provided visualization services ?"
Yes
Fotis Sioutis
2009/11/30 13:04
Then really I have no clue ...
but
your issue reminded me a problem i had in past when i was reading the occ provided mesh in order to pass it to my own renderer.The problem then, was that i did not translate the provided normal with the owner TopoDS_Face transformation.This issue created the exact same side-effect like your case.
Fotis
Saretto
2011/01/31 18:42
UP!
In OCC 6.4 is resolved this issue ????
sergey zaritchny
2011/02/03 10:13
Hi,
Unfortunately I can't reproduce the problem in Draw (in OCCT6.3.0 too).
Used below set of commands with 'mirror' command and
the next visualization in standard AISViewer in shading mode
gives correct result (as you may see it from the attached picture).
box b 100 100 100 10 10 10
copy b b2
tmirror b2 0 0 0 1 0 0
vinit
vdisplay b
# turn on shading mode for the first box 'b'
vdisplay b2
# turn on shading mode for the second box 'b2'
vfit
The resulting shape is attached.
Regards
You have to be logged in to download the attached file
PG
2011/02/03 10:44
Looks fine with me too.
But 'tmirror' command uses the SetMirror function with gp_Ax1 object.
The author wants to use 'gp_Ax2' object.
regards
- PG
sergey zaritchny
2011/02/03 13:29
h'm!
Look, please at the BRepTest_BasicCommands.cxx.
Below is the extraction from the code:
...
if (!strcmp(a[0],"tmirror")) {
if (n < 8) return 1;
T.SetMirror(gp_Ax2(gp_Pnt(atof(a[n-6]),atof(a[n-5]),atof(a[n-4])),
gp_Vec(atof(a[n-3]),atof(a[n-2]),atof(a[n-1]))));
...
}
IMHO it is gp_Ax2.
Regards
Timo
2012/06/11 14:16
The difference is that the Draw command "tmirror" uses BRepBuilderAPI_Transform whereas Saretto in his code just set the location of the shape.
The mirror transformation inverts the normals. Therefore, the shading isn't correct anymore.
Also scaling transformations affect the normals. Therefore, upscaling results in darker lighting, downscaling in lighter Lighting if you just set the shape to a new location.
BRepBuilderAPI_Transform::Perform checks for these cases and uses BRepTools_TrsfModification in these and setting the location of the shape in other cases like e.g. rotations. As far as I understand, BRepTools_TrsfModification creates a transformed copy of the shape and therefore the normals are recalculated.
I don't know where the normals are calculated or if it is possible to force their recalculation.
The same shading problems also occur when you set the transformation of an AIS_InteractiveObject via SetTransformation() to be a scale or mirror transformation after it has been displayed in an AIS_InteractiveContext. This seems to me like a bug. Using BRepBuilderAPI_Transform solves this problem but it is much slower.
A colleague of mine said that you can let OpenGL recalculate the normals automatically by
glEnable(GL_RESCALE_NORMAL);
Would this be a solution for all these problems?
According to http://www.opengl.org/discussion_boards/showthread.php/133406-GL_RESCALE_NORMAL-in-VC GL_RESCALE_NORMAL is contained in OpenGL 1.2.
Kind regards,
Timo
Timo
2012/06/12 13:56
In order to reproduce the mirror problem with AIS_InteractiveObject.SetTransformation you can use the Import Export sample with the following modification: