A plug-in for creating a 3D video

This topic has been viewed 5004 times and has 2 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
tibihan
Posts: 7
Joined: Tue Mar 09, 2010 7:30 am
Country: France

A plug-in for creating a 3D video

Post by tibihan »

[font=times new roman]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:

Code: Select all

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.
[/font]

Code: Select all

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();
}
[font=times new roman]I hope that there are not much changes to do. And I thank you in advance for your help.[/font]
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: A plug-in for creating a 3D video

Post by Puybaret »

a) If you want to change the location of the message dialog box, use the following statements:

Code: Select all

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. [;)]
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).

Code: Select all

final Robot robot = new Robot();
EventQueue.invokeLater(new Runnable() {
    public void run() {
      robot.createScreenCapture(...);
    } 
  });
c) I don't see any error in your code. [:(]
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
tibihan
Posts: 7
Joined: Tue Mar 09, 2010 7:30 am
Country: France

Re: A plug-in for creating a 3D video

Post by tibihan »

Thank you very much for your help.

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

Who is online

Users browsing this forum: No registered users and 1 guest