我基本上是在尝试通过 Java3D 创建一个形状,屏幕上只出现一个立方体。我想把立方体放在一行或一列中,但我就是不知道我做错了什么。显然这只是部分代码,只是创建立方体的方法。
私人无效createCubes(){
Cuboid box = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance);
Cuboid box2 = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance);
Cuboid box3 = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance);
Cuboid box4 = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance);
Vector3f vector = new Vector3f(0f, .3f, 0f);
TransformGroup tg = new TransformGroup();
Transform3D transform = new Transform3D();
transform.setTranslation(vector);
tg.addChild(box);
tg.setTransform(transform);
tg.addChild(box2);
tg.setTransform(transform);
tg.addChild(box3);
tg.setTransform(transform);
tg.addChild(box4);
tg.setTransform(transform);
rootGroup.addChild(tg);