www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Melssj5 on April 11, 2006, 05:02:27 am

Title: Sky
Post by: Melssj5 on April 11, 2006, 05:02:27 am
How to add a sky instead of that black enviroment that jpct has by default?
Title: Sky
Post by: Mr.Marbles on April 11, 2006, 03:00:54 pm
I've used the technique described in the following post (http://www.jpct.net/forum/viewtopic.php?t=110) and it works well. If you just want to use a solid color for the background then you can replace the buffer.clear() with buffer.clear(Color).
Title: Sky
Post by: pitt on April 17, 2006, 02:00:42 pm
use the technic called 'skybox'.

Some free sky textures.
http://www.octanedigitalstudios.com/page4.html
http://www.scentednectar.com/skyboxes/

Source code

     float size=4000;
     String[] name={"top","front","left","right","back"};
     for (int i=0;i<name.length;i++)
     {
     InputStream in=new FileInputStream(name+".jpg");
     BufferedImage b=null;
     try
     {
      b=ImageIO.read(in);     
     } catch (Exception e) {}
     Texture pic=new Texture(b,false);
     pic.enableGLClamping();
     TextureManager.getInstance().addTexture(name,pic);
     }
     Object3D[] o=new Object3D[name.length];
     //top
     Object3D obj=Primitives.getPlane(1,size*2);
     obj.rotateZ((float)Math.PI/2);
     obj.rotateX((float)Math.PI/2);
     obj.translate(0,size,0);
     o[0]=obj;
      //front
     obj=Primitives.getPlane(1,size*2);
     obj.translate(0,0,size);
     obj.rotateZ((float)Math.PI);
     o[1]=obj;
     //left
     obj=Primitives.getPlane(1,size*2);
     obj.translate(size,0,0);
     obj.rotateZ((float)Math.PI);
     obj.rotateY((float)Math.PI/2);
     o[2]=obj;
     //right
     obj=Primitives.getPlane(1,size*2);
     obj.translate(-size,0,0);
     obj.rotateZ((float)Math.PI);
     obj.rotateY((float)-Math.PI/2);
     o[3]=obj;    
     //back
     obj=Primitives.getPlane(1,size*2);
     obj.translate(0,0,-size);
     obj.rotateZ((float)Math.PI);
     obj.rotateY((float)Math.PI);
     o[4]=obj;    
     
     for (int i=0;i<name.length;i++)
     {
       o.setTexture(name);
       o.setLighting(Object3D.LIGHTING_NO_LIGHTS);
       o.build();
       world.addObject(o);
     }
Title: Sky
Post by: Remo on April 18, 2006, 09:13:39 am
You can also use a more simple method like raft did here :
http://www.jpct.net/forum/viewtopic.php?p=1854#1854
Title: Sky
Post by: Melssj5 on April 18, 2006, 06:52:49 pm
Well, i set my map inside an empty sphere, and I gave the sphere a texture of a sky