Author Topic: What are the bare minimums to set up a world with an empty plane?  (Read 2035 times)

Offline themendios

  • byte
  • *
  • Posts: 4
    • View Profile
What are the bare minimums to set up a world with an empty plane?
« on: September 21, 2010, 10:42:14 am »
All I want is to make a plane with a tiled texture and put a camera in it.

What is the bare minimum to achieve this?  I am really not sure, I thought if I created a plane, put it in the world, and had ambient lighting in the world, that I should see it, but it's just a pure black scene.

I am pretty new to this so I'm not really sure where to start, the wiki isn't a ton of help because I'm not wanting to pre-create a world from a 3ds file, I want to dynamically generate it as you move about.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #1 on: September 21, 2010, 01:57:13 pm »
yes, these should be sufficient provided with your camera is at a proper location to see the plane.

Offline themendios

  • byte
  • *
  • Posts: 4
    • View Profile
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #2 on: September 21, 2010, 02:06:50 pm »
Thanks for the response ;)  

I found an old post by paulscode that basically helped me create an applet that I was for the first time after modifying it able to create a simple plane and see it.  I'm not sure what I'm doing wrong on the application side, there seem to be a million different Java graphics options and Google only turns up other APIs.

Even with that I'm nowhere near what I wanted and the demos are are so hugely complex I am seriously about to give up.  They only seem to implement displayGLOnly, and I'm not well-versed enough in the half a dozen Java graphics concepts to know what else I can pass to it.  

I spent hours and hours trying to modify the advanced example since it was close to what I wanted but there are so many unknowns in there like compiling the objects and the dozen or so GL options etc etc.  All I know is as soon as I removed the skybox the world turned pitch black and I can't figure out why.

All I want to do is make a plane, I don't even care if it's textured, any size, and be able to put a moveable camera on top of it.  If I can get that far I can figure out the rest since all the documentation assumes I already know everything about Java application graphics which I do not.

I have spent the last 4 days nonstop trying to figure this out, granted some of it was struggling with Java IDEs but still a very frustrating time.  Even more frustrating is the fact that if I could get these basics down I feel like I have a pretty good grasp on the rest of JPCT, and I am a developer full-time so this isn't just somebody who assumes he can learn to code overnight.
« Last Edit: September 21, 2010, 02:11:34 pm by themendios »

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #3 on: September 21, 2010, 02:20:19 pm »
There is a box demo in the examples which is basically what you want. Just modify the box to a flat plane, and give it the textures you want.
If you get stuck, post what code you have and Ill see if I can help.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #4 on: September 21, 2010, 02:24:02 pm »
i was about to say the same thing with zammbi. start with the HelloWorld tutorial. there is also a wiki page for that demo to make things clear:
http://www.jpct.net/wiki/index.php/Hello_World

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #5 on: September 21, 2010, 04:46:08 pm »
And remember that, in case of the software renderer, you need a frame/jframe or similar to render into and that, instead of calling displayGlOnly, you have to call display(...) with a valid graphics context if the component to blit the result into (for example from the frame).

Offline themendios

  • byte
  • *
  • Posts: 4
    • View Profile
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #6 on: September 22, 2010, 01:32:09 am »
Thanks for all the responses  ;D  I have been messing with Hello World, but it's on hold atm because I have my regular paying job to deal with today.

A few questions, though:

When you create a plane, how is it oriented?  I have been c/p'ing other people's code (mostly Egon's) and I'm not sure I understand what exactly they're doing.

Is a "unit" for lack of a better term a fixed amount of screen space or tied to pixels?  How much screen space/pixels?

How is JPCT regarding created objects?  The only 2 objects I really want are a cube and a plane and it seems silly to create a 3ds for this.

Also, how well would JPCT handle the following (my scenario):
The plane will be the bottom of the 'world' but the player should never get to that point.
The actual world will be comprised entirely of simple cubes, and we are talking many cubes.  They will have a limited amount of textures (less than 32) and all have the same shape obviously, but is there any particular way I should design this?  I don't think the renderer will have any problem at all, but I'm wondering about the collision detection having several thousand uniform objects might not matter if they're uniform or not.

Thanks for all your work btw Egon, I really feel like you got the short end of the internet, I really don't understand why JPCT isn't the first thing to pop out of any game dev's mouth when Java 3D gaming is mentioned.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #7 on: September 22, 2010, 09:21:43 pm »
I think the planes created by the Primitives class lie in the xy-plane. I'm not sure though...just try it.
The boxes that Primitives creates aren't that great, because they are rotated 45 and have no proper texture coordinates. You are better of with one done in a modeller or in code. Take a look at my game Robombs. It should contain a box model iirc.

About the object count...well, i assume that not all objects are visible at a time? In that case, i suggest to work with (potentially) visible objects only, i.e. don't create all 1000+ but maybe just the next 100 ones or similar. I prefer to load a static blueprint once and clone that if a new instance is needed. Again, this can be seen in the Robombs sources. Another option is to use an object pool. I do this on Android to minimize garbage collection. On the desktop, this is no issue though.

Offline themendios

  • byte
  • *
  • Posts: 4
    • View Profile
Re: What are the bare minimums to set up a world with an empty plane?
« Reply #8 on: September 23, 2010, 12:13:14 am »
I think the planes created by the Primitives class lie in the xy-plane. I'm not sure though...just try it.
The boxes that Primitives creates aren't that great, because they are rotated 45 and have no proper texture coordinates. You are better of with one done in a modeller or in code. Take a look at my game Robombs. It should contain a box model iirc.

About the object count...well, i assume that not all objects are visible at a time? In that case, i suggest to work with (potentially) visible objects only, i.e. don't create all 1000+ but maybe just the next 100 ones or similar. I prefer to load a static blueprint once and clone that if a new instance is needed. Again, this can be seen in the Robombs sources. Another option is to use an object pool. I do this on Android to minimize garbage collection. On the desktop, this is no issue though.

Funny that you mention it, I was actually going to steal the Robombs 3ds :D 

However, while I understand that for performance reasons a static modeled 3ds baseline world is optimal, I really can't do that: what I am essentially trying to create, for lack of a better way to explain it, is something like the lego game, where the actual world is made up of blocks as well as potentially the environment.

However, these blocks are uniform, and don't have a hell of a lot of variety at least as far as graphics performance is concerned, I would love for you to expound on the object pool concept, because I am sure there is some way to optimize this particular scenario since the objects, while numerous, are very simple polygons and not particularly varied in texture, and I'm guessing an object pool would be something where you have a set number of objects (say 32) that you can redeploy throughout the world with optimized technique.