Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Sky generation  (Read 6097 times)
0 Members and 1 Guest are viewing this topic.
Offline kaffiene
« Reply #30 - Posted 2004-02-17 08:54:33 »

Quote
You might also want to use a Background node for this, I know endolf has an example....

Kev



Do you know where that example might be?  Ive searched the site and Google to no avail
Offline kaffiene
« Reply #31 - Posted 2004-02-17 20:40:20 »

I can see that it uses a background node.  But reading that code and the Background.java code in Xith3D I can't see any indication that its disabling the depth test before writing the background geometry.
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #32 - Posted 2004-02-18 06:11:16 »

Hi
 Sorry about the delay in responding.

Ok, Java3d does disable the z buffer and draw a one unit background (in my case a sphere), xith doesn't (yet?), so you have to draw a huge cube to do it. The way I have done it for darkvoid is to create an ac3d model with the starfield texture applied that is 280 metres across (not big enough for propper play, but ok for now, corners at -140,-140,-140 to 140,140,140). This then has the texture applied to the inside of it. I use my ac3d loader to load it into xith and place it in the background. I hope that helps a little, but it's just summing up what others have said.

I'd like to see the z disabled for background nodes and a one unit size like java3d did, maybe when I've sorted a few things out here I'll look into it if no-one gets there first Smiley

Cheers

Endolf

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

Senior Member




Friendly fire isn't friendly!


« Reply #33 - Posted 2004-02-18 06:13:04 »

Quote
But reading that code and the Background.java code in Xith3D I can't see any indication that its disabling the depth test before writing the background geometry.


Isn't that what I asked before?

It seems that background stuff is rendered first. So theres hope that a skybox e.g. isn't fogged away. But it still has to be a large box taking the Z-clipping into account when setting up the geometry?


HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline dsellars

Junior Member




Need to write more games


« Reply #34 - Posted 2004-08-11 13:09:48 »

Sorry to bring up this old thread but I was wondering if anyone had looked into this anymore/worked out how to get it working?

It's just that it fits into something I'm thinking about at the moment, a kinda space simulation with a starfield in the background similar by the sound of it to the effect endolf wanted to create.

Cheers,
Dan.
Offline z.e.r.o

Junior Member




Java games rock!


« Reply #35 - Posted 2004-08-20 07:09:49 »

I did, and noticed a strange thing.
First of all, the thing that almost every 3D tutorial seem to be forgotting about skyboxes is that you have to disable the depth buffer when drawing them around the camera, to ensure that the scene will be drawn on top of the skybox instead of partially (of totally) behind the sky geometry.

This is the rather ugly code for a skybox proto-demo. It is working correctly only if you use vertex colouring for the skybox. If you enable the texture it seems to make ignore the DepthBufferEnabled flag.
I'm doing something wrong, I hope.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
import javax.vecmath.*;

import java.awt.*;
import java.awt.event.*;

// Xith3D
import com.xith3d.scenegraph.*;
import com.xith3d.test.*;
import com.xith3d.loaders.texture.*;

// use Jogl
import com.xith3d.render.*;
import com.xith3d.render.jogl.*;

public class SkyBox implements KeyListener {
    TransformGroup sbTG, cubeTG;
    Transform3D sbT, cubeT, v;
    Shape3D cube;
    Shape3D box;
    Vector3f eyeLoc = new Vector3f(0, 0, 10);
    View view;
    float angle;
    float speed = 0.02f;
    boolean db;
   
    public static void main (String args[]) {
        new SkyBox();
    }
   
    public SkyBox() {
        db = false;
       
        // create the virtual universe
       VirtualUniverse universe = new VirtualUniverse();
       
        // add a view to the universe
       view = new View();
        universe.addView(view);
       
        // add a locale
       Locale locale = new Locale();
        universe.addLocale(locale);
       
        // create a BranchGroup
       BranchGroup scene = new BranchGroup();
        locale.addBranchGraph(scene);
       
        //loads texture for the skybox
       Texture2D skyTex;
        TextureLoader tl = new TextureLoader();
        tl.registerPath(".");
        skyTex = (Texture2D)tl.getMinMapTexture("sky.png");
       
        sbTG = new TransformGroup();
        cubeTG = new TransformGroup();
        scene.addChild(sbTG);
        scene.addChild(cubeTG);
       
        //Cube geometry
       Geometry g1 = Cube.createCubeViaTriangles(0, 0, 0, 1, true);
        cube = new Shape3D(g1, new Appearance());
       
        //Skybox geometry
       
        //sets renderingattributes to not use depthbuffer for the skybox
       RenderingAttributes ra = new RenderingAttributes();
        ra.setDepthBufferEnable(false);
        Appearance boxApp = new Appearance();
        boxApp.setRenderingAttributes(ra);
       
       
        //Enable this to have a blue working skybox
       boxApp.setColoringAttributes(
            new ColoringAttributes(
            new Color3f(0.0f, 0.0f, 1.0f), ColoringAttributes.NICEST));
       
        //using this call broke the setRenderingAttributes!
       //boxApp.setTexture(skyTex);
       
        Geometry g2 = Cube.createCubeViaTriangles(0, 0, 0, 10, false);
        box = new Shape3D(g2, boxApp);
       
        sbTG.addChild(box);
        cubeTG.addChild(cube);
        sbT = new Transform3D();
        cubeT = new Transform3D();
        v = new Transform3D();
        v.setTranslation(eyeLoc);
        sbT.setTranslation(eyeLoc);
        sbTG.setTransform(sbT);
       
        //ensure the cube to be OVER the Skybox to illustrate
       //the disabling of the depth buffer for the skybox rendering
       cubeT.setTranslation(new Vector3f(0f, 0f, -12f));
        cubeTG.setTransform(cubeT);
       
        //Window creation lingo.
       RenderPeer rp = new RenderPeerImpl();
        CanvasPeer cp = rp.makeCanvas(null, 640, 480, 32, false);
        Canvas3D canvas = new Canvas3D();
        canvas.set3DPeer(cp);
        Toolkit.getDefaultToolkit().addAWTEventListener(
            new EventListener(),   AWTEvent.KEY_EVENT_MASK);
       
        //Place camera
       view.addCanvas3D(canvas);
        view.getTransform().lookAt(eyeLoc,   // location of eye
           new Vector3f( 0, 0, 0),   // center of view
           new Vector3f( 0, 1, 0));  // vector pointing up
       
        while(true) {
            view.renderOnce();
        }
    }
   
    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == e.VK_LEFT) {
            angle = (angle + speed) % 360;
            v.setTranslation(new Vector3f (0, 0, 0));
            v.rotY(angle);
            v.setTranslation(eyeLoc);
            view.setTransform(v);
            sbT.setTranslation(eyeLoc);
            sbTG.setTransform(sbT);
        }
       
        if (e.getKeyCode() == e.VK_RIGHT) {
            angle = (angle - speed) % 360;
            v.setTranslation(new Vector3f (0, 0, 0));
            v.rotY(angle);
            v.setTranslation(eyeLoc);
            view.setTransform(v);
            sbT.setTranslation(eyeLoc);
            sbTG.setTransform(sbT);
        }        
    }
   
    public void keyTyped(KeyEvent e) {
       
    }
   
    public void keyReleased(KeyEvent e) {
       
    }
   
    class EventListener implements AWTEventListener {
        public void eventDispatched(AWTEvent event) {
            if(event instanceof KeyEvent) {
                KeyEvent e = (KeyEvent) event;
                switch(e.getID()) {
                    case KeyEvent.KEY_TYPED: keyTyped(e); break;
                    case KeyEvent.KEY_PRESSED: keyPressed(e); break;
                    case KeyEvent.KEY_RELEASED: keyReleased(e); break;
                }
            }
        }
    }
}


Comments?

Matteo Anelli
.brain - http://www.dot-brain.com
Offline cascade

Junior Member




Java games rock!


« Reply #36 - Posted 2004-08-20 11:00:51 »

Hi,

don't know if this has been mentioned in this thread so far:

Terragen is a nice tool to create images for backgrounds and skyboxes.

You can find it here: www.planetside.co.uk

Besides it's a very nice tool to play with (even for beginners). See www.terradreams.de for examples from skilled terragen users.

Somewhere on the terragen site is a skybox tutorial including a script. This tutorial tells you how to create 6 images for your cube.
Offline z.e.r.o

Junior Member




Java games rock!


« Reply #37 - Posted 2004-08-20 19:51:47 »

That's nice, if only Xith3D will retain depth buffer settings on the cube once textured Smiley

I also noticed that if the cube is set too large (around 50000 seem to broke in my machine) the texture binded to the cube will not show up at all.

Matteo Anelli
.brain - http://www.dot-brain.com
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #38 - Posted 2004-08-20 23:48:00 »

wow!  Terragen has come a LONG way since I last used at it four years ago.  Thanks for prompting me to check it out again.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #39 - Posted 2004-08-20 23:55:22 »

Quote

Somewhere on the terragen site is a skybox tutorial including a script. This tutorial tells you how to create 6 images for your cube.


found some:
http://www.delphigl.de/tutorials/skybox.html
http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=gamejoseph03212002.html
http://www.blitzbasic.com/Community/posts.php?topic=25359

First one looks good.

Will.

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

JGO Coder


Projects: 2


Fire at will


« Reply #40 - Posted 2004-08-21 07:28:39 »

Quote
I can see that it uses a background node.  But reading that code and the Background.java code in Xith3D I can't see any indication that its disabling the depth test before writing the background geometry.


It isn't currently, you are correct.

I am now working to implementing this feature.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #41 - Posted 2004-09-01 07:16:28 »

Geometry with the Background node now works properly.

Note - it you must manually tell the geom to disable the depth buffer when drawn (i.e. so that everything is drawn in front).  Do this by setting a RenderingAttribute of the geometry Appearance:

1  
2  
3  
Appearance a = new Appearance();
a.setRenderingAttributes(new RenderingAttributes());
a.getRenderingAttributes().setDepthBufferWriteEnable(false);


For a complete example, look at the Xith3DBackgroundGeomTest.

Will.

Pages: 1 [2]
  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.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!