We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am fairly familiar with Java, but not much experience with computer graphics. I am working on a program that takes in serial data, and uses that to manipulate a 3D hand in Processing. I have a hand model that I split into 15 separate components (for each segment that needs to move) in Blender. I couldn't find a way to deform a complex mesh like this (HE-Mesh was all I found, and it didn't seem like it would do the job). Here's my code:
import saito.objloader.*;
import processing.serial.*;
import processing.opengl.*;
String inputString = "";
boolean stringComplete = false;
Serial port; // Create object from Serial class
OBJModel hand; //Creates hand object
void setup() {
size (600, 400, OPENGL); //Sets window size, sets to OpenGL
String portName = Serial.list()[1]; //Sets port to COM3
port = new Serial(this, portName, 9600);
hand = new OBJModel(this, "palm.obj", "t1.obj", "t2.obj", "i1.obj", "i2.obj", "i3.obj", "m1.obj", "m2.obj", "m3.obj", "r1.obj", "r2.obj", "r3.obj", "p1.obj", "p2.obj", "p3.obj");
hand.disableDebug();
hand.scale(150);
hand.translateToCenter();
}
void serialEvent(Serial port) {
while (port.available()>0) {
char inChar = (char)port.read();
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}
}
}
void draw() {
if (stringComplete) {
int[] data = int(split(inputString, ' ')); //Splits string into an integer array
println(inputString);
inputString = ""; //Clears inputString
stringComplete = false;
}
background(200);
lights();
translate(width/2, height/2, 0);
hand.draw();
}
My first issue is that the OBJLoader only seems to be able to load 1-2 files. (The above code says that the constructor is undefined. If I remove all but any two of them, it will render.) Am I supposed to import them as separate objects? Or, maybe it is supposed to be numerous objects in one file? Also, once I have all of these things imported, how do I move them around? I need to be able to move the fingers individually, but also be able to move the entire hand model. A matrix stack seems to be how this is done, but I don't know how to incorporate that into my code. Finally, does the position of the origin matter when I export from Blender? I have them all centered under the palm currently.
I know it's a long string of questions, thanks for the help.
Answers
*How to display. I proofread all of it except the title, figures.
And apparently I can edit the title. Just going to go away now.