1
2 개의 구를 표시해야하는 Java 프로그램이 있습니다. 그것은 구의 번역이 -1.0에서 1.0의 범위를 벗어날 때까지 작동합니다.이 경우 객체가 사라집니다. SimpleUniverse 설정이 있고 여러 곳에서 여러 setBounds를 시도했지만 어떻게 될지 알 수 없었습니다. ViewPlatform에서 OrbitBehavior를 움직이면 가까워 질수록 객체가 보이지 않기 때문에 실제 위치는 카메라 위치에 의존하지 않습니다. Java3D에서 -1.0에서 +1.0 범위 밖에 볼 수없는 객체의 변환 위치
이
이 구체에 대한 설정입니다 : 공용 클래스 CelestialBody는지는 tRANSFORMgROUP를 확장 {CelestialBody(float posX, float posY, float posZ) {
// This is set for the dynamic behaviour.
setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D t3d = new Transform3D();
t3d.setTranslation(new Vector3f(posX, posY, posZ));
setTransform(t3d);
setBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 10000.0f));
Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 100, createAppearance());
addChild(sphere);
}
private Appearance createAppearance() {
Appearance appear = new Appearance();
Material mat = new Material();
mat.setShininess(100.0f);
appear.setMaterial(mat);
return appear;
}
}
이 주요 프로그램 :
public class CelestialApp extends Frame {
public static void main(String[] args) {
// TODO Auto-generated method stub
new CelestialApp();
}
private SimpleUniverse universe = null;
public CelestialApp() {
// ...
BranchGroup scene = constructContentBranch();
scene.compile();
universe = new SimpleUniverse(defaultCanvas);
setupView();
universe.addBranchGraph(scene);
}
private void setupView() {
ViewingPlatform vp = universe.getViewingPlatform();
OrbitBehavior orbit = new OrbitBehavior();
orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 10000.0f));
vp.setNominalViewingTransform();
vp.setViewPlatformBehavior(orbit);
}
private BranchGroup constructContentBranch() {
BranchGroup scene = new BranchGroup();
CelestialBody body1 = new CelestialBody(-2.0f, 0.0f, 0.0f);
scene.addChild(body1);
CelestialBody body2 = new CelestialBody(2.0f, 0.0f, -1.1f);
scene.addChild(body2);
PhysicalBehavior physics1 = new PhysicalBehavior(body1);
scene.addChild(physics1);
PhysicalBehavior physics2 = new PhysicalBehavior(body2, new Vector3d(0.0f, 0.0f, 0.0f));
scene.addChild(physics2);
setupLights(scene);
return scene;
}
private void setupLights(BranchGroup scene) {
AmbientLight lightA = new AmbientLight();
lightA.setInfluencingBounds(new BoundingSphere());
lightA.setColor(new Color3f(0.3f, 0.3f, 0.3f));
scene.addChild(lightA);
DirectionalLight lightD1 = new DirectionalLight();
lightD1.setInfluencingBounds(new BoundingSphere());
Vector3f dir = new Vector3f(-0.3f, -1.0f, -0.5f);
dir.normalize();
lightD1.setDirection(dir);
lightD1.setColor(new Color3f(1.0f, 1.0f, 1.0f));
scene.addChild(lightD1);
Background bg = new Background(0.0f, 0.0f, 0.0f);
bg.setApplicationBounds(new BoundingSphere());
scene.addChild(bg);
}
}
아무 코드없이 진행되는 상황을 말하기 란 매우 어렵습니다. 적어도 관련 스 니펫을 줄 수 있습니까? –
주 수업 : http://pastebin.com/FfL4BBgU 개체 클래스 : http://pastebin.com/TGZDD8Cd – progician
그냥 링크를 제공하는 것보다는 질문에 편집하십시오 (이상적으로 관련없는 내용은 지우는 것이 이상적입니다). –