Hi there,
I've been trying to get the vertices of an object via OBJLoader. At this moment, i'm able to get all the vertices from the loop function below. However, I can't call the variable 'vert' from outside the class and even when I want to call it from outside the loop, I only got 1 vertex.
I need to be able to call all vertices of the object from outside the class in order to use the vertices for constrain
purposes.
Below is the codes and you can just use any obj file and rename it to test.obj. I'm using Processing 1.5.1
Could someone help me to solve this and point out my mistakes?
Thank you all
- import saito.objloader.*;
- import java.util.HashMap;
- Test t1;
- void setup() {
- size(640, 360, P3D);
- t1 = new Test(this, "test.model");
- }
- void draw() {
- background(255);
- fill(210,180,140);
- t1.draw();
- }
- ---------------------------------------------------------------------------------------
- class Test{
- Object test;
- Bone(PApplet _applet, String model_name) {
- test = new Object (_applet, "test.obj");
- }
- void draw() {
- pushMatrix();
- translate(65, 0, 0);
- test.model.draw();
- popMatrix();
- }
- }
- -------------------------------------------
- import saito.objloader.*;
- class Object
- {
- OBJModel model;
- PVector vert;
- Object(PApplet _applet, String model_name)
- {
- model = new OBJModel(_applet, model_name, "relative", TRIANGLES);
- model.disableDebug();
- //model.translateToCenter();
- model.disableMaterial();
- model.scale(40);
- for (int i = 0; i < model.getVertexCount(); i++)
- {
- vert = model.getVertex(i);
- print(vert);
- }
- }
- }
1