Loading...
Logo
Processing Forum

Spline loader?

in Contributed Library Questions  •  2 years ago  
Hi guys, I'm trying to import an obj object containing few Splines, for this I'm using the library OBJLoader. I thought It would work no problem but I can't see the Splines because I think processing is not loaded them.
Somebody know who loader Spline in processing?
Thanks.

Copy code
  1. import saito.objloader.*;

    OBJModel model ;

    float rotX, rotY;

    void setup()
    {
        size(400, 400, P3D);

        model = new OBJModel(this, "Box.obj", "absolute", POLYGON);
        model.enableDebug();

        model.scale(20);
        model.translateToCenter();


        stroke(90,200,225);
    }

    void draw()
    {
        background(56,56,56);
        lights();
        pushMatrix();
        translate(width/2, height/2, 0);
        rotateX(rotY);
        rotateY(rotX);

        model.draw();

        popMatrix();
    }
    void keyPressed()
    {

        if(key=='1')
            model.shapeMode(POINTS);
         if(key=='2')
            model.shapeMode(LINES);
         if(key=='3')
            model.shapeMode(POLYGON);
    }

    void mouseDragged()
    {
        rotX += (mouseX - pmouseX) * 0.01;
        rotY -= (mouseY - pmouseY) * 0.01;
    }

Obj code:
Copy code
  1. # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
    # File Created: 12.10.2011 18:32:04

    #
    # shape Shape
    #

    # 0 vertices

    g Shape

    #
    # object Box
    #

    v  -5.0000 -5.0000 5.0000
    v  5.0000 -5.0000 5.0000
    v  -5.0000 -5.0000 -5.0000
    v  5.0000 -5.0000 -5.0000
    v  -5.0000 5.0000 5.0000
    v  5.0000 5.0000 5.0000
    v  -5.0000 5.0000 -5.0000
    v  5.0000 5.0000 -5.0000
    # 8 vertices

    g Box
    f 1 3 4 2
    f 5 6 8 7
    f 1 2 6 5
    f 2 4 8 6
    f 4 3 7 8
    f 3 1 5 7
    # 6 polygons

    #
    # shape Splines
    #

    v  -6.9834 6.9834 -6.9834
    v  6.9834 -6.9834 6.9834
    v  6.9834 6.9834 6.9834
    v  -6.9834 -6.9834 -6.9834
    v  -6.9834 6.9834 6.9834
    v  6.9834 -6.9834 -6.9834
    v  6.9834 6.9834 -6.9834
    v  -6.9834 -6.9834 6.9834
    # 8 vertices

    g Splines
    l 9 10
    l 11 12
    l 13 14
    l 15 16


Replies(1)

Re: Spline loader?

2 years ago
A traditional way and impractical It's to convert the code for yourself, this works for simple objects.
Obj code:
Copy code
  1. # shape Splines
    #

    v  -7.000 7.000 -7.000
    v  7.000 -7.000 7.000
    v  7.000 7.000 7.000
    v  -7.000 -7.000 -7.000
    v  -7.000 7.000 7.000
    v  7.000 -7.000 -7.000
    v  7.000 7.000 -7.000
    v  -7.000 -7.000 7.000
    # 8 vertices

    g Splines
    l 9 10
    l 11 12
    l 13 14
    l 15 16
Processing code:
Copy code
  1. pushMatrix();
    scale(20);
    line(-7, 7, -7, 7, -7,7);
    line(7, 7, 7, -7, -7,-7);
    line(-7, 7, 7, 7, -7,-7);
    line(7, 7, -7, -7, -7,7);
    popMatrix();