Sketchup front back face
-
hello.
I have created a sketchup importer for opengl 2 in c++.
My problem is that i wish recognize if a face is front face or backface.
I'm ispired from the skpToXml demo , and i read about outer loop and inner loop.
When I'm import simple models all work , but for certain models i don't see part of the scene or textures are flipped.
then:1)is possible recognize a front/back face from the importer(not in the shader)?How?
2)is possible that a complex face ( nLoops>1 like the example skpToXml)is a back face? because i read that outer loop are always in ccg order or always cw i dont remember.I'm trying to flip all the backface or flip all the front face for reach an uniformity(all front face or all back face), this clearly is all to do only in importation phase , then i create a custom xml or serialize all in binary for speed up the loading.
In the shader i see if a face is a front face or back face with the FACE semantic (is automatic and already done), in cg for example FACE return < 0 if the face is a backface and > 0 if the face is a front face.
Thanks.
-
A face has several properties that might help.
face.normal
returns the faces direction
face.outer_loop.vertices
are returned counter-clockwise to the face.normal.
So if you know the order of the vertices and the normal you can work out which is the front and back of the face...
If you export a face by getting its loops and their vertices the outer_loop's clock-ness gives you its normal/front...
IF parts of your model ARE made wrongly - so the back-face is the wrong way it WILL export 'perfectly' - i.e. 'wrong'!!! -
thanks tig.
I understand, you were very kind, but I just can not find property Normal.
I'm Using sketchup 8 and C + +, perhaps in the 'SDK for C + + is called in another way.
can 'be?
else:
I have seen examples in the SDK that tests if the loops are == 1, and the commentary says it is a simple face, if not then use the "== 1" it use the
"CreateMesh (PolygonMeshPoints | PolygonMeshNormals, m_pPerspective, & m_pMesh);"
in this case the faces are always counter-clockwise or do I need to know the normal property ?
I see that there is a property get_Plane, i can use this?
but how?
thanks.ps sorry for my english
-
If you get the face's plane you should be able to work out it's normal ?
A plane is effectively an array of a point and a vector ?? The vector is the 'normal'... -
Try posting to the C++ SDK forum:
http://groups.google.com/group/su-sdk-fileshare/topics
Advertisement