How to Rotate a 3d model in all its glory?!

edited March 2016 in How To...

I have an existing .step file that contains all the shape/texture information on it.

Assuming I can convert it to an .obj or .svg file, how can I loadShape and rotate it so that the object looks just like when it's opened in autocad/pro-e/etc?

I saw this tutorial ( https://processing.org/tutorials/p3d/ ) but it seems to display everything using vector-like graphics. Also, is there a another tutorial or book on manipulating existing 3d objects in Processing? (as opposed to creating 3d objects)

Tagged:

Answers

  • Answer ✓

    I think I used a lib

    http://www.openprocessing.org/sketch/31784

    there's a tutorial on PShape which can load svg

    https://www.processing.org/tutorials/pshape/

  • Thanks, I couldn't open the sketch (even after adding openprocessing.org & c723113.r13.cf2.rackcdn.com to the java site exceptions list)

    But the youtube video looks great!

    Did you have to do anything other than loadShape to get it to display more than a vector wire object, or did it automatically render it as full textured solid?

  • it runs on my win PC in firefox

    no, the rendering was automatically

    the lib is referred to below in openprocessing

  • I found plenty of example object files to try with (grabcad, yobi3d, tf3dm, shapeways, thingiverse, 3dwarehouse.sketchup, the3dstudio, turbosquid, 3dexport,etc). However they all behave the same. For example, when I run this:

    PShape house;    
    float ry;
    
    public void setup() {
      size(640, 360, P3D);
      house = loadShape("Montesout.obj");
    }
    
    public void draw() {
      background(100);
      lights();
    
      translate(width/3, height/3, 0); 
      //rotateX(QUARTER_PI * 1.0);            
      rotateZ(-PI );
    
      rotateY(map(mouseX, mouseY, width, 2.5, -2.5));
    
      //rotateY(ry);
      pushMatrix();
      translate(1500,-400,0);
      shape(house);
      popMatrix();
     }
    

    Although it displayed without errors, and with no additional libraries, it doesn't look right. The top half is what the .obj file is, and the bottom half is what I see in processing: http://i57.tinypic.com/5kirkl.jpg

    So, then I tried using saitoobjloader :

    import processing.opengl.*; 
    import saito.objloader.*; 
    import peasy.*; 
    
    int detail = 70; 
    color bg= #ffffff; 
    PeasyCam cam; 
    OBJModel model; 
    
    void setup() 
    {
    size(1000 , 600 , OPENGL); 
    model = new OBJModel (this, "Montesout.obj"); 
    cam = new PeasyCam(this, 700); 
    model.scale(0.3); 
    model.translateToCenter(); 
    noStroke(); 
    smooth(); 
    } 
    
    void draw() 
    {
    lights(); 
    background(200);
    smooth(); 
    model.draw(); 
    } 
    
    void lights() 
    { 
    int w=170, m=-422, p=+422; 
    ambientLight(w,w,w); 
    directionalLight(w, w, w, m, m, m); 
    directionalLight(w, w, w, p, p, p);
    directionalLight(w, w, w, m, m, p); 
    directionalLight(w, w, w, p, p, m); 
    }
    

    But how do I install the library into Processing?
    (I get 'No library found for saito.objloader' , 'No library found for peasy')

  • I guess for peasy, use the menu in the IDE and install the library peasycam

    for saito.... maybe drag and drop the jar-file of it onto your sketch in the IDE of p5

    saito I'm not sure whether it's for 1.5.1 only...

    did you read the PShape tutorial? P5 is much more advanced than back when I wrote the little 3D chess sketch...

    ;-)

  • I don't think you need import processing.opengl.*; in p5 version > 2.0

    did you try add lib in the menu in the IDE?

  • Hey all, I've made a lot of progress but just ran smack into OpenGL issues. At one point in time I had a disc twisting and turning in a window based on a joystick. Now I'm getting the following:

    rotateX() can only be used with a renderer that supports 3D, such as P3D or OPENGL. rotateY() can only be used with a renderer that supports 3D, such as P3D or OPENGL. translate(), or this particular variation of it, is not available with this renderer.

    Where do I get these magic libraries? I thought that OpenGL was part of Processing. What's really yanking my chain is that I don't even USE translate in the sketch I'm using. I'd sure appreciate if someone could give me a few pointers to get back on the road.

    Thanks, Joe B

  • edited January 2015

    3D just means

        size (600, 600, OPENGL);
    

    that's it.

    When you say

        size (600, 600);
    

    your sketch is in 2D. Then rotateX() and rotateY() won't work (they are 3D). Also translate with 3 parameters is 3D I guess.

    To make rotateX() and rotateY() work just say

        size (600, 600, OPENGL);
    

    That's true for processing version >= 2.0; for older like 1.5.1 you need addiontally to import opengl lib.

    In processing version >= 2.0 this lib is included.

  • did you make progress?

Sign In or Register to comment.