UserK
UserK

Reputation: 908

Processing 3d object .obj import

I'm trying to import 3d objects in Processing from .obj files found on the web. I've seen that there are several ways to import objs into the scene.

I'm using PShape in this example and an obj file found here. I've started from the Examples>Basic>Shape>LoadDisplayObJ sample in which textures work.

I was able to import the obj file using the loadShape function but no textures and colors were displayed. Am I missing something? Should I import the .mtl file as well?

Here is the code:

PShape house;

float ry;

public void setup() {
  size(640, 360, P3D);

  house = loadShape("huts/huts.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();
 }

Upvotes: 2

Views: 9868

Answers (1)

Dmx Dmx
Dmx Dmx

Reputation: 36

Yes, you have the import that file too, and if you have something like .jpg that will be your texture.

Upvotes: 2

Related Questions