deleted

edited December 2015 in Library Questions

i have several OBJ files from my 3D CAD Design and i will like to bring it in to processing for interactive gui for arduino project

Answers

  • There is an example in Basics->Shape->loadDisplayOBJ

  • edited November 2015

    no yes i just noticed this tho it was not there i stumble across it by messing around with the ide add library, but i have a model obj file of a brain and i want to know how do i increase rendering speed or size of model in processing ? or do i gotta do all that in my 3d modeling prog?

  • Easiest way is to just add scale(); - see the edited example below. This simply imports the rocket in the example twice the size i.e. scale(2);

     PShape rocket;
    
        float ry;
    
        public void setup() {
          size(640, 360, P3D);
    
          rocket = loadShape("rocket.obj");
        }
    
        public void draw() {
          background(0);
          lights();
    
          translate(width/2, height/2 + 100, -200);
          rotateZ(PI);
          rotateY(ry);
          scale(2);
          shape(rocket);
    
          ry += 0.02;
        }
    
  • @PDF197 does scale() takes any arguments in the constructor? i mean am i putting the brain obj inside the "scale(brain)"?

  • No, scale(brain) would not work.

    I do not know how far you have gone with this, or how much you know already so a hint... Someone might have a better way, but if you want to change the scale using a sensor input from Arduino think this way this...

    The scale(); function needs a float (number) to know how much to scale the model that is being imported. For example, scale(2); would import your model at double the original size.

    What you can do is define your own float at the start of your sketch, e.g. float ScaleBrain = 1. Use scale(ScaleBrain) to create a variable, you can then control with your Arduino input.

    This uses the same example, but with a few changes. This assumes your brain file is called brain.obj.

        PShape brain;
    
        float ScaleBrain = 1;
        //float ScaleBrain = random(1,5);
        float ry;
    
        public void setup() {
          size(640, 360, P3D);
    
          brain = loadShape("brain.obj");
        }
    
        public void draw() {
          background(0);
          lights();
    
          translate(width/2, height/2 + 100, -200);
          rotateZ(PI);
          rotateY(ry);
          scale(ScaleBrain);
          shape(brain);
    
          ry += 0.02;
        }
    
  • i hear you ill keep this info in mind BUT this is not a arduino in or output this is just a obj model ONCE im close to done then the arduino will communicate via rs232 to processing but this is not where im at NOW im simply trying to have the brain model "imported" then i want to have it interact with the serial com port....

    tho as in now i did try your sketch above but i got this error about memory ? im not sure i uploaded a screenshot hope this helps you help me,Screenshot (72)

  • edited December 2015

    That suggests the file you are importing is quite big. How many vertices/faces etc. does it have? Try this:

    Open Processing > Go to preferences > Tick the "Increase Maximum Memory... box > increase to 512Mb (or more) > OK > Run sketch again.

    memory

  • hmmm i never thought of the memory increase, ill try that tho the obj is 45mb wow i dint even kno that ! im not sure about the vertices tho i did found all this other info tho. that memory in Processing was @256 ill jacked it up to 1000mb i did not noticed a diff, i even got this sketch that run in draw six gif and a face dtection sketch i merged to it from a example and the gif are all lagging like as 1 fps even tho i have it set to 100 frames here is the setup & draw but the facedetection dont even do its job the cam opens up but dont detect squat! ughh

    Cap

    public void setup() 
    {
      size(1280, 900);
      frameRate(100);
      video = new Capture(this, 640, 360,"Microsoft LifeCam Front" ); // this,640,480"USB2.0 Camera"
      //                     Side.0-Down.0   
      opencv = new OpenCV(this, 900,900);//width/scl, height/scl
      opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  
    
      faceList = new ArrayList<Face>();
    
      video.start();
      println("Cortan Visual GUI " + Gif.version());
    
      Cortan = new Gif(this, "Cortan.gif");
      Cortan.loop();
      b1= new Gif(this, "b1.gif");
      b1.loop();
      c= new Gif(this, "c.gif");
      c.loop();
      x= new Gif(this, "x.gif");
      x.loop();  
      aa= new Gif(this, "aa.gif");
      aa.loop();
      bb= new Gif(this, "bb.gif");
      bb.loop();
      cc= new Gif(this, "cc.gif");
      cc.loop();
      ccc= new Gif(this, "ccc.gif");
      ccc.loop();  
      silo= new Gif(this, "silo.gif");
      silo.loop();
    }
    
    void draw() 
    {
      background(0);  
      opencv.loadImage(video);
      image(video, 0, 0 );
      detectFaces();
      //      X.0-Y.0    
      image(b1, 650, 0);
      image(c, 650, 100);
      image(aa, 10, 700);
      image(bb, 0, 400);
      image(cc, 0, 550);
      image(ccc, 900, 100/2);
      image(silo, 900, 300);
      image(x, 900, 200);
      image(Cortan, 400, 360);//, 0, width / 2 - Cortan.height / 2);
      //image(animation[(int) (animation.length / (float) (width) * mouseX)], width - 10 - animation[0].width, height / 2 - animation[0].height / 2);
      // Draw all the faces
      for (int i = 0; i < faces.length; i++) 
      {
        noFill();
        strokeWeight(5);
        stroke(255, 0, 0);
        //rect(faces[i].x*scl,faces[i].y*scl,faces[i].width*scl,faces[i].height*scl);
        rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
        saveFrame("DBase/Meet-####.jpg");//********I ADDED THIS**********
      }
      for (Face f : faceList) 
      {
        strokeWeight(1);
        f.display();
      }
    }
    

    Screenshot (68)

This discussion has been closed.