Bezier shapes to .obj

edited July 2015 in How To...

Hello, I'm generating shapes and I have issues exporting them to .obj files via OBJExport, when I build a shape with beginShape(); and vertex(); function only, everything works well and shapes look as exported, when I import them into Blender or Modo.

As soon as I make the shapes curved with bezierVertex(). The exported .obj files become distorted when imported into Blender or Modo.

What am I doing wrong? Is there a better way to get this shape into 3D software? Thank you for your time in advance.

A shape generated in Processing:

reg

Bezier control points set-up:

ctrl

The same shape after export to .obj and after import into blender:

blend1

import nervoussystem.obj.*;

// Coordinates of the anchor and control points are set manually for now.
PVector pointA = new PVector(0,-50, 0); 
PVector pointActrl = new PVector(pointA.x + 35,pointA.y ,0);

PVector pointB = new PVector(100, -100, 0);
PVector pointBctrl = new PVector(pointB.x-35, pointB.y+35, 0);

PVector pointC = new PVector(pointB.x, pointB.y+50,0);
PVector pointCctrl = new PVector(pointBctrl.x, pointBctrl.y+45, 0);

PVector pointD = new PVector(0, 0, 0);
PVector pointDctrl = new PVector(pointActrl.x, pointD.y, 0 );

void setup(){ 

  size(400, 400, P3D);

  noFill();
  stroke(0);

  //beginRecord("nervoussystem.obj.OBJExport", "new_world1.obj"); 

  translate(width/2, height/2);

  beginShape(); 
    vertex(pointA.x,pointA.y, pointA.z); // POINT A

    bezierVertex(pointActrl.x, pointActrl.y, pointActrl.z,    pointBctrl.x, pointBctrl.y, pointBctrl.z,     pointB.x, pointB.y, pointB.z); //POINT B

    vertex( pointC.x, pointC.y, pointC.z); // POINT C

    bezierVertex( pointCctrl.x, pointCctrl.y, pointCctrl.z,    pointDctrl.x, pointDctrl.y, pointDctrl.z,     pointD.x, pointD.y, pointD.z); //POINT D  
  endShape(CLOSE); 

  //endRecord();

  ctrl_line(pointB, pointBctrl); //display bezier control points, will not be exported into .obj
  ctrl_line(pointA, pointActrl);
  ctrl_line(pointC, pointCctrl);
  ctrl_line(pointD, pointDctrl);  

}

void draw() {

}

void ctrl_line(PVector anchor, PVector control){

  stroke(255, 0, 0);
  strokeWeight(1);

  line(anchor.x, anchor.y, control.x, control.y);
  fill(255,0,0);
  noStroke();
  ellipse(control.x, control.y, 6, 6);
}

Answers

  • edited July 2015

    Hi again, if anyone would be struggling with the same issue, I figured this out. I no longer use .obj export and instead use the .dxf export lib. This way bezier shapes' geometry imports into 3D software as it should. Blender has .dxf import add-on, but when I import my .dxf shapes created with the code above, nothing displays and nothings seems to be added to Blender's layer list. However, when imported into Modo or Cinema 4D the shapes work well and display properly.

Sign In or Register to comment.