[vtkusers] Help!! =( NormalizedViewport -> World usingvtkCoordinate

Louis Desjardins lost_bits1110 at hotmail.com
Fri Dec 10 15:23:03 EST 2004


Also.. Now I've treid to convert my viewport coords to Display coords and 
then from Display to World

                CoordObj->SetCoordinateSystemToNormalizedViewport( );
		CoordObj->SetValue(0.5, 0.5, 1);
		values = CoordObj->GetComputedDisplayValue( Ren );

		ViewPortToWorld->SetValue(1, 1, 1);
		morevalues = CoordObj->GetComputedDisplayValue( Ren1 );

'values' and 'morevalues' give me the correct coordinates
then I do
		CoordObj->SetCoordinateSystemToDisplay( );

                CoordObj->SetValue(values[0], values[1], values[2]);
		Value1 = ViewPortToWorld->GetComputedWorldValue(Ren );

		CoordObj->SetValue(morevalues[0], morevalues[1], morevalues[2]);
		Value2 = ViewPortToWorld->GetComputedWorldValue( Ren );

but both Value1 and Value2 give me the exact same coords!!
????

makes no sense
If anyone has any suggestions, that woudl help me alot

Thank you................

LD



>From: "Louis Desjardins" <lost_bits1110 at hotmail.com>
>To: vidyadhar at lucidindia.net, vtkusers at vtk.org
>Subject: Re: [vtkusers] Help!! =( NormalizedViewport -> World 
>usingvtkCoordinate
>Date: Fri, 10 Dec 2004 16:45:10 +0000
>
>Thank you so much for your response Vidyadhar,
>
>I am using vtkCoordinate sorry i should have mentioned
>
>So just to clarify:
>
>I have a viewport that is divided on my screen so that it takes teh top 
>half of my screen:
>
>And I have an unstructured mesh which is defined in its own coodoordinate 
>space, world space i guess, but its constantly rotating around so we see 
>different views of the mesh
>
>Now I've defined by viewport as
>Ren->SetViewport( 0.5, 0.5, 1, 1)
>
>so I guess this is Normalized Viewport
>
>and I'vve tried using all 3 xyz now when using vtkCooridnate but it doesnt 
>work, (maybe i'm not seetting the z value correctly? I tried both 0 and 1? 
>how do i know which to use?)
>
>or i've tried
>
>Ren->SetViewPoint( 0.5, 0.5, 0 );
>Ren->ViewToWorld();
>worldValue1 = Ren->GetWorldPoint();
>
>Ren->SetViewPoint( 1, 1, 0 );
>Ren->ViewToWorld();
>worldValue1 = Ren->GetWorldPoint();
>
>which should also work, but doesnt work (again maybe the z value is wrong? 
>I tried it with '1' as well and didnt work)
>
>Say that the below is my screen: and the top half is the viewport i 
>defined: so I just want the points I've marked in X to be in world coords:
>
>--------------X
>|                 |
>|                 |
>X------------ |
>|                 |
>|                 |
>--------------
>
>
>Okay thank you again,
>I'll keep trying meanwhile any tips are very much appreciated!!
>thank you
>LD
>p.s or maybe i shoudlnt be using view? shoudl i use display??
>
>>From: "vidyadhar" <vidyadhar at lucidindia.net>
>>To: "Louis Desjardins" <lost_bits1110 at hotmail.com>
>>Subject: Re: [vtkusers] Help!! =( NormalizedViewport -> World using 
>>vtkCoordinate
>>Date: Fri, 10 Dec 2004 12:42:07 +0530
>>
>>Hi,
>>It is not clear from your message but I think you are using vtkCoordinate
>>class for transformation. If that is the case then there is mistake in
>>SetValue. It should get (x,y,z) coordinates, not just (x,y).
>>vtkViewport itself has methods to translate like this.
>>Get/SetDisplay/WorldPoint and WorldToDisplay and DisplayToWorld. Here 
>>world
>>coordinates are homogeneous coordinates (x,y,z,s).
>>Vidyadhar
>>----- Original Message -----
>>From: "Louis Desjardins" <lost_bits1110 at hotmail.com>
>>To: <vtkusers at vtk.org>
>>Sent: Friday, December 10, 2004 8:21 AM
>>Subject: [vtkusers] Help!! =( NormalizedViewport -> World using
>>vtkCoordinate
>>
>>
>> > Okay apparantly my last message didnt go through which was:
>> >
>> > Hello experts
>> >
>> > Say I have a Viewport that is defined as:
>> > Ren->SetViewport( 0.5, 0.5, 1, 1)    // (x_min,y_min, x_max,y_max)
>> >
>> > so basically it takes some fraction of the screen (half in this case)
>> >
>> > I've rendered an UnstructuredGrid in this viewport, and thus I have an
>>idea
>> > of what my world coordinates are
>> >
>> > I would like to know the points defined above for my 'Ren' viewport in
>>these
>> > defined world coordinates
>> >
>> > so I would like to convert (0.5,0.5) to world coords
>> > and (1,1) to world coords
>> >
>> > this my code:
>> >
>> >        double *worldValue1 = new double[2];
>> > double *worldValue2 = new double[2];
>> >
>> > ViewPortToWorld->SetCoordinateSystemToNormalizedViewport( );
>> > ViewPortToWorld->SetViewport( Ren );
>> > ViewPortToWorld->SetValue(0.5, 0.5);
>> >
>> > worldValue1 = ViewPortToWorld->GetComputedWorldValue( Ren );
>> > cout<<worldValue1[0]<<" "<<worldValue1[1]<<endl;
>> >
>> > ViewPortToWorld->SetValue(1, 1);
>> > worldValue2 = ViewPortToWorld->GetComputedWorldValue( ColorDoppler.Ren1 
>>);
>> > cout<<worldValue2[0]<<" "<<worldValue2[1]<<endl;
>> >
>> > Like I said, I have an idea of what the values should be, but I dont 
>>get
>>the
>> > right ones
>> > also, worldValue1 and worldValue2 give the exact same values!??
>> >
>> > Any help at all would be greatly appreciated =S
>> > Thank you!
>> >
>> > LD
>> > --------
>> > .. just to add to this:
>> > I've also tried:
>> >
>> > Ren->SetViewPoint( 0.5, 0.5, 0 );
>> > Ren->ViewToWorld();
>> > worldValue1 = ColorDoppler.Ren1->GetWorldPoint();
>> > cout<<worldValue1[0]<<"  "<<worldValue1[1]<<endl;
>> >
>> > Ren->SetViewPoint( 1, 1, 0 );
>> > Ren->ViewToWorld();
>> > worldValue1 = ColorDoppler.Ren1->GetWorldPoint();
>> > cout<<worldValue1[0]<<"  "<<worldValue1[1]<<endl<<endl;
>> >
>> > and still doesnt work :(
>> >
>> > sigh
>> >
>> >
>> >
>> >
>>
>
>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages on-topic. 
>Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list