Processing 3d object .obj import

别说谁变了你拦得住时间么 提交于 2019-12-08 02:46:10

问题


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();
 }

回答1:


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



来源:https://stackoverflow.com/questions/15258270/processing-3d-object-obj-import

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!