Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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 2002 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 »

Hello,

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: http://xith.org/download/builds/2004-09-02_cvs/

First, download the code: SkyBox.java

To create a SkyBox, use this code:
1  
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: http://www.delphigl.de/tutorials/skybox.html 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:



Enjoy,

Will.

Offline cascade

Junior Duke




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:

http://www.dartnall.f9.co.uk/forester/terrains/main.htm

http://www.ashundar.co.uk/list.php?c=ter3

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:

TerraSource
Surfice Map Guide

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

Will.

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.

Jordi

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

Will.

Offline LaLiLuLeLo

Senior Newbie




Foooocus!


« 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);

       z.normalize();

       Vector3f y = new Vector3f(up);

       /* X vector = Y cross Z */
       Vector3f x = new Vector3f();
       x.cross(y,z);
       y.cross(z,x);

      x.normalize();
      y.normalize();
     
      matrix.setIdentity();

      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;
     

      if(!Float.isNaN(matrix.determinant()))matrix.invert();
      // this put it into opengl mode, was screwing things up
      //matrix.transpose();

      setChanged(true);
  }

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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!