<br>Hey, <br><br>Thanks. It's working fine. A small verification.. Where should be the callback command called??<br><br>In Renderer's start event or in wxWindowRenderInteractor's EndInteractorEvent?? And after setting the<br>scale to glyphs, do i need to refresh or render them again??<br><br>And depth is to be calculated as difference of objects position and camera position right?? Coz in my case all glyphs are at same depth<br><br>Thanks<br><blockquote><br>---------- Original message ----------<br>From:David Gobbi< david.gobbi@gmail.com ><br>Date: 09 Feb 10 17:33:58<br>Subject: Re: [vtkusers] rescaling glyphs..??<br>To: Rakesh Patil <rakeshthp@in.com><br><br>Hi Rakesh,<br><br>The only thing that you should be doing in the callback is setting the<br>scale. You should only add the glyphs to the renderer once (and the<br>callback is not the place to do that). The reason that things are<br>slowing down is that you are creating new glyphs and adding them to<br>the rende
rer each time, so after the callback has been called N times<br>there will be N copies of all your glyphs in the renderer. After you<br>fix this, calling the callback on every render should not be a problem<br>at all.<br><br>What I mean by "depth" is distance from the camera. The further an<br>object is from the camera, the smaller it will look. So, the further<br>it is from the camera, the more you have to scale it to make it "look"<br>the same size.<br><br>Actually depth isn't exactly the distance from the camera. The depth<br>is the dot product of the camera's direction-of-projection with the<br>vector from the camera's position to the object's position. So to<br>scale objects so that they always look the same size, you will need to<br>compute the depth for each object and then use the depth to compute<br>the scale factor. Store these scale factors in an array of scalars<br>(i.e. a vtkFloatArray with the same length as your list of points) and<br>then store these sc
alars with your point data. Then you can tell<br>Glyph3D to use these scalars to scale the glyphs.<br><br> David<br><br><br>On Tue, Feb 9, 2010 at 4:40 AM, Rakesh Patil <rakeshthp@in.com> wrote:<br>><br>> Well,<br>><br>> I guess, its working fine.. But the scaling isn't working properly...<br>> As told by you, i hooked an observer in the renderer's start event. But by<br>> doing so,<br>> the performance of the application became very slow. So, i hooked an<br>> observer to<br>> the vtkRenderWindowInteractor's EndInteractionEvent.<br>><br>> And then in my command callback, i call the following two functions,<br>><br>> ComputeScale();<br>> DisplayVectors();<br>><br>> DisplayVectors contains the code to display vector arrays. as<br>><br>> glyphs->SetScaleFactor(_scale);<br>><br>> glyphMapper = vtkPolyDataMapper::New();<br>> glyphMapper->SetInputConnection(glyphs->GetOutputPort());<br>><br>> glyphAc
tor = vtkActor::New();<br>> glyphActor->SetMapper(glyphMapper);<br>><br>> pRenderer->AddActor(glyphActor);<br>><br>> The above code is executed again and again.. And thats why the performance<br>> of the application<br>> goes down..<br>><br>> So, what i want to know is whether what i did is correct or not?? Secondly,<br>> is t here any faster method to display the scaled output??<br>><br>> Thanks<br>><br>> ---------- Original message ----------<br>> From:"Rakesh Patil"< rakeshthp@in.com ><br>> Date: 09 Feb 10 12:50:37<br>> Subject: Re: [vtkusers] rescaling glyphs..??<br>> To: "David Gobbi"<br>><br>> Hello sir,<br>><br>> Well, I dont know what you exactly mean by "at the same depth" in regards to<br>> collection of glyph?<br>> Actually, each nodes are at different depths (say range from 0 to 3000 for<br>> example). And I display<br>> glyphs at these nodes. So, does it mean that my glyphs
are not at same<br>> depth..??<br>><br>> Thanks<br>><br>><br>><br>> ---------- Original message ----------<br>> From:David Gobbi< david.gobbi@gmail.com ><br>> Date: 08 Feb 10 19:06:27<br>> Subject: Re: [vtkusers] rescaling glyphs..??<br>> To: Rakesh Patil<br>><br>> Hi Rakesh,<br>><br>> The "ViewPort" is not what you think. It has nothing to do with the<br>> problem you are working on.<br>><br>> The "position" in that code means world coordinates of whatever object<br>> object you want to scale. When the camera is doing a perspective<br>> projection (this is the default), then the scale of an object depends<br>> on its depth within the scene. The position is used to compute the<br>> depth.<br>><br>> If you have a collection of glyphs that a re all at approximately the<br>> same depth, you can compute the centroid and use that as the position.<br>> Setting a different scale for each glyph is p
ossible, too, but is<br>> more complicated.<br>><br>> David<br>><br>><br>> On Sun, Feb 7, 2010 at 10:58 PM, Rakesh Patil wrote:<br>>> Hello,<br>>><br>>> I have to scale my vector arrows (glyphs) in such a way that when it is<br>>> zoomed in, the arrow size must become small and as I zoom out, it should<br>>> grow up.. As my senior instructed me here,<br>>><br>>> <a target=\"_blank\" href="http://www.vtk.org/pipermail/vtkusers/2010-January/105915.html" target="_blank">http://www.vtk.org/pipermail/vtkusers/2010-January/105915.html</a><br>>><br>>> I tried my best and did this..<br>>><br>>> class vtkMyCallback : public vtkCommand<br>>> {<br>>> public:<br>>> static vtkMyCallback *New(){<br>>> return new vtkMyCallback;<br>>> }<br>>><br>>> virtual void Execute(vtkObject *callee, unsigned long, void *)<br>>> {<br>>> vt kRenderer *ren derer = reint
erpret_cast(callee);<br>>> computeSomething(renderer->GetActiveCamera()->GetPosition(), renderer);<br>>> }<br>>> };<br>>><br>>> Here is a code for computeSomething()<br>>><br>>> computeSomething( const double position[3], vtkRenderer *renderer)<br>>> {<br>>> double vp[4];<br>>> renderer->GetViewPort(vp);<br>>> cout << vp[0] << vp[1] << vp[2] << vp[3];<br>>> }<br>>><br>>> It is invoked as<br>>><br>>> vtkMyCallback * mo = vtkMyCallback::New();<br>>> pRenderer->AddObserver(vtkCommand::StartEvent, mo);<br>>><br>>><br>>> When i run this code, I get the viewport as<br>>><br>>> 0011<br>>><br>>> It remains same throughout. Even after zooming in and out...<br>>><br>>> after that I tried the code which was suggested to me by one of the senior<br>>> developer here<br>>><br>>> The
scale which it returns is 0. as the position i'm passing in<br>>> computeSomething is s ame as the camera position in else part. Actually,<br>>> now<br>>> i need to find the scale. So in order to do that, what position do i need<br>>> to<br>>> pass as a parameter for this function.? what is difference between,<br>>> position<br>>> and camera position??<br>>><br>>> Thanks in advance<br>>> Rakesh Patil<br>>><br>>> Dear vtkusers ! Get Yourself a cool, short @in.com Email ID now!<br>>> _______________________________________________<br>>> Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>>><br>>> Visit other Kitware open-source projects at<br>>> <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>>><br>>> Please keep m
essages on-topic and check the VTK FAQ at:<br>>> <a target=\"_blank\" href="http://www.vtk.org/Wik" target="_blank">http://www.vtk.org/Wik</a> i/VTK_FAQ<br>>><br>>> Follow this link to subscribe/unsubscribe:<br>>> <a target=\"_blank\" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>>><br>>><br>><br></rakeshthp@in.com></rakeshthp@in.com></blockquote>