Print at Dec 21, 2025, 7:22:49 AM
Posted by tibihan at Mar 9, 2010, 6:56:44 PM
A plug-in for creating a 3D video
Hi,

1-As a teacher, I participate to a project with young students and I would like to have a tool to produce videos.
I have started writing a plug-in. Although I am a newbie in Java, I have got a first encouraging result.
Then, I have just seen your project " Creating 3D videos" on your blog. It would be probably perfect for us. But unfortunately, we don't have much time and I would like to go further quickly. Perhaps you can help me on some points.

2- I have developed a tool – an Open Office Spreadsheet – to help building a list of all the necessaries characteristics of the camera for each image then produce a text-file. My plug-in reads this file and moves the observer in the plan. The visit is shown in the 3D-view.

3- There are three difficulties left:

a) A first option enables to follow the movements image by image, displaying a message.
But the instruction:
JOptionPane.showMessageDialog(null, "");
centers the message. I don't know how to choose a better position.

b) A second option enables to chain the movements without displaying a message. But the intermediate positions are not shown. I suppose that I should send a message to a listener of the 3D view to say that something has changed; but I don't know how to do it.

c) Most important, I would like that a third option create and save the images as the "Render Tool" does. Here is my code. It does not work.

PhotoRenderer.Quality qual = PhotoRenderer.Quality.LOW;
BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_3BYTE_BGR );
PhotoRenderer photRenderer = null;
try {
photRenderer = new PhotoRenderer(getHome(), qual);
} catch (IOException e) {
JOptionPane.showMessageDialog(null, String.format("%s ","exception: " + e.getMessage()));

e.printStackTrace();
}
ImageObserver observer = null;
photRenderer.render(image, getHome().getObserverCamera(), observer);

File output = new File("c:/Im1.png");
try {
ImageIO.write(image, "PNG", output);
} catch (IOException e) {
JOptionPane.showMessageDialog(null, String.format("%s ","exception: " + e.printStackTrace();
}

I hope that there are not much changes to do. And I thank you in advance for your help.

Posted by Puybaret at Mar 10, 2010, 7:44:06 AM
Re: A plug-in for creating a 3D video
a) If you want to change the location of the message dialog box, use the following statements:

JOptionPane optionPane = new JOptionPane("Message");
JDialog dialog = optionPane.createDialog(JOptionPane.getRootFrame(), "Titre");
// Change location
dialog.setLocation(10, 10);
dialog.setVisible(true);
dialog.dispose();


b) You're right, displaying a message to wait for the end of each move in the 3D view is probably not the best solution. wink
Miserably, the solution is not straightforward. The best solution would be to wait for an event that tells you that a move of the camera is finished in the 3D view, but this would oblige you to create and display a 3D view that would use the canvas3DPostRendered method I added for Canvas3D instances (see line 244 in HomeComponent for a real example).
If you capture images with Robot class (as I suppose you do), a simpler solution might be to include your calls to createScreenCapture in EventQueue invokeLater or invokeAndWait calls (the choice depends on the thread in which you run your video program).

final Robot robot = new Robot();
EventQueue.invokeLater(new Runnable() {
public void run() {
robot.createScreenCapture(...);
}
});


c) I don't see any error in your code. sad
It looks almost the same as the one I used in VideoPanel.PhotoImageGenerator class. What exceptions do you get? Do you use multithreading?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by tibihan at Mar 10, 2010, 4:29:46 PM
Re: A plug-in for creating a 3D video
Thank you very much for your help.

I have not much time right now. I shall study your ideas this week-end.