【发布时间】:2018-05-15 02:49:29
【问题描述】:
我已经在 JPCT 中浏览了 3D 对象 documentation,但我找不到仅沿 y 轴缩放 3D 对象[a Cylinder] 的方法。我的世界有多个对象,我的目标是缩放一个特定对象。欣赏任何线索。谢谢!!
类似于这个 openGL 函数 glScalef(1,10,1)。
【问题讨论】:
我已经在 JPCT 中浏览了 3D 对象 documentation,但我找不到仅沿 y 轴缩放 3D 对象[a Cylinder] 的方法。我的世界有多个对象,我的目标是缩放一个特定对象。欣赏任何线索。谢谢!!
类似于这个 openGL 函数 glScalef(1,10,1)。
【问题讨论】:
用户 AGP 在此处列出了实现此目的的方法: JPCT Forums
它基本上使用了以下顶点控制器类,我也成功使用过:
class VertexController extends GenericVertexController
{
public VertexController(Object3D toCheck) {
super.init(toCheck.getMesh(), true);
}
protected void scale(SimpleVector scale)
{
SimpleVector[] vertices = getSourceMesh();
SimpleVector[] destination = getDestinationMesh();
for (int i = 0; i < vertices.length; i++)
{
vertices[i].x *= scale.x;
vertices[i].y *= scale.y;
vertices[i].z *= scale.z;
destination[i].x = vertices[i].x;
destination[i].y = vertices[i].y;
destination[i].z = vertices[i].z;
}
this.updateMesh();
}
public void apply() {}
}
你可以这样称呼它:
vertexController = new VertexController(object);
然后在您的 onDrawFrame 或任何需要的地方:
vertexController.scale(new SimpleVector(1,1.5f,1));
【讨论】: