Java/Processing - 导入的对象在相机附近消失
Java/Processing - imported objects disappear close to camera
我已经将一个对象导入到我在 Blender 中创建的 Processing 中。
下面的代码有效,对象出现但看起来很小(或很远)。
如果我尝试使用 PeasyCamm 靠近对象,它会在它足够接近以正确查看之前完全消失。我唯一能想到的是物体本身非常靠近相机但实际上很小......
我试图缩放对象,但调用了
myshape.getVertexCount()
表示我的对象没有顶点,我所做的任何事情似乎都没有改变任何东西。我有一个微小的渲染对象,它在大约四分之一屏幕高度处消失。
PShape myshape;
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam camera;
void setup(){
size( 640, 480, P3D);
camera = new PeasyCam(this, 0, 0, 0, 50);
frameRate(10);
myshape = loadShape("test.obj");
for (int i = 0; i < myshape.getVertexCount(); i++){
PVector v = myshape.getVertex(i);
println("Inside");
v.x *= 45;
v.y *= 45;
v.z *= 45;
myshape.setVertex(i, v);
}
}
void draw(){
background(0);
shape(myshape);
}
getVertexCount()
和 getVertex()
函数仅适用于您在代码中使用 vertex()
函数创建的形状。可以在 the reference.
中找到更多信息
如果您只想缩放形状,则只需使用 scale()
功能即可。这是一些示例代码,将您的对象缩放 20
:
PShape myshape;
void setup() {
size(500, 500, P3D);
myshape = loadShape("test.obj");
}
void draw() {
background(0);
translate(width/2, height/2, 100);
scale(20);
shape(myshape);
}
编辑: 显然你仍然可以到达目标文件中的顶点,只是不像调用 getVertex()
函数那么简单。首先,您必须遍历形状的子项,然后对子项调用 getVertex()
。 this forum post 中的更多信息(参见 jeremydouglass 的回答)。
我已经将一个对象导入到我在 Blender 中创建的 Processing 中。
下面的代码有效,对象出现但看起来很小(或很远)。
如果我尝试使用 PeasyCamm 靠近对象,它会在它足够接近以正确查看之前完全消失。我唯一能想到的是物体本身非常靠近相机但实际上很小......
我试图缩放对象,但调用了
myshape.getVertexCount()
表示我的对象没有顶点,我所做的任何事情似乎都没有改变任何东西。我有一个微小的渲染对象,它在大约四分之一屏幕高度处消失。
PShape myshape;
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam camera;
void setup(){
size( 640, 480, P3D);
camera = new PeasyCam(this, 0, 0, 0, 50);
frameRate(10);
myshape = loadShape("test.obj");
for (int i = 0; i < myshape.getVertexCount(); i++){
PVector v = myshape.getVertex(i);
println("Inside");
v.x *= 45;
v.y *= 45;
v.z *= 45;
myshape.setVertex(i, v);
}
}
void draw(){
background(0);
shape(myshape);
}
getVertexCount()
和 getVertex()
函数仅适用于您在代码中使用 vertex()
函数创建的形状。可以在 the reference.
如果您只想缩放形状,则只需使用 scale()
功能即可。这是一些示例代码,将您的对象缩放 20
:
PShape myshape;
void setup() {
size(500, 500, P3D);
myshape = loadShape("test.obj");
}
void draw() {
background(0);
translate(width/2, height/2, 100);
scale(20);
shape(myshape);
}
编辑: 显然你仍然可以到达目标文件中的顶点,只是不像调用 getVertex()
函数那么简单。首先,您必须遍历形状的子项,然后对子项调用 getVertex()
。 this forum post 中的更多信息(参见 jeremydouglass 的回答)。