[vtkusers] Changing the direction of Z

Paul Harris harris.pc at gmail.com
Thu Oct 21 03:19:20 EDT 2010


On 19 October 2010 06:31, Jim Peterson <jimcp at cox.net> wrote:

> 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.
>

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



>  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.
>
>
Yes.  And sometimes I need to visualise a plane from both sides, so
TwoSidedLighting is working well for me there.


>  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.
>
>
ah yes, I meant vtkTransformPolyDataFilter, sorry.


>
>> 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
>


Ok, now for some new information to look at.
Attached is a C++ file, if you compile and run it, you'll see one white cone
(with no bottom), and another black cone you can't see.
if you run it like so:  ./flip L
then it will use the vtkLightKit and you will see a white cone and a RED
cone.

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).

I found a couple of previous emails to the mailing list about this kind of
problem:

This one is the basis for my example code,
http://markmail.org/message/mqcc2yc7eqji6x6v

And this one discusses a problem with diffuse lighting and negative scaling,
http://markmail.org/message/mqcc2yc7eqji6x6v

I think there is a bug in here somewhere...

Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101021/1f59efb6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flip.cpp
Type: text/x-c++src
Size: 1447 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101021/1f59efb6/attachment.cpp>


More information about the vtkusers mailing list