[vtkusers] Changing the direction of Z

Jim Peterson jimcp at cox.net
Mon Oct 18 18:31:43 EDT 2010


Paul Harris wrote:
>
> My models do not have any particular handedness, ...
all 3D models have a "handedness" 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. "Left handed" is the same rule with "counter 
clockwise" replaced with "clockwise". you trasnform between the two by 
either reversing the direction of Z or exchanging X and Y. 
> in fact if I turn on the CullBackfaces mode, then every second 
> triangle disappears!
>
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.
> That confuses me a lot... 
> If I negate the Z axis when I import the data, it looks perfect.
That would be switching the "handedness" of the model.
> If I use vtkTransformPolyData, it looks perfect.
I can only find vtkTransformPolyDataFilter, Probably need to see what 
you specified.
>
> 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't make any difference at all.
>
> I don'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't the important bit, but rather the important bit is when the 
> lighting is applied. - in particular, TwoSidedLighting.
>
> Following that hunch, I turned off TwoSidedLighting, and flipped the 
> model with SetUserTransform, with NO vtkReverseSense.
>
> Now both my normal and flipped model look perfect, except that half of 
> their triangles are dark.
> 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.
>
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 "other 
side" it only looks like the same triangles are dark?
> Ideas?
> thanks
> Paul
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.
HTH,
Jim



More information about the vtkusers mailing list