Newbie Universe Size Question

Hello,
I wasn’t sure whether to put this in Newless Cluebies or not, please accept my apologies if I’m wrong :slight_smile:

I’m currently taking my first steps with Java3D in the creation of a basic 3D space game. I’ve been quite successful in getting everything loaded up and twiddling around with the materials from Maya .obj exports etc.

I’m currently working with the translation classes, and realised that my ship quite happily travelled out of the spherical universe textured with a space picture. “Alright then, I’ll make the universe bigger!” I replaced the 1.0f radius with Float.MAX_VALUE (I have no respect for my computer) and it happened again. I’ve hunted through Google to affirm my suspision that the sphere’s maximum radius is 1.0f, but I’ve not found anything to confirm or deny it. Am I correct in this?

If so, how does one create a large expanse to work with? I tried working the other way, and scaling down my models. Which works up to a point, and then Java3D seems to kind of give up and go “That’s as small as it’s getting!” Slapping a couple more zeros in the decimal place of my scaling Transform3D stopped having an effect after a while :slight_smile: Unfortunately, my universe still isn’t big enough :frowning:

Is it impossible to have a sphere bigger than radius 1? Is there a better way of texturing the background that will allow me to have my massive void? Should I give up and simply fly around a big black place? “Well, yeah, it’s a game set in a black hole. They’re damn black you know. How do you know you can’t see light off objects when you’re in one? Have you ever been in one?!” Might work :smiley:

Thanks for any help you might be able to give me,
Oh, and Merry Christmas/Hanukkah,
Chris

Hi
Ok, a couple of things. There is a background object type, you can add geometry to it, and as long as it fits inside a unit sphere it will be drawn first, with all your other objects after it, if you then apply your texture to the inside of it your background will work. I used it with a cube and got a nice star field background.
The second thing, is that you cannot have a large 3d universe in java3d, or any consumer hardware, there is a ratio of front to back clip distances that limit the size of the visible universe, after that you have to play tricks to get it to work. This article has a good explanation of the reasons.

HTH

Endolf

Thank you for your reply!
Yes, I am currently using a sphere as my background geometry:


        Background bg = new Background();
        bg.setApplicationBounds(infiniteBounds);
      BranchGroup backGeoBranch = new BranchGroup();
        Sphere sphereObj = new Sphere(1.0f, Sphere.GENERATE_NORMALS |
                            Sphere.GENERATE_NORMALS_INWARD |
                          Sphere.GENERATE_TEXTURE_COORDS, 45);
        Appearance backgroundApp = sphereObj.getAppearance();
        backGeoBranch.addChild(sphereObj);
        bg.setGeometry(backGeoBranch);

ripped from the Java3D examples themselves :smiley:
Thank you for the link, it was helpful in explaining the problems.
Could you point me to how exactly I could look into simulating a larger environment? I’m currently being restricted by the way I’m trying to solve the problem. The universe is a unit sphere, I can only resize models to a specific point, but other games have demonstrated that the percievable universe can be larger than what I am currently achieving.

Please flame me if I’m being stupid :wink:

Hi
Been in bed with flu the last couple of days, still not fireing on all 4 cylinders, so you’ll have to excuse me if I miss anything here. It looks to me as though your objects arn’t going through your sphere at all. It being in a background node your objects will always be drawn after it. I’m thinking that your objects are just hitting your back clip distance and being clipped. If you draw your background wireframe only you should still see your whole objects being displayed if they are going through it. If they are hitting the back clip distance they will be cut short.
As to how to solve it. well. There was a discussion on the java3d mailing list a while back with some ideas, check the archives there for some perspetives.

HTH

Endolf

Thanks a lot for your help, you’ve been really great.

After spending another couple of hours bashing through all the permutations of the universe, I finally found a solution!

With your advice, I set the back clip distance to 2000m, which is a fair way. I’ll do more through testing in the bounds of the recommended <= 1000m. No luck. I pulled the viewer back to 1999m and turned the background into wireframe mode. I could see the objects! I began to sob ever so slightly as it occured to me that the universe must be less than 2000m radius. I tried for another hour experimenting and was almost about ti give up. I then noticed something in the Key Navigation class I’d set up; it was using the branch group bounds, which I remembered was optimised so it bounded over only what was necessary (which explains why I could fly outside of the limits of control and have zero response!) I set the bounds to Double.MAX_VALUE and hey presto! It works! I can fly around all merrily and see the objects from miles off!

I suppose Java3D itself reduces the boundaries of the universe inkeeping to how big it feels it should be. Because my Key Navigator was set as the too small branch group, I think Java3D used the too small branch group as the bounds.

Hope you feel better soon! I know I certainly do!

Chris