2012-02-13 83 views
0

我想在我写的Java3D程序中为所有3D对象创建通用抽象超类。我需要通过通用接口将共享功能(如移动对象)添加到所有3D对象。我想使用Sphere类的预先存在的几何来创建我自己的sphere3d对象。我可以访问Sphere类的几何而不扩展吗?

我希望能够访问Sphere类的几何而不继承它,因为我的object3d抽象类扩展了Shape3D,因此子类必须继承object3d。有没有办法将我自己的sphere3d类(它扩展object3d)的几何设置为Sphere的几何?几何是我需要的。

谢谢您的时间

回答

1
float radius = 2.4f; 
int divisions = 24; 
// Further flags: GENERATE_TEXTURE_COORDS etc. 
int primflags = Sphere.GEOMETRY_NOT_SHARED | Sphere.GENERATE_NORMALS; 

Sphere sphere = new Sphere(radius, primflags, divisions); 

Shape3D shape3D = sphere.getShape(); 

Geometry = shape3D.getGeometry(); // Your desired result ! 

shape3D.setGeometry(null); 
相关问题