<div dir="ltr">Hi Sankhesh,<div><br></div><div>Yes, I want users to be able to interact with the VTK objects with a VR wand. I can test whether the wand works by temporarily using keyboard buttons to zoom, pan, rotate, and select the VTK objects. I would need to use a vtkRenderWindowInteractor in this case, right?</div><div><br></div><div>Thanks,</div><div>Elaine</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 21, 2017 at 1:28 PM, Sankhesh Jhaveri <span dir="ltr"><<a href="mailto:sankhesh.jhaveri@kitware.com" target="_blank">sankhesh.jhaveri@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="m_-3906093223114168208markdown-here-wrapper" style="font-family:"Lucida Sans",Cantarell,Verdana,sans-serif;color:rgb(11,83,148)"><p style="margin:0px 0px 1.2em!important">Hi Elaine,</p>
<p style="margin:0px 0px 1.2em!important">By using the <code style="font-size:0.95em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(218,218,218);background-color:rgb(232,232,232);border-radius:3px;display:inline">ExternalVTKWidget</code> and all the <code style="font-size:0.95em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(218,218,218);background-color:rgb(232,232,232);border-radius:3px;display:inline">vtkExternal*</code> classes, you get interaction by default. The external widget ensures that the VTK camera is synchronized with the VR camera. Is there some special kind of interaction that you are looking for?</p>
<p style="margin:0px 0px 1.2em!important">Sankhesh</p>
<div title="MDH:SGkgRWxhaW5lLDxkaXY+PGJyPjwvZGl2PjxkaXY+QnkgdXNpbmcgdGhlIGBFeHRlcm5hbFZUS1dp
ZGdldGAgYW5kIGFsbCB0aGUgYHZ0a0V4dGVybmFsKmAgY2xhc3NlcywgeW91IGdldCBpbnRlcmFj
dGlvbiBieSBkZWZhdWx0LiBUaGUgZXh0ZXJuYWwgd2lkZ2V0IGVuc3VyZXMgdGhhdCB0aGUgVlRL
IGNhbWVyYSBpcyBzeW5jaHJvbml6ZWQgd2l0aCB0aGUgVlIgY2FtZXJhLiBJcyB0aGVyZSBzb21l
IHNwZWNpYWwga2luZCBvZiBpbnRlcmFjdGlvbiB0aGF0IHlvdSBhcmUgbG9va2luZyBmb3I/PC9k
aXY+PGRpdj48YnI+PC9kaXY+PGRpdj5TYW5raGVzaDwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 21, 2017 at 12:27 PM elainejiang8 <<a href="mailto:elainejiang8@gmail.com" target="_blank">elainejiang8@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I'm writing a program that integrates vtk with an external VR program. This<br>
requires that I use the VR program's render loop instead of vtk's. However,<br>
I'm hoping to still be able to use vtkRenderWindowInteractor as it will make<br>
interacting with vtk objects much easier. I saw a post on stackoverflow that<br>
said that I could just call vtkRenderWindowInteractor::<wbr>Initialize() for the<br>
interactor to become enabled, but when I call the function, I can't seem to<br>
interact with the vtk objects. Does anyone have any insight into this issue?<br>
I'll attach my initialization and render functions below:<br>
<br>
void initialize() {<br>
    vtkNew<<wbr>vtkExternalOpenGLRenderWindow> renWin;<br>
    externalVTKWidget-><wbr>SetRenderWindow(renWin.<wbr>GetPointer());<br>
    renWin->AddRenderer(ren);<br>
<br>
    /*****************************<wbr>*****************************/<br>
<br>
    std::string files[7] = {"../data/cco-ascii.vtk",<br>
"../data/newjets-ascii.vtk", "../data/fekcorr-ascii.vtk",<br>
"../data/newar-ascii.vtk", "../data/newhetg-ascii.vtk",<br>
"../data/newopt-ascii.vtk", "../data/newsi-ascii.vtk"};<br>
<br>
    for(int i = 0; i < NUM_ACTORS; i++) {<br>
        vtkSmartPointer<<wbr>vtkPolyDataReader> reader =<br>
        vtkSmartPointer<<wbr>vtkPolyDataReader>::New();<br>
        reader->SetFileName(files[i].<wbr>c_str());<br>
        reader->Update();<br>
        vtkSmartPointer<vtkPolyData> inputPolyData = reader->GetOutput();<br>
<br>
        // Merge duplicate points, and/or remove unused points and/or remove<br>
degenerate cells<br>
        vtkSmartPointer<<wbr>vtkCleanPolyData> clean =<br>
        vtkSmartPointer<<wbr>vtkCleanPolyData>::New();<br>
        clean->SetInputData(<wbr>inputPolyData);<br>
<br>
        vtkSmartPointer<<wbr>vtkSmoothPolyDataFilter> smoothFilter =<br>
        vtkSmartPointer<<wbr>vtkSmoothPolyDataFilter>::New(<wbr>);<br>
        smoothFilter-><wbr>SetInputConnection(clean-><wbr>GetOutputPort());<br>
        smoothFilter-><wbr>SetNumberOfIterations(15);<br>
        smoothFilter-><wbr>SetRelaxationFactor(0.1);<br>
        smoothFilter-><wbr>FeatureEdgeSmoothingOff();<br>
        smoothFilter-><wbr>BoundarySmoothingOn();<br>
        smoothFilter->Update();<br>
<br>
        // Update normals on newly smoothed polydata<br>
        vtkSmartPointer<<wbr>vtkPolyDataNormals> normals =<br>
vtkSmartPointer<<wbr>vtkPolyDataNormals>::New();<br>
        normals->SetInputConnection(<wbr>smoothFilter->GetOutputPort())<wbr>;<br>
        normals-><wbr>ComputePointNormalsOn();<br>
        normals->ComputeCellNormalsOn(<wbr>);<br>
        normals->Update();<br>
<br>
        vtkSmartPointer<<wbr>vtkPolyDataMapper> mapper =<br>
        vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();<br>
        mapper->SetInputConnection(<wbr>normals->GetOutputPort());<br>
        mapper->ScalarVisibilityOff();<br>
<br>
        vtkSmartPointer<vtkActor> actor =<br>
        vtkSmartPointer<vtkActor>::<wbr>New();<br>
        actor->SetMapper(mapper);<br>
        actor->GetProperty()-><wbr>SetInterpolationToFlat();<br>
        actor->GetProperty()-><wbr>SetOpacity(0.8);<br>
<br>
        ren->AddActor(actor);<br>
        actors.push_back(actor);<br>
    }<br>
<br>
    /*****************************<wbr>*****************************/<br>
<br>
    // Set the custom type to use for interaction.<br>
    vtkSmartPointer<<wbr>MouseInteractorHighLightActor> style =<br>
    vtkSmartPointer<<wbr>MouseInteractorHighLightActor><wbr>::New();<br>
    style->SetDefaultRenderer(ren)<wbr>;<br>
<br>
    interactor->SetRenderWindow(<wbr>renWin.GetPointer());<br>
    interactor-><wbr>SetInteractorStyle(style);<br>
<br>
    /*****************************<wbr>*****************************/<br>
<br>
    ren->SetBackground(0.87, 0.88, 0.91);<br>
    ren->ResetCamera();<br>
    *interactor->Initialize();*<br>
<br>
    vtkOpenGLCamera *camera = (vtkOpenGLCamera *)ren->GetActiveCamera();<br>
    // camera default position set at (4.68744, 2.67252, 360.229)<br>
    camera->SetPosition(4, 2, 360);<br>
    camera->SetViewUp(0,1,0); // controls "up" direction for camera<br>
}<br>
<br>
<br>
void display() {<br>
    // Enable depth testing. Demonstrates OpenGL context being managed by<br>
external<br>
    // application i.e. GLUT in this case.<br>
    glEnable(GL_DEPTH_TEST);<br>
<br>
    // Buffers being managed by external application i.e. GLUT in this case.<br>
    glClearColor(0.87f, 0.88f, 0.91f, 1.0f); // Set background color to gray<br>
and opaque<br>
    glClearDepth(1.0f);<br>
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the color<br>
buffer<br>
<br>
    glFlush();  // Render now<br>
<br>
    glEnable(GL_LIGHTING);<br>
    glEnable(GL_LIGHT0);<br>
<br>
    //interactor->Render();<br>
    externalVTKWidget-><wbr>GetRenderWindow()->Render();<br>
    glutSwapBuffers();<br>
}<br>
<br>
Thanks,<br>
Elaine<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkRenderWindowInteractor-with-custom-render-loop-tp5744540.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/vtkRenderWindowInteractor-<wbr>with-custom-render-loop-<wbr>tp5744540.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><div dir="ltr">-- <br></div><div class="m_-3906093223114168208gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div class="m_-3906093223114168208inbox-markdown-here-wrapper" style="font-family:'proza libre',sans-serif;color:rgb(0,56,107)"><h5 id="m_-3906093223114168208inbox-sankhesh-jhaveri" style="margin:1.3em 0px 1em;padding:0px;font-size:1.1em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-weight:bold;color:rgb(11,65,148)">Sankhesh Jhaveri</h5>
<h6 id="m_-3906093223114168208inbox--sr-research-development-engineer-kitware-http-www-kitware-com-518-881-4417" style="margin:1.3em 0px 1em;padding:0px;font-size:1em;color:rgb(11,83,148);font-family:'open sans',sans-serif;font-weight:normal"><em>Sr. Research & Development Engineer</em> | <a href="http://www.kitware.com/" target="_blank">Kitware</a> | <a href="tel:(518)%20881-4417" value="+15188814417" target="_blank">(518) 881-4417</a></h6>
<div title="MDH:PGIgc3R5bGU9ImZvbnQtZmFtaWx5OiB2ZXJkYW5hLCBzYW5zLXN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0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px">​</div></div></div></div>
</font></span></blockquote></div><br></div>