自迁移出 MediaWiki 以来,本页内容尚未经过审查。如果您愿意帮忙,请查看帮助指南!
如何对内容应用特定的转换
您可以下载本指南 here 的示例来源代码。
每个内容都可以单独完成转换。在应用程序中,这例如由用户通过选择内容并使用鼠标拖动来。
还可以通过 API 轻松应用转换。重要的是要记住,有两种不同类型的转换:局部用于转换,对于每个内容来说都是单独的,以及全局转换,它不是单独的内容,而是适用于集合的视图。
这里讨论局部转换。如何更改全局转换将在后面的 HowTo 中介绍。
对内容应用转换很简单;创建 Universe 并添加内容(请参阅前面的 HowTo)之后,以下代码显示如何创建表示绕 Y 轴 45 度旋转的转换:
// Add the image as an isosurface
Content c = univ.addVoltex(imp);
// Create a new Transform3D object
Transform3D t3d = new Transform3D();
// Make it a 45 degree rotation around the local y-axis
t3d.rotY(45 * Math.PI / 180);
// Apply the transformation to the Content. This concatenates
// the previous present transformation with the specified one
c.applyTransform(t3d);
applyTransform()将一个转换与先前存在的转换连接起来。因此,如果重复上述代码中的applyTransformation(),底部导致整体旋转90度。
还有另一种方法,setTransform(),它不连接变换,而是将其固定为指定的变换:
// setTransform() does not concatenate, but sets the specified
// transformation:
c.setTransform(t3d);
这意味着内容的转换旨在彻底转换操作(即身份),请执行以下操作:
// reset the transformation to the identity
t3d.setIdentity();
c.setTransform(t3d);
还有另一种方法,lock(),可以为内容调用它并阻止进一步的转换。
Content.java的重要方法,关于转换
public void toggleLock();
public void setLocked(boolean b);
public void applyTransform(Transform3D transform);
public void setTransform(Transform3D transform);