处理 3d 对象 .obj 导入 [英] Processing 3d object .obj import

查看:29
本文介绍了处理 3d 对象 .obj 导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从网上找到的 .obj 文件中导入 Processing 中的 3d 对象.我已经看到有几种方法可以将 objs 导入到场景中.

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.

我在这个例子中使用了 PShape 并且在 这里找到了一个 obj 文件.我从纹理工作的示例>基本>形状>LoadDisplayObJ 示例开始.

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.

我能够使用 loadShape 函数导入 obj 文件,但没有显示纹理和颜色.我错过了什么吗?我也应该导入 .mtl 文件吗?

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?

代码如下:

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

推荐答案

是的,您也可以导入该文件,如果您有类似 .jpg 之类的内容,它将成为您的纹理.

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

这篇关于处理 3d 对象 .obj 导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆