[vtkusers] rescaling glyphs..??

Rakesh Patil rakeshthp at in.com
Tue Feb 9 07:46:45 EST 2010


 Hey, Thanks. It's working fine. A small verification.. Where should be the callback command called??In Renderer's start event or in wxWindowRenderInteractor's EndInteractorEvent?? And after setting thescale to glyphs, do i need to refresh or render them again??And depth is to be calculated as difference of objects position and camera position right?? Coz in my case all glyphs are at same depthThanks Original message From:David Gobbi< david.gobbi at gmail.com >Date: 09 Feb 10 17:33:58Subject:Re: [vtkusers] rescaling glyphs..??To: Rakesh Patil Hi Rakesh,The only thing that you should be doing in the callback is setting thescale.You should only add the glyphs to the renderer once (and thecallback is not the place to do that).The reason that things areslowing down is that you are creating new glyphs and adding them tothe renderer each time, so after the callback has been called N timesthere will be N copies of all your glyphs in the renderer.After youfix this, calling the callback 
 on every render should not be a problemat all.What I mean by "depth" is distance from the camera.The further anobject is from the camera, the smaller it will look.So, the furtherit is from the camera, the more you have to scale it to make it "look"the same size.Actually depth isn't exactly the distance from the camera.The depthis the dot product of the camera's directionofprojection with thevector from the camera's position to the object's position.So toscale objects so that they always look the same size, you will need tocompute the depth for each object and then use the depth to computethe scale factor.Store these scale factors in an array of scalars(i.e. a vtkFloatArray with the same length as your list of points) andthen store these scalars with your point data.Then you can tellGlyph3D to use these scalars to scale the glyphs.DavidOn Tue, Feb 9, 2010 at 4:40 AM, Rakesh Patilwrote:>> Well,>> I guess, its working fine.. But the scaling isn't working properly...> As told by
  you, i hooked an observer in the renderer's start event. But by> doing so,> the performance of the application became very slow. So, i hooked an> observer to> the vtkRenderWindowInteractor's EndInteractionEvent.>> And then in my command callback, i call the following two functions,>> ComputeScale();> DisplayVectors();>> DisplayVectors contains the code to display vector arrays. as>> glyphs>SetScaleFactor(scale);>> glyphMapper = vtkPolyDataMapper::New();> glyphMapper>SetInputConnection(glyphs>GetOutputPort());>> glyphActor = vtkActor::New();> glyphActor>SetMapper(glyphMapper);>> pRenderer>AddActor(glyphActor);>> The above code is executed again and again.. And thats why the performance> of the application> goes down..>> So, what i want to know is whether what i did is correct or not?? Secondly,> is t here any faster method to display the scaled output??>> Thanks>>  Original message > From:"Rakesh Patil"< rakeshthp at in.com >> Date: 09 Feb 10 12:50:37> Subject: Re: [vtkusers] r
 escaling glyphs..??> To: "David Gobbi">> Hello sir,>> Well, I dont know what you exactly mean by "at the same depth" in regards to> collection of glyph?> Actually, each nodes are at different depths (say range from 0 to 3000 for> example). And I display> glyphs at these nodes. So, does it mean that my glyphs are not at same> depth..??>> Thanks>>>>  Original message > From:David Gobbi< david.gobbi at gmail.com >> Date: 08 Feb 10 19:06:27> Subject: Re: [vtkusers] rescaling glyphs..??> To: Rakesh Patil>> 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 a re 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 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/2010January/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 *)>> {>> vt kRenderer *ren derer = reinterpretcast(callee);>> computeSomething(renderer>GetActiveCamera()>GetPosition(), renderer);>> }>> };>>>> Here is a code for computeSomething()>>>> computeSomething( const double position[3], vtkRenderer *renderer)>> {>> double vp[4];>> renderer>GetViewP
 ort(vp);>> cout >> 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 s ame 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 opensource projects at>> http://www.kitware.com/opensource/opensource.html>>>> Please keep messages ontopic and check the VTK FAQ at:>> 
 http://www.vtk.org/Wik i/VTKFAQ>>>> 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/20100209/5c26322c/attachment.htm>


More information about the vtkusers mailing list