[vtkusers] Java vs. TCL using RIBExporter
Jeff Lee
jeff at cdnorthamerica.com
Mon Dec 4 09:13:45 EST 2000
Christian,
In tcl, the following lines enter you into an event loop:
# prevent the tk window from showing up then start the event loop
wm withdraw .
iren SetUserMethod {wm deiconify .vtkInteract}
In your java code, however, you have no such mechanism to enter you into an event loop. One
way would be to
add an "iren.Start()" somewhere after the "iren.Render()" statement. In addition, you could
set a user method
which would write the file every time the user presses the "u" key. I have done this and
included it here.
Good luck,
-Jeff
Christian Poecher wrote:
> Hi,
>
> I would like to fly through a scenery and take several "snapshots" of the
> scenery and export them to a RIB file, so I can render them and finally make
> a high-quality video of it.
> I tested some TCL-examples and translated them into Java. There was a
> strange difference between those versions: The TCL-version exports a RIB and
> runs on and the Java-version exports the RIB and closes after the file is
> exported. I checked the TCL and Java versions for differences and could find
> none. Is this an error in the Java wrapper, or have I forgotten something?
> You might want to see the code:
> Java:
> http://www.fortunecity.de/wolkenkratzer/silicon/613/RIBPropertyTest.java
> TCL: (start dentedTest.tcl)
> http://www.fortunecity.de/wolkenkratzer/silicon/613/dented.tcl
> http://www.fortunecity.de/wolkenkratzer/silicon/613/dentedTest.tcl
> http://www.fortunecity.de/wolkenkratzer/silicon/613/colors.tcl
> http://www.fortunecity.de/wolkenkratzer/silicon/613/vtkInt.tcl
>
> TIA, Chris
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
--
J.A. Lee
Software Engineer
Computational Dynamics North America
3 Schoolhouse Lane
Etna NH, 03750
ph: 603-643-9993 x109, fax: 603-643-9994
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20001204/166133b0/attachment.htm>
-------------- next part --------------
/**
* Title: VTK RIB Exporter Test
* Description: Testing to export a scene to a RIB-File which could be processed by BMRT. Goal should be to create a video of a flightpath through the scenery.
* Copyright: Copyright (c) 2000
* Company: ICOM Consulting GmbH
* @author Christian Poecher
* @version 1.0
*/
import vtk.*;
public class RIBPropertyTest {
vtkRenderer ren = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
vtkRIBExporter rib = new vtkRIBExporter();
vtkRIBProperty den1 = new vtkRIBProperty();
vtkRIBProperty den2 = new vtkRIBProperty();
vtkRIBProperty den3 = new vtkRIBProperty();
vtkRIBProperty den4 = new vtkRIBProperty();
vtkRIBProperty den5 = new vtkRIBProperty();
vtkRIBProperty den6 = new vtkRIBProperty();
vtkRIBProperty den7 = new vtkRIBProperty();
vtkRIBProperty den8 = new vtkRIBProperty();
vtkRIBProperty den9 = new vtkRIBProperty();
vtkSphereSource sphere = new vtkSphereSource();
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
vtkActor act1 = new vtkActor();
vtkActor act2 = new vtkActor();
vtkActor act3 = new vtkActor();
vtkActor act4 = new vtkActor();
vtkActor act5 = new vtkActor();
vtkActor act6 = new vtkActor();
vtkActor act7 = new vtkActor();
vtkActor act8 = new vtkActor();
vtkActor act9 = new vtkActor();
public RIBPropertyTest() {
//Initialize Renderer, RenWin and the Interactor
renWin.AddRenderer(ren);
iren.SetRenderWindow(renWin);
//Create sphrereSource and the Mapper
sphere.SetPhiResolution(20);
sphere.SetThetaResolution(20);
mapper.SetInput(sphere.GetOutput());
//Making the 9 actors and set their position
act1.SetMapper(mapper);
act2.SetMapper(mapper);
act3.SetMapper(mapper);
act4.SetMapper(mapper);
act5.SetMapper(mapper);
act6.SetMapper(mapper);
act7.SetMapper(mapper);
act8.SetMapper(mapper);
act9.SetMapper(mapper);
act1.SetPosition(-1.5, 1.5, 0);
act2.SetPosition(0, 1.5, 0);
act3.SetPosition(1.5, 1.5, 0);
act4.SetPosition(-1.5, 0, 0);
act5.SetPosition(0, 0, 0);
act6.SetPosition(1.5, 0, 0);
act7.SetPosition(-1.5, -1.5, 0);
act8.SetPosition(0, -1.5, 0);
act9.SetPosition(1.5, -1.5, 0);
//Add those Actors to the Renderer.
ren.AddActor(act1);
ren.AddActor(act2);
ren.AddActor(act3);
ren.AddActor(act4);
ren.AddActor(act5);
ren.AddActor(act6);
ren.AddActor(act7);
ren.AddActor(act8);
ren.AddActor(act9);
//Prepare surfaces.
den1.SetVariable("Km", "float");
den1.SetParameter("Km", "1");
den1.SetDisplacementShader("dented");
den1.SetSurfaceShader("plactic");
den2.SetVariable("Km", "float");
den2.SetParameter("Km", "2");
den2.SetDisplacementShader("dented");
den2.SetSurfaceShader("plactic");
den3.SetVariable("Km", "float");
den3.SetParameter("Km", "3");
den3.SetDisplacementShader("dented");
den3.SetSurfaceShader("plactic");
den4.SetVariable("Km", "float");
den4.SetParameter("Km", "4");
den4.SetDisplacementShader("dented");
den4.SetSurfaceShader("plactic");
den5.SetVariable("Km", "float");
den5.SetParameter("Km", "5");
den5.SetDisplacementShader("dented");
den5.SetSurfaceShader("plactic");
den6.SetVariable("Km", "float");
den6.SetParameter("Km", "6");
den6.SetDisplacementShader("dented");
den6.SetSurfaceShader("plactic");
den7.SetVariable("Km", "float");
den7.SetParameter("Km", "7");
den7.SetDisplacementShader("dented");
den7.SetSurfaceShader("plactic");
den8.SetVariable("Km", "float");
den8.SetParameter("Km", "8");
den8.SetDisplacementShader("dented");
den8.SetSurfaceShader("plactic");
den9.SetVariable("Km", "float");
den9.SetParameter("Km", "9");
den9.SetDisplacementShader("dented");
den9.SetSurfaceShader("plactic");
//Set surfaces.
act1.SetProperty(den1);
act2.SetProperty(den2);
act3.SetProperty(den3);
act4.SetProperty(den4);
act5.SetProperty(den5);
act6.SetProperty(den6);
act7.SetProperty(den7);
act8.SetProperty(den8);
act9.SetProperty(den9);
//Setting other stuff and render it.
ren.SetBackground(0.1, 0.2, 0.4);
renWin.SetSize(640, 480);
iren.Initialize();
renWin.Render();
iren.SetUserMethod(new RIBwriter(), "writeRIB");
iren.Start();
}
public static void main(String[] args) {
System.loadLibrary("vtkJava");
RIBPropertyTest RIBPropertyTest1 = new RIBPropertyTest();
}
public class RIBwriter {
public RIBwriter(){}
public void writeRIB(){
System.out.println("writing file");
//Write the pic to a file.
rib.SetRenderWindow(renWin);
rib.SetFilePrefix("dented");
rib.BackgroundOff();
rib.Write();
}
}
}
More information about the vtkusers
mailing list