Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Sparky's little Cube World Project  (Read 5907 times)
0 Members and 1 Guest are viewing this topic.
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Posted 2013-03-29 20:49:46 »

Hello!

You could have already guessed it: I joined the club creating cube world games! I am doing this because I am now taking my first steps in 3D-game-programming and this seems to be fairly easy and enjoyable. I am working with LWJGL.

Last things I did: (roughly)
- get Shaders working (GLSL 1.20 / 1.30)
- setting up movement in 3D space (matrix stuff)
- setting up a standard cube (only one texture for now)
- setting up a chunk that can hold many cubes
- managing the performance by culling everything away that is not needed at the moment (not fully finished yet)
- enable manipulating cubes by removing or placing them

The visuals is simple at the moment, sort of binary: either there is a cube or there is not. Because I have not had the time to implement different kinds of cubes. It is not very high on my priority list.

So I am now going to show what it looks like at the moment.


And here is a video:
<a href="http://www.youtube.com/v/GKxiF8YavXc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/GKxiF8YavXc?version=3&amp;hl=en_US&amp;start=</a>

I will be working on this the next few days I think. I will update here if there is any good process on it.
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #1 - Posted 2013-03-29 20:54:36 »

Ok, I forgot about the jar if you like to try it. It should be ready for windows and linux:
here

Please report me any errors. Smiley
Offline DziNeIT

Senior Newbie


Exp: 3 years



« Reply #2 - Posted 2013-03-29 20:55:39 »

Ok, I forgot about the jar if you like to try it. It should be ready for windows and linux:
here

Please report me any errors. Smiley

The download is a 404
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #3 - Posted 2013-03-29 20:56:14 »

Yeah, fixed it! Thank you. Smiley
Offline Vermeer

JGO Coder


Medals: 16



« Reply #4 - Posted 2013-03-29 20:58:36 »

Wow that looks really good. Will take a look! Will look with interest. It great to have more cube world projects!  Smiley

EDIT*

Had a look, thats fantastic. Nice 3d picking btw!
Offline Vermeer

JGO Coder


Medals: 16



« Reply #5 - Posted 2013-03-30 08:31:35 »

Your picking is very good, may I ask - did you use ray casting or glReadpixels? Or both?
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #6 - Posted 2013-03-30 09:44:08 »

Thank you, Vermeer. Smiley

Honestly, I don't know anything of glReadPixels. So, yes, I used ray casting. It took me some time to get the idea of the vectors and the role of the dot products in this thing, but after that, it was easy. (Edit: I was mixing things up, no dotProduct in my code) This is my code:

http://pastebin.java-gaming.org/3e222042c57
note: getMin(X) and others are the corners of the cube.
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #7 - Posted 2013-03-30 10:28:14 »

I have made a new video showing the raycasting by drawing the ray as a line.

<a href="http://www.youtube.com/v/IPq6JQf3KT4?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/IPq6JQf3KT4?version=3&amp;hl=en_US&amp;start=</a>
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2013-03-30 10:43:29 »

This is pretty great! I love how your camera slides a little when you stop walking, it makes it feel more realistic than abruptly stopping! But, why do you render the backs of the cubes that are inside the chunk? In my voxel engine, I only render faces that are absolutely needed. So for instance, I render a chunk out like yours. Now, yours will render cubes while mine just renders the front face of the cube. I don't know if that made any sense at all but... I'm just wondering why you render out faces that are hidden behind other faces, wouldn't that be slightly less efficient than just rendering only the faces that are visible?

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2013-03-30 10:44:37 »

But, why do you render the backs of the cubes that are inside the chunk?

You should watch the first video to the end again Wink

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #10 - Posted 2013-03-30 10:53:28 »

Oh darn, I did it again :/ But he still was rendering them at the end, he just enabled back face culling I think! So why even have it off in the first place? Unless I'm wrong and he actually had it on the whole time... 

Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #11 - Posted 2013-03-30 11:01:22 »

It is a good question, opiop.

I did it because I was often confused while debugging, running into a wall and not being able to see anything. And after all I wanted to make sure that everything renders the way that I want it to be. So I disabled backface-culling and I had no problems anymore. Of course there is an impact on efficiency, but when I am done or not in debugging mode, then it will always be turned on. Smiley

Please, if there are other things that are questionable or weird or anything, please ask or tell me.
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #12 - Posted 2013-03-30 11:05:55 »

I actually had the same problem last night! Thank you for the ray casting code, I think next I'll try to implement block placing/destruction.

Good luck on your game, I'll be watching! Smiley

Edit:
Actually, you are using ray casting correct? Isn't that a very old way of picking in 3D? I feel like
1  
glReadPixels()
is a better way to do it, but I have no idea!

Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #13 - Posted 2013-03-30 11:30:52 »

Good luck on your game, I'll be watching! Smiley
Thank you!   Smiley

Actually, you are using ray casting correct?
No offense, but this should be obvious now. Wink Yes, I do.

Isn't that a very old way of picking in 3D? I feel like
1  
glReadPixels()
is a better way to do it, but I have no idea!
Hmmm, of course there are differences in performance, that can be arguments for using certain techniques, but in the math itself, I see no problems. It is fairly simple, doesn't use square roots, just divisions here and there. And it gives me information about the surface that the ray has hit i.e. the normal of the face. Can glReadPixels() do this? I don't know much about it, but it seems like it could be a problem to get information about the orientation of the face the pixel belongs to.

EDIT: The algorithm was published by Andrew Woo in "Fast Ray-Box intersection" in Andrew Glassner's "Graphics Gems" in 1990.
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #14 - Posted 2013-03-30 11:47:54 »

Actually, you are using ray casting correct? Isn't that a very old way of picking in 3D? I feel like
1  
glReadPixels()
is a better way to do it, but I have no idea!

Oh, glReadPixels() is aweful!
I use glReadPixels only for making screenshots, I don't really know what you are trying to archive with them

glReadPixels gives you an array of color values, which each pixel on a framebuffer has. To generate that array the driver needs to send all the data from your graphics card to your cpu / ram to make it accessible for the cpu.

That operation is very, very expensive. It's a lot about copying and stuff..


I don't even really understand what you are trying to archive with getting the pixel values from your framebuffer? Do you want to draw unique colors for each block of your game to a second framebuffer and then read the color value of the pixel in the middle of the screen and then translate that color back to a position in your voxel world?

That's definitely not the purpose of glReadPixels()...

Sparky's solution is the right solution (if he is doing it with the bresenham-algorithm...  Roll Eyes )

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #15 - Posted 2013-03-30 11:54:18 »

Sparky's solution is the right solution (if he is doing it with the bresenham-algorithm...  Roll Eyes )
Hmmm, am I? I don't think so. I have skipped the chapter about bresenham in my book. Maybe I should go back there.  persecutioncomplex
In my last post I edited where the algorithm that I am using is from:
Quote
The algorithm was published by Andrew Woo in "Fast Ray-Box intersection" in Andrew Glassner's "Graphics Gems" in 1990.
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #16 - Posted 2013-03-30 11:56:30 »

Sparky's solution is the right solution (if he is doing it with the bresenham-algorithm...  Roll Eyes )
Hmmm, am I? I don't think so. I have skipped the chapter about bresenham in my book. Maybe I should go back there.  persecutioncomplex
In my last post I edited where the algorithm that I am using is from:
Quote
The algorithm was published by Andrew Woo in "Fast Ray-Box intersection" in Andrew Glassner's "Graphics Gems" in 1990.

Eh... Couldn't find the book's chapter on google, probably you could just post some source? Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #17 - Posted 2013-03-30 12:10:52 »

I posted the source in this thread. Here it is: http://pastebin.java-gaming.org/3e222042c57

I got it from my favorite book: http://gamemath.com/about-the-book/
It is really, really good!  Cool
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #18 - Posted 2013-04-01 21:14:16 »

So here is my promised version with collision detection. I had some problems with it because I am unexperienced and a bit dumb, but now I have it neeeeeaaaarly working! Smiley

You can test it here: Alpha2

I still have severe problems with performance. Because of this there are still 8*8*8 cubes per chunk. This is what I am going to fix next. I can't wait. Smiley

I will post a video of it, when it is ready!
Offline steg90

Senior Member


Medals: 1



« Reply #19 - Posted 2013-04-01 21:25:07 »

You aint dumb @Sparky83!

Anyway, tried to run your jar and I got this on my terminal:

Exception in thread "main" java.lang.UnsupportedClassVersionError: engine/EngineMain : Unsupported major.minor version 51.0

Running on a Macbook Pro.

Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #20 - Posted 2013-04-01 21:48:45 »

You aint dumb @Sparky83!
Maybe not completely, but I have potential! Wink Thanks for defending me against myself anyway. Smiley

Quote
Anyway, tried to run your jar and I got this on my terminal:

Exception in thread "main" java.lang.UnsupportedClassVersionError: engine/EngineMain : Unsupported major.minor version 51.0

Running on a Macbook Pro.
Try downloading it again, it shouldn't do this now. I used an older compliance level. Do you have an old version of Java on your machine?
Offline steg90

Senior Member


Medals: 1



« Reply #21 - Posted 2013-04-01 21:54:48 »

Java/Javac version is 1.6.0_37

Unfortunately I'm getting the same error...

Did you build with Java 1.7?
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #22 - Posted 2013-04-01 22:05:24 »

Did you build with Java 1.7?
Yes, I do.

Here is my video which is just showing a minute of so called "gameplay"...
<a href="http://www.youtube.com/v/ixc7d__BzDM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/ixc7d__BzDM?version=3&amp;hl=en_US&amp;start=</a>
Offline steg90

Senior Member


Medals: 1



« Reply #23 - Posted 2013-04-01 22:15:31 »

Looks cool,

Did you use AABB's?  Or get player position and use as index/offset into your block array?

Cheers
Offline steg90

Senior Member


Medals: 1



« Reply #24 - Posted 2013-04-01 22:20:15 »

I need to look into collisions myself, I take it you define a bounding box for the player/camera, and use this to detect if 'bound' with one of the blocks?
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #25 - Posted 2013-04-01 22:24:04 »

I have put my posts together:
Old post:
I am using AABBs and dynamic seperating axis test. And the tests are pretty slow because I am doing them on all cubes currently... this is what I am going to change when fixing performance issues. Did this on raycasting for picking already.
When I am done with that, there will be some work with the chunks to do, because one single chunk is getting boring.

New Post:
Quote
I take it you define a bounding box for the player/camera, and use this to detect if 'bound' with one of the blocks?
Yes, of course. If you are really getting the book I told you about, then you will find excellent explanations on this in the Appendix A. Wink
Offline steg90

Senior Member


Medals: 1



« Reply #26 - Posted 2013-04-01 22:27:22 »

Many thanks,

Will take a look at this, book should be here this week.

I'm working on, get current camera location x,z, transform this to voxel space to determine block we are on, then test AABB.
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #27 - Posted 2013-04-11 13:51:26 »

It has been more than a week with no update now. This is, because I am not really working on it. Instead, I am learning about lighting to be able to implement it in this project. I want to do this on my own with shaders. For now, I have read a lot about the theory and I have implemented blinn-phong in a test-project. I also have a short video of it:
<a href="http://www.youtube.com/v/WjIeSP7uHpg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/WjIeSP7uHpg?version=3&amp;hl=en_US&amp;start=</a>
Nothing too great about it. But this is just a start.

Now I will continue learning. Smiley
Offline steg90

Senior Member


Medals: 1



« Reply #28 - Posted 2013-04-11 14:00:31 »

Very nice ;-)

This will look great when you implement it into your game!
Offline Vermeer

JGO Coder


Medals: 16



« Reply #29 - Posted 2013-04-11 17:22:26 »

That looks really cool. Do you plan to use lots of real time lighting, or is it for just a few special effects?

Looks great tho, can imaging how cool that would look in your game. Smiley
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.

Dwinin (29 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (39 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!