【问题标题】:Scale along a particular axis of an 3D object in JPCT在 JPCT 中沿 3D 对象的特定轴缩放
【发布时间】:2018-05-15 02:49:29
【问题描述】:

我已经在 J​​PCT 中浏览了 3D 对象 documentation,但我找不到仅沿 y 轴缩放 3D 对象[a Cylinder] 的方法。我的世界有多个对象,我的目标是缩放一个特定对象。欣赏任何线索。谢谢!!

类似于这个 openGL 函数 glScalef(1,10,1)。

【问题讨论】:

    标签: opengl jpct


    【解决方案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));

    【讨论】:

      猜你喜欢
      • 2013-08-13
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 2020-11-10
      • 1970-01-01
      • 2017-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多