与气缸一起工作
Contents
[
Hide
]
自定义偏移顶部
Aspose.3D for Java 允许自定义圆柱体的偏移顶部。为了使用此功能,您可以使用 Cylinder
类的 setOffsetTop()
方法。以下代码段显示了如何自定义偏移顶部:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Java | |
// Create a scene | |
Scene scene = new Scene(); | |
// Initialize cylinder | |
Cylinder cylinder1 = new Cylinder(2, 2, 10, 20, 1, false); | |
// Set OffsetTop | |
cylinder1.setOffsetTop(new Vector3(5, 3, 0)); | |
// Create ChildNode | |
scene.getRootNode().createChildNode(cylinder1).getTransform().setTranslation(10, 0, 0); | |
// Initialize second cylinder without customized OffsetTop | |
Cylinder cylinder2 = new Cylinder(2, 2, 10, 20, 1, false); | |
// Create ChildNode | |
scene.getRootNode().createChildNode(cylinder2); | |
// Save | |
scene.save(RunExamples.getDataDir()+ "CustomizedOffsetTopCylinder.obj", FileFormat.WAVEFRONTOBJ); |
左边的OffsetTop设置为 (5,3,0),很容易看到顶盖移动了,整个躯干也受到了影响。
自定义剪切底部
Aspose.3D for Java 允许自定义圆柱体的剪切底部。为了使用此功能,您可以使用 Cylinder
类的 setShearBottom()
属性。以下代码段显示了如何自定义剪切底部:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Java | |
// Create a scene | |
Scene scene = new Scene(); | |
// Create cylinder 1 | |
Cylinder cylinder1 = new Cylinder(2, 2, 10, 20, 1, false); | |
// Customized shear bottom for cylinder 1 | |
cylinder1.setShearBottom(new Vector2(0, 0.83));// shear 47.5deg in xy plane(z-axis) | |
// Add cylinder 1 to the scene | |
scene.getRootNode().createChildNode(cylinder1).getTransform().setTranslation(10, 0, 0); | |
// Create cylinder 2 | |
Cylinder cylinder2 = new Cylinder(2, 2, 10, 20, 1, false); | |
// Add cylinder to without a ShearBottom to the scene | |
scene.getRootNode().createChildNode(cylinder2); | |
// Save scene | |
scene.save(RunExamples.getDataDir()+ "CustomizedShearBottomCylinder.obj", FileFormat.WAVEFRONTOBJ); |
左圆柱体具有剪切底部到 (0,0.83),而右圆柱体是序数圆柱体。
创建风扇气缸
Aspose.3D for Java 允许创建风扇圆柱体。为了使用此功能,您可以将 Cylinder
类的 setGenerateFanCylinder()
属性设置为 true
。以下代码段显示了如何使用此功能:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Jav | |
// Create a Scene | |
Scene scene = new Scene(); | |
// Create a cylinder | |
Cylinder fan = new Cylinder(2, 2, 10, 20, 1, false); | |
// Set GenerateGanCylinder to true | |
fan.setGenerateFanCylinder(true); | |
// Set ThetaLength | |
fan.setThetaLength(MathUtils.toRadian(270.0)); | |
// Create ChildNode | |
scene.getRootNode().createChildNode(fan).getTransform().setTranslation(10, 0, 0); | |
// Create a cylinder without a fan | |
Cylinder nonfan = new Cylinder(2, 2, 10, 20, 1, false); | |
// Create ChildNode | |
scene.getRootNode().createChildNode(nonfan); | |
// Save scene | |
scene.save(RunExamples.getDataDir()+ "CreateFanCylinder.obj", FileFormat.WAVEFRONTOBJ); |
左圆柱体具有GenerateFanCylinder = false,右圆柱体具有GenerateFanCylinder = true。