I have SkyBox working - but the visual effect is very obviously a box (especially when you wish to show a 3d star scape). What I am looking for is a sphere based star map to project around my view - it doesn’t need to move (interstellar distances could be handled by regenerating the images when a great distance is moved). At present it doesn’t need to be accurate, just work!
Ideally I would project 6 different sphere views onto the sphere. The box doesn’t seem to work well - the angles of the box give different perspective and rotate stangely…
I’ve put my code below - but it’s probably miles off - thanks to William Denis for a starter with SkyBox…
The loaded object is a simple sphere with an image texture mapped to it (using art of illusion).
Cheers
Andy Stratton
public class StarSphere extends Background {
public StarSphere (String filename) {
BranchGroup starSphere = getSphere(filename);
// Sets the geometry of this Background node to be the created sphere
setGeometry(starSphere);
}
public BranchGroup getSphere(String filename)
{
BranchGroup result = null;
try {
result = new OBJLoader().load("./starsphere.obj");
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
Object obj = result.getChild(0);
BranchGroup bg = null;
while ((obj != null) && (obj instanceof BranchGroup))
{
bg = (BranchGroup)obj;
obj = bg.getChild(0);
}
for (int i = 0; i < bg.getChildren().size(); i++) {
// Set texture and disable depth buffer
Appearance a = new Appearance();
a.setRenderingAttributes(new RenderingAttributes());
a.getRenderingAttributes().setDepthBufferWriteEnable(false);
((Shape3D)bg.getChild(i)).setAppearance(a);
}
return result;
}
}