Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  SkyBox mini-tutorial and utility class  (Read 4900 times)
0 Members and 1 Guest are viewing this topic.
Offline William Denniss

JGO Coder

Projects: 2

Fire at will

« Posted 2004-09-02 04:55:40 »


As some of you are aware, I have been working on improving Xith3D's background node capabilities so better SkyBoxes are possible (among other things).  This work is finished.

thread ref:
Functional Background Node
Sky generation

I have now created a SkyBox utility class for all to use (BSD Licensed).  In due course I will create a tutorial on the subject - but until then you can still use it.  It's actually incredibly simple.

Note:  You must be running the latest version of Xith3D.  I have created a new snapshot here for your convenience:

First, download the code:

To create a SkyBox, use this code:
SkyBox s = new SkyBox("skybox-front.jpg", "skybox-right", "skybox-back.jpg", "skybox-left.jpg", "skybox-top.jpg", "skybox-bottom.jpg");

SkyBox extends Background - so once created, simply add it to your scene (e.g. add it to a BranchGroup).

Add the skybox textures to your TextureLoader path and you're done.

All you really need to do is create some nice textures to use.  One great tool for this is Terragen.  I followed the terragen part of this tutorial: for the sample images.  Basically you set the camera up so it has a 90 degree FOV (zoom of 1 in "Camera Settings"), and render images at (0,0,0), (90,0,0), (180,0,0), (270,0,0), (0,90,0), (0,-90,0).

Here are the sample textures, and my terragen World and Terrain files that I made for the tute (which took ~5min to create).

As you can see, adding a SkyBox to your project is now very easy.  All you need is some nice textures and a project to add it too.  I plan on writing a tutorial with an example project, but until then, if you don't have a working project - just edit one of the demos.

This is a picture of the SkyBox in my game:



Offline cascade

Junior Devvie

Java games rock!

« Reply #1 - Posted 2004-09-06 06:40:19 »

and if you invest another 5 mins for terragen you can give the mountains some nice ice or snow topping.

spending some more time with terragen and google you can locate various sources for terragen terrain files based on real world terrain data. See for example:

Note that the terrain files itself just give you a plain rocky (using the default ground texture as seen in the pictures above) surface. You need to put multiple surfaces with their respective distributions (height based or inclination based) and coloring to get nice results. It's worth to spend some extra minutes on it Wink
Offline William Denniss

JGO Coder

Projects: 2

Fire at will

« Reply #2 - Posted 2004-09-06 11:17:56 »

I have spent an extra 5min for my game Smiley  I just wanted a really basic example for the tute.

Thanks for the links though.  Here are a few more:

Surfice Map Guide

They were just posted to the terragen Mac mailing list and look very good.


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jordi_Eng

Junior Newbie

Java games rock!

« Reply #3 - Posted 2005-01-16 14:50:28 »

I got a "cannot invert matrix in renderOnce() error" when using any geometry in the Background node. To reproduce the bug, move your viewPlatform very fast (with the mouse). If someone could resolve this, I would be please.


Offline William Denniss

JGO Coder

Projects: 2

Fire at will

« Reply #4 - Posted 2005-01-16 18:45:36 »

I have not ever seen this bug and have used SkyBox a lot.  Are you using my SkyBox class?

You may need to submit a small test case so I can reproduce it on my machine.

Edit:  Or at least give us a stack trace so we have a clue what's going on Smiley


Offline LaLiLuLeLo

Senior Newbie


« Reply #5 - Posted 2005-01-17 12:50:14 »

i think that bug has more to do with the view being in an uncomprising position than with the skybox.
Offline Jordi_Eng

Junior Newbie

Java games rock!

« Reply #6 - Posted 2005-04-24 18:18:19 »

Finally, there were no bug in Background node. It's was located in Transform3D.lookat() function. In heavy hazardous conditions the invert matrix at the end of lookat() can be calculated with a determinant of zero, causing a fatal crash. I have add a special version of lookat() in my custom version of Xith3d. You can add the code :

 public final void lookAt2(Tuple3f eye, Tuple3f center, Tuple3f up) {

       /* Make rotation matrix */

       /* Z vector */
       Vector3f z = new Vector3f();
       z.x =(int) (eye.x - center.x);
       z.y =(int) (eye.y - center.y);
       z.z = (int)(eye.z - center.z);


       Vector3f y = new Vector3f(up);

       /* X vector = Y cross Z */
       Vector3f x = new Vector3f();


      matrix.m00 = x.x;
      matrix.m01 = x.y;
      matrix.m02 = x.z;

      matrix.m10 = y.x;
      matrix.m11 = y.y;
      matrix.m12 = y.z;

      matrix.m20 = z.x;
      matrix.m21 = z.y;
      matrix.m22 = z.z;

      // this put it into opengl mode, was screwing things up


It faster than the normal one, but I not sure if it could replace lookat. I have cut code that I don't known the utility.

I have a great game that will use Xith3d, GoldRush, with a lot of specials effects, vehicules and weapons type!

Jordi Lafortune
Pages: [1]
  ignore  |  Print  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (27 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (210 views)
2018-05-13 18:23:11

nelsongames (127 views)
2018-04-24 18:15:36

nelsongames (126 views)
2018-04-24 18:14:32

ivj94 (867 views)
2018-03-24 14:47:39

ivj94 (128 views)
2018-03-24 14:46:31

ivj94 (779 views)
2018-03-24 14:43:53

Solater (143 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!