[vtkusers] rescaling glyphs..??

David Gobbi david.gobbi at gmail.com
Mon Feb 8 08:36:27 EST 2010


Hi Rakesh,

The "ViewPort" is not what you think.  It has nothing to do with the
problem you are working on.

The "position" in that code means world coordinates of whatever object
object you want to scale.  When the camera is doing a perspective
projection (this is the default), then the scale of an object depends
on its depth within the scene.  The position is used to compute the
depth.

If you have a collection of glyphs that are all at approximately the
same depth, you can compute the centroid and use that as the position.
 Setting a different scale for each glyph is possible, too, but is
more complicated.

   David


On Sun, Feb 7, 2010 at 10:58 PM, Rakesh Patil <rakeshthp at in.com> wrote:
> Hello,
>
> I have to scale my vector arrows (glyphs) in such a way that when it is
> zoomed in, the arrow size must become small and as I zoom out, it should
> grow up.. As my senior instructed me here,
>
> http://www.vtk.org/pipermail/vtkusers/2010-January/105915.html
>
> I tried my best and did this..
>
> class vtkMyCallback : public vtkCommand
> {
> public:
> static vtkMyCallback *New(){
> return new vtkMyCallback;
> }
>
> virtual void Execute(vtkObject *callee, unsigned long, void *)
> {
> vtkRenderer *renderer = reinterpret_cast<vtkRenderer>(callee);
> computeSomething(renderer->GetActiveCamera()->GetPosition(), renderer);
> }
> };
>
> Here is a code for computeSomething()
>
> computeSomething( const double position[3], vtkRenderer *renderer)
> {
> double vp[4];
> renderer->GetViewPort(vp);
> cout << vp[0] << vp[1] << vp[2] << vp[3];
> }
>
> It is invoked as
>
> vtkMyCallback * mo = vtkMyCallback::New();
> pRenderer->AddObserver(vtkCommand::StartEvent, mo);
>
>
> When i run this code, I get the viewport as
>
> 0011
>
> It remains same throughout. Even after zooming in and out...
>
> after that I tried the code which was suggested to me by one of the senior
> developer here
>
> The scale which it returns is 0. as the position i'm passing in
> computeSomething is same as the camera position in else part. Actually, now
> i need to find the scale. So in order to do that, what position do i need to
> pass as a parameter for this function.? what is difference between, position
> and camera position??
>
> Thanks in advance
> Rakesh Patil
>
> Dear vtkusers ! Get Yourself a cool, short @in.com Email ID now!
> _______________________________________________
> 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
>
>



More information about the vtkusers mailing list