[vtkusers] Changing the direction of Z

Paul Harris harris.pc at gmail.com
Sun Oct 17 21:59:48 EDT 2010


Jim, please stick your nose in at all times, that is why its mailing list :)

My models do not have any particular handedness, in fact if I turn on the
CullBackfaces mode, then every second triangle disappears!

That confuses me a lot...
If I negate the Z axis when I import the data, it looks perfect.
If I use vtkTransformPolyData, it looks perfect.

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.

Ideas?
thanks
Paul


On 18 October 2010 00:09, Jim Peterson <jimcp at cox.net> wrote:

> My apologies for sticking my nose into this conversation, but I feel there
> is a miscommunication regarding coordinate systems going on here. In my
> opinion, Bill is a master of these nuances, and speaks knowledgeably
> regarding ITK, Paraview and VTK. A right handed system is represented by
> extending your thumb, index finger and middle finger of your right hand at
> 90 degrees to each other. A left handed system by doing the same with your
> left hand, exactly which finger is point up is irrelevant, the difference is
> whether the rotation to the next axis is clockwise or counter clockwise. The
> default view of the right handed system in vtk is with index finger pointing
> up, and palm visible, in other medical presentations, the typical initial
> view is with your index finger point down and palm pointing away.  In my
> experience with vtk, and medical data, both treat the image data as a right
> handed coordinate system, the difference being where the origin is relative
> to the rest of the object, and which direction Z increases. what I have
> noticed is medical data generally appears "upside down and from the back",
> so a simple 180 degree transform around the X axis results in the expected
> image appearance and orientation. That is, the origin is in the upper left
> of the view and z increases away from the viewer.
>
> In my opinion the easiest way to attain this view is to position the camera
> in the world space to get this view, not transform the points.
>
> I hope this helps, again, I apologize for jumping in.
> Jim
>
> Paul Harris wrote:
>
>> The models and other data points are usually in a East,North,Elevation
>> coordinate system, but often some datasets will be in a West,South,Depth or
>> some variant in between, due to legacy reasons.
>>
>> I would like to be able to just flick a switch and have everything
>> displayed the "right way" around, however if its going to involve
>> vtkTransformPolyData, what I might be forced to do is flip everything around
>> at the point of importing/loading the data, and then flip the numbers around
>> again when I display grids, coordinates and stuff in tables...
>>
>> However it would be ideal if I could just tell VTK which way around the
>> world coordinates are, without worrying about normals pointing the wrong way
>> etc.
>>
>> On 17 October 2010 11:11, Bill Lorensen <bill.lorensen at gmail.com <mailto:
>> bill.lorensen at gmail.com>> wrote:
>>
>>    The vtk coordinate system is right-handed. Are your models in a left
>>    handed system?
>>
>>    On Sat, Oct 16, 2010 at 11:10 PM, Bill Lorensen
>>    <bill.lorensen at gmail.com <mailto:bill.lorensen at gmail.com>> wrote:
>>    > Yes, user matrix should work. But a negative scale will mess up the
>>    > shading calculation. The user matrix is used by opengl. Not sure why
>>    > reverse sense did not work.
>>    >
>>    > Try the same thing (as an experiment) with vtkTransformPolyData.
>>    >
>>    > On Sat, Oct 16, 2010 at 7:46 PM, Paul Harris
>>    <harris.pc at gmail.com <mailto:harris.pc at gmail.com>> wrote:
>>    >> On 16 October 2010 21:25, Bill Lorensen
>>    <bill.lorensen at gmail.com <mailto:bill.lorensen at gmail.com>> wrote:
>>    >>>
>>    >>> You can use the vtkTransformPolyDataFilter
>>    >>>
>>    >>
>>    >> That will make a copy of the points and then adjust all the
>>    values, right?
>>    >>
>>    >> There is quite a lot of points to plot, I was hoping to use an
>>    approach that
>>    >> wouldn't involve using more memory.
>>    >>
>>    >> Earlier, I tried this approach:
>>    >> vtkTransform * flipform = vtkTransform::New();
>>    >> flipform->Identity();
>>    >> flipform->Scale(1,1,-1);
>>    >> actor_flip->SetUserMatrix( flipform->GetMatrix() );
>>    >>
>>    >> And that worked find *except* that all of the surfaces look
>>    dark, as if they
>>    >> are facing away from the camera.
>>    >>
>>    >> I looked around and tried adding vtkReverseSense to the chain,
>>    but that
>>    >> didn't make any difference at all.
>>    >>
>>    >> Should I be able to use SetUserMatrix?
>>    >>
>>    >>
>>    >>
>>    >>>
>>    >>> On Sat, Oct 16, 2010 at 9:06 AM, Paul Harris
>>    <harris.pc at gmail.com <mailto:harris.pc at gmail.com>> wrote:
>>    >>> > The models themselves.   Flipping the ViewUp seems to be the
>>    same as
>>    >>> > turning
>>    >>> > the monitor upside down, but that is not the result I want.
>>    >>> > The problem is that Z in model coordinates is "downwards",
>>    but vtk seems
>>    >>> > to
>>    >>> > insist that Z is "upwards".
>>    >>> > This problem is not just for Z either,
>>    >>> > I also have the situation where in some circumstances, the Y
>>    should
>>    >>> > point
>>    >>> > the other way.   ie, Y means South rather than North.
>>    >>> >
>>    >>> >
>>    >>> > On 16 October 2010 03:32, Bill Lorensen
>>    <bill.lorensen at gmail.com <mailto:bill.lorensen at gmail.com>> wrote:
>>    >>> >>
>>    >>> >> Do you want the models flipped, or just the view of the models?
>>    >>> >>
>>    >>> >> If it is the latter, you can set the ViewUp of the camera
>>    to 0,0,-1.
>>    >>> >>
>>    >>> >>
>>    >>> >> On Fri, Oct 15, 2010 at 3:17 PM, Paul Harris
>>    <harris.pc at gmail.com <mailto:harris.pc at gmail.com>>
>>
>>    >>> >> wrote:
>>    >>> >> > Hi all,
>>    >>> >> >
>>    >>> >> > I have a VTK scene with some vtkPolyDataMappers and
>>    actors, plus an
>>    >>> >> > orientation widget.
>>    >>> >> >
>>    >>> >> > I want to change the fundamental direction of the Z axis,
>>    so that it
>>    >>> >> > points
>>    >>> >> > down rather than up.  I want all of the models, the
>>    orientation
>>    >>> >> > widget,
>>    >>> >> > etc
>>    >>> >> > to flip, so that they point down instead of up.
>>    >>> >> >
>>    >>> >> > I've tried lots of things but have gotten nowhere...
>>    >>> >> >
>>    >>> >> > how do I make this happen?
>>    >>> >> >
>>    >>> >> > thanks
>>    >>> >> > Paul
>>    >>> >> >
>>    >>> >> >
>>    >>> >> >
>>    >>> >> > _______________________________________________
>>    >>> >> > Powered by www.kitware.com <http://www.kitware.com>
>>
>>    >>> >> >
>>    >>> >> > Visit other Kitware open-source projects at
>>    >>> >> > http://www.kitware.com/opensource/opensource.html
>>    >>> >> >
>>    >>> >> > Please keep messages on-topic and check the VTK FAQ at:
>>    >>> >> > http://www.vtk.org/Wiki/VTK_FAQ
>>    >>> >> >
>>    >>> >> > Follow this link to subscribe/unsubscribe:
>>    >>> >> > http://www.vtk.org/mailman/listinfo/vtkusers
>>    >>> >> >
>>    >>> >> >
>>    >>> >
>>    >>> >
>>    >>
>>    >>
>>    >
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101018/0d9d82c5/attachment.htm>


More information about the vtkusers mailing list