处理3D对象.OBJ进口对象、OBJ

2023-09-08 01:12:56 作者:秀恩愛強心跳

我试图在处理从网络上找到的.obj文件导入3D对象。我已经看到了,有几种方法可以导入OBJ文件到场景中。

我在这个例子中使用PShape和OBJ文件中找到这里。我从一例子>基本>形状> LoadDisplayObJ样品中的纹理工作全面启动。

我能够导入使用loadShape功能obj的文件,但没有任何纹理和颜色进行显示。我失去了一些东西?我应该导入.mtl文件中呢?

下面是code:

  PShape的房子;

浮动RY;

公共无效设置(){
  大小(640,360,P3D);

  房子= loadShape(小屋/​​ huts.obj);
}

公共无效平局(){
  背景(100);
  灯();

  平移(宽度/ 3,高度/ 3,0);
  // rotateX(QUARTER_PI * 1.0);
  rotateZ(-PI);

  rotateY(图(mouseX,mouseY的,宽度,2.5,-2.5));

  // rotateY(RY);
  pushMatrix();
  翻译(1500,-400,0);
  形状(房子);
  popMatrix();
 }
 

解决方案

是的,你有过的文件导入,如果你碰到这样的 .JPG 即会是你的纹理。

3DMAX当前选中的一个或多个对象参考了其他对象

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

解决方案

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