obj Importation
in
Contributed Library Questions
•
1 year ago
Hello everyone!
I'm trying to make a obj importation, but with a window, like this (i modify an existing file)
But, you will see, there is a problem "the constructor objmodel is undefined", i know it can be a very stupid mistake but if you can help me, it will be cool. Thank to all! (PS: sorry for my english, i'm french)
There is the code:
I'm trying to make a obj importation, but with a window, like this (i modify an existing file)
But, you will see, there is a problem "the constructor objmodel is undefined", i know it can be a very stupid mistake but if you can help me, it will be cool. Thank to all! (PS: sorry for my english, i'm french)
There is the code:
- import saito.objloader.*;
/**
filechooser taken from http://processinghacks.com/hacks:filechooser
@author Tom Carden
*/
import javax.swing.*;
OBJModel obj;
// set system look and feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
// create a file chooser
final JFileChooser fc = new JFileChooser();
// in response to a button click:
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// see if it's an image
// (better to write a function and check for all supported extensions)
if (file.getName().endsWith("obj")) {
// load the image using the given file path
obj = new OBJModel(file.getPath());
obj.debugMode();
if (obj != null) {
// size the window and show the image
size(obj.width,obj.height,P3D);
}
} else {
// just print the contents to the console
// note: loadStrings can take a Java File Object too
String lines[] = loadStrings(file);
for (int i = 0; i < lines.length; i++) {
println(lines[i]);
}
}
} else {
println("Open command cancelled by user.");
}
1