<br><br><div class="gmail_quote">On 19 October 2010 06:31, Jim Peterson <span dir="ltr">&lt;<a href="mailto:jimcp@cox.net" target="_blank">jimcp@cox.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



Paul Harris wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
My models do not have any particular handedness, ...<br>
</blockquote>
all 3D models have a &quot;handedness&quot; Right handed says the  positive Y axis is a 90degree rotation counter clockwise from the positive X axis, the positive Z axis is 90 degrees counter clockwise from the  X/Y plane along the  Y positive axis. &quot;Left handed&quot; is the same rule with &quot;counter clockwise&quot; replaced with &quot;clockwise&quot;. you trasnform between the two by either reversing the direction of Z or exchanging X and Y. <br>



</blockquote><div><br>Ok well in that case, some of the models I view are right-handed, some are left-handed.  I need to support both.<br>I might have no choice but to insist on whatever VTK is happy with.<br><br> </div>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
in fact if I turn on the CullBackfaces mode, then every second triangle disappears!<br>
<br>
</blockquote></div>
This would likely depend on how the triangles are derived in the first place, typically the triangle normal is computed pointing away from the side of the polygon that has the points in a clockwise order. Apparently your triangles are alternating clockwise and counterclockwise, making half of them facing away from you.<div>



<br></div></blockquote><div><br>Yes.  And sometimes I need to visualise a plane from both sides, so TwoSidedLighting is working well for me there.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
That confuses me a lot... If I negate the Z axis when I import the data, it looks perfect.<br>
</blockquote></div>
That would be switching the &quot;handedness&quot; of the model.<div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If I use vtkTransformPolyData, it looks perfect.<br>
</blockquote></div>
I can only find vtkTransformPolyDataFilter, Probably need to see what you specified.<div><br></div></blockquote><div><br>ah yes, I meant vtkTransformPolyDataFilter, sorry.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
But if I use SetUserTransform() then the faces look dark.  I tried vtkReverseSense with reversecells and reversenormals turned on, off and vice versa and it didn&#39;t make any difference at all.<br>
<br>
I don&#39;t think I understand where the lighting is applied and how the normals come into play.  It seems like the direction of the normal isn&#39;t the important bit, but rather the important bit is when the lighting is applied. - in particular, TwoSidedLighting.<br>




<br>
Following that hunch, I turned off TwoSidedLighting, and flipped the model with SetUserTransform, with NO vtkReverseSense.<br>
<br>
Now both my normal and flipped model look perfect, except that half of their triangles are dark.<br>
What is really interesting to me is that the SAME triangles are dark in both the flipped and unflipped case.  I was expecting them to be different as I expected the normals to be reversed.<br>
<br>
</blockquote></div>
I think maybe posting an example would be a real benefit. How symetrical is your model? is it possible that reversed and viewed from the &quot;other side&quot; it only looks like the same triangles are dark?<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ideas?<br>
thanks<br>
Paul<br>
</blockquote>
It looks like you have found several solutions that work, you describe some interesting artifacts in behavior of the logic, I think we would need to see exactly what was coded to produce these results to determine whether there are any bugs to be fixed and what the test is to verify the behavior.<br>




HTH,<br><font color="#888888">
Jim<br>
</font></blockquote></div><br><br>Ok, now for some new information to look at.<br>Attached is a C++ file, if you compile and run it, you&#39;ll see one white cone (with no bottom), and another black cone you can&#39;t see.<br>

if you run it like so:  ./flip L<br>then it will use the vtkLightKit and you will see a white cone and a RED cone.<br><br>The difference between the two cones is that the black/red one has been transform with SetUserMatrix()... its translated by (2,0,0) and scaled by (1,1,-1).<br>

<br>I found a couple of previous emails to the mailing list about this kind of problem:<br><br>This one is the basis for my example code,<br><a href="http://markmail.org/message/mqcc2yc7eqji6x6v">http://markmail.org/message/mqcc2yc7eqji6x6v</a><br>

<br>And this one discusses a problem with diffuse lighting and negative scaling,<br><a href="http://markmail.org/message/mqcc2yc7eqji6x6v">http://markmail.org/message/mqcc2yc7eqji6x6v</a><br><br>I think there is a bug in here somewhere...<br>

<br>Regards,<br>Paul<br><br>