Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (574) Games in Android Showcase (154) games submitted by our members Games in WIP (620) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: 1 2 3 [4] 5 6 7
 ignore  |  Print
 LWJGL BlockWorld  (Read 39215 times) 0 Members and 1 Guest are viewing this topic.
HeroesGraveDev

JGO Kernel

Medals: 354
Projects: 11
Exp: 3 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #90 - Posted 2013-03-28 02:13:51 »

Some thoughts on AABB:

http://www.java-gaming.org/user-generated-content/members/167679/aabb.jpg

My ingame solution is similar, but I use a circle rather than a box for the easiest. I handle vertical collisons (falling / jumping differently as this will be axis aligned - ie you dont tilt forwards and backwards)

What are you thoughts on dealing with non axis aligned collisions  ....1, 2, 3 or another solution?

When rotation is nivolved it is no longer an AABB.
What you need is an OBB with SAT.

AABB = Axis Aligned Bounding Box.
OBB = Oriented Bounding Box.
SAT = Separating Axis Theorem

HeroesGraveDev

JGO Kernel

Medals: 354
Projects: 11
Exp: 3 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #91 - Posted 2013-03-28 02:21:09 »

Just a little thought on how I'd do picking:

I have a Vector indicating the "lookAt": The direction the camera is looking.
And I have a Vector telling me the position of the camera.
 1  2 `Vec3 camDir = camera.getDirectionVector();Vec3 camPos = camera.getPosition();`

So what I do now is a pretty ugly ray-casting (everyone starts ugly):
 1  2  3  4  5  6  7  8  9  10  11  12  13 `// Make this variable greater, and more positions will be iterated over => more precisefinal int steps = 10;// This is the range the player has, being able to grab blocks (in this case 4 blocks)final float range = 4f;Vec3 deltaStep = new Vec3(camDir).normalize().mul(range / (float) steps);Vec3 currentPos = new Vec3(camPos);for (int i = 0; i < steps; i++) {    currentPos.add(deltaStep);    Block block = world.getBlockAt((int) currentPos.x, (int) currentPos.y);    if (block != null) {         return block;    }}`

This way you can already pick blocks to destroy them...
But I honestly have no concrete Idea of how to do picking of single faces of a block...

I'd probably do that normal picking, and then construct a line out of the picking position, where the block was found and the camera position, and then test all the faces of the cube for intersection with the constructed line.

And you can easily cut down the faces that need checking down to 3 by not including the back faces.
And if the camera position is equal to the block position on any axis then you can remove the faces on that axis too.

Best Case Scenario: Check 0 faces.
Worst Case Scenario: Check 3 faces.

steg90

Senior Devvie

Medals: 1

 « Reply #92 - Posted 2013-03-28 15:59:12 »

@Vermeer  - this is look great ;-)  Was the fog easy to implement?

Thanks
Mike

« JGO Spiffy Duke »

Medals: 143
Projects: 1
Exp: 6 years

Java guru wannabe

 « Reply #93 - Posted 2013-03-28 16:51:43 »

Fog is very simple to implement as long as your sky is a single color. When you start messing around with gradients it gets a whole lot more complicated

Mike

My current game, Minecraft meets Farmville and goes online
State of Fortune | Discussion thread @ JGO
steg90

Senior Devvie

Medals: 1

 « Reply #94 - Posted 2013-03-28 18:21:41 »

Ok,

I got a skybox, so textured cube.  Simple fog would be ok for a start :-)
HeroesGraveDev

JGO Kernel

Medals: 354
Projects: 11
Exp: 3 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #95 - Posted 2013-03-28 22:54:44 »

On Block Picking:

If you have the gradient of a line, then you can work out the x coords from the y coords and vice versa.
In case you don't know linear algebra:
 `y = mx+c; x = (y-c)/m;`

With that, you simply find which axis has the least most change (in this case x-axis), and interpolate along that line in ones, until you hit a block. Sometimes, you will have two y coords for one x coord. To avoid missing blocks that actually might be hit, you simply check for blocks on both sides of the intersected line. Once you hit a block, backtrack one space along the line to work out which face the ray intersected.

Of course it needs to be adjusted for 3D.

EDIT: I haven't actually tried this. I'm implementing it in my own game right now. It should work.

EDIT 2: Almost got it working. I just need to make it check for blocks on both sides of the line then it should be finished.

Vermeer

JGO Coder

Medals: 16

 « Reply #96 - Posted 2013-03-29 09:03:53 »

Hi, thanks for that. I have used Bresenhams line algorithm before in a 2.5D ray caster, also for Line of sight in a Tile based RPG game.

I have picking working fairly well now. I cast a ray from camera. I do it as you have outlined.

I do the vertical calculations first, and then from that I know the horizontal distance, which I just use trig to find the x and z distance. Like with Bresnenhams this can be optimised with similar triangles.

I don't know the usual resolution, but I'm casting 100 rays over 10 blocks. =0.1 block accuracy.  I can improve this when I Find the individual face as you outline below.

The tricky part is if the line intersects exactly on the corner of 2 blocks, an thus traces through them. Mathamatically possible, but not what we want!
steg90

Senior Devvie

Medals: 1

 « Reply #97 - Posted 2013-03-29 09:36:01 »

Glad you got the raycast working ;-)

I'm having trouble with a texture on a cube as I want to texture my blocks now, they look too bland just using colours.  I'm getting weird effects, I've textured just a cube which looks fine, if my texture is green (grass), then the rest of the blocks which aren't being textured by the way, will also take on this colour...have you seen anything like this before?...If the texture is brown/crate, then again all my colours on my blocks seemed to get 'tinted' with the texture colour?!

I'm using PNGDecoder, also used slick-util with same results.

Thanks and keep up this great work, it is inspiring!

*UPDATE - got it working, I was forgetting to disable the textures for blocks that don't need a texture!
DziNeIT

Senior Newbie

Exp: 3 years

 « Reply #98 - Posted 2013-03-29 13:50:06 »

Is it possible that we could get the source for the new version of your game? I've made my own block engine but it's not great on efficiency / performance, and I'd love to learn from someone better's code to see where it can be optimised and what methods I should be using.
Vermeer

JGO Coder

Medals: 16

 « Reply #99 - Posted 2013-03-29 17:45:43 »

Update:
3D picking part 1

Im going away for a few days so no work on this till monday. Someone is going to host the code for me, on my return I will make all the code
available. It's not fancy code, infact its probably a good example of not what to do. I't is not optimised, or organised. But I like to just get things working first.
But if it helps solve any problems that people can build on then sure.

steg90

Senior Devvie

Medals: 1

 « Reply #100 - Posted 2013-03-29 18:00:36 »

That is cool ;-)

I'm having the odd issue were sometimes my texture on block will be drawn in the wrong colour, have you ever experienced this?!  For instance, a block with a dirt texture appears green?!

Keep up the great work!

Vermeer

JGO Coder

Medals: 16

 « Reply #101 - Posted 2013-03-29 18:03:54 »

I have had that issue if changing colours with glColour and then not putting it back to 1,1,1 before rendering other stuff.
steg90

Senior Devvie

Medals: 1

 « Reply #102 - Posted 2013-03-29 20:11:37 »

Ahhh, so you have to put colour back to 1,1,1?  Seems a bit strange?!

Thanks for that.
Longor1996
 « Reply #103 - Posted 2013-03-29 20:16:14 »

Hi there!

The only thing you have to do is, to put a white pixel in the top-left corner of the texture.
And everytime you don't need texture's anymore, just set TexCoord to 0:0.

Trust me, it works pretty well.

- Longor1996

Vermeer

JGO Coder

Medals: 16

 « Reply #104 - Posted 2013-04-01 16:28:30 »

update

Been looking at lighting. This will be for a player held light, that would be in addition to pre calculated lighting.

A zip file containing the eclipse project is available on my brothers website:
(Please look at his java game!)

http://www.missiondefence.com/vermeer/

Please remember this is a test project, and not representative of ideal solutions. But please feel free to use any of it - if its of any help.  It will crash if you do things I did not plan it to do!

Just ask if you have any questions about it, or feel you need to point out how bad bits of it are!

I will be starting work on my proper game soon, once I have looked at model loading, and shaders.
Vermeer

JGO Coder

Medals: 16

 « Reply #105 - Posted 2013-04-02 19:56:38 »

Update

opiop65

JGO Kernel

Medals: 165
Projects: 7
Exp: 4 years

JumpButton Studios

 « Reply #106 - Posted 2013-04-02 20:01:29 »

Stop being better at this than me :/ I almost deleted my project last night, I've been struggling lately. Do you use opengl's built in lighting to do your lighting right now? Or are you using vertex coloring?

Pauler
 « Reply #107 - Posted 2013-04-02 20:03:17 »

Stop being better at this than me :/ I almost deleted my project last night, I've been struggling lately. Do you use opengl's built in lighting to do your lighting right now? Or are you using vertex coloring?
I face many problems with my project , too that I don't really see how to fix them.

This guy is really good.
opiop65

JGO Kernel

Medals: 165
Projects: 7
Exp: 4 years

JumpButton Studios

 « Reply #108 - Posted 2013-04-02 20:10:36 »

My main issue is a vertex bug. At location 0, 0, 0 this little triangular shape set of vertices draw. I have come to conclude that they cause an issue where random vertices are drawn when my chunks update. I turn on wire frame mode and look in my chunk when it updates, and all of a sudden, close to 2,000 triangles draw and then delete themselves. My whole game slows down to 30 FPS, which is ridiculous seeing as when drawing 1 chunk, I get close to 2,000 FPS. I have come to call this bug the "0, 0, 0 update bug". I'm starting to think the issue is that I'm using quads and not triangles, and maybe the quads aren't being processed correctly. Fortunately, I bought a copy of the SuperBible, and it came today, so I'm going to learn modern OpenGL.

So while this guy is pretty good, and he obviously has been learning OpenGL more than me, I think my programs suffer mostly from my lack of OOP :/ I frequently have to re-design classes, and I hate it. Oh well...

ra4king

JGO Kernel

Medals: 374
Projects: 3
Exp: 5 years

I'm the King!

 « Reply #109 - Posted 2013-04-02 22:26:07 »

Aww noooo don't use the SuperBible! Use the Arcsynthesis tutorials!

opiop65

JGO Kernel

Medals: 165
Projects: 7
Exp: 4 years

JumpButton Studios

 « Reply #110 - Posted 2013-04-02 22:27:28 »

Wait really?? Everyone says the SuperBible is very good :/

ra4king

JGO Kernel

Medals: 374
Projects: 3
Exp: 5 years

I'm the King!

 « Reply #111 - Posted 2013-04-02 22:50:19 »

The SuperBible might go into more depth and somewhat better explanations, but code-wise: it sucks.

Vermeer

JGO Coder

Medals: 16

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

Update

Tests using vertex lighting for skylight shadows.
When a block is placed, a search is made for blocks underneath that did have sky illumination. An area is then modified by around the block, decreasing the light level.
So multiple connected blocks will decrease the level more and more.

steg90

Senior Devvie

Medals: 1

 « Reply #113 - Posted 2013-04-03 15:46:18 »

That is looking fantastic :-)
Sparky83

Senior Devvie

Medals: 6
Projects: 1

 « Reply #114 - Posted 2013-04-03 16:09:27 »

Really nice work! I am looking forward to implementing lighting im my project too. This can create amtospheric highlights.
But for now, I am still struggling with my collision detection, trying to make it better and more efficient.

Keep up the good work, this will be an awesome competitor!
Longor1996
 « Reply #115 - Posted 2013-04-03 17:46:29 »

Just a random Question again:
Does anyone that makes a Voxel Engine make any plans?
It seems like everyone just want's to clone Minecraft as fast as possible,
ignoring all good programming principles while doing so.

Does anyone here plan anything?

- Longor1996

marcuiulian13

Senior Devvie

Medals: 5
Exp: 3 years

 « Reply #116 - Posted 2013-04-03 17:48:43 »

I do. Learning stuff is the priority for me, but I have a vague image of a voxel-based game in my mind.

Getting a project done is by far the most hard thing in game development.
Sparky83

Senior Devvie

Medals: 6
Projects: 1

 « Reply #117 - Posted 2013-04-03 17:55:19 »

As this goes to everyone building those engines I feel like answering:
It sounds like an accusation. Even if it just was for copying the idea as fast as possible and getting it running, I don't see any problem in that as long as it is for fun.

As you can see in my thread, I am taking my time to optimize things. And I think others do aswell. For me it is a good thing to learn it by just copying the concept of minecraft, because these are my first steps in 3D programming and I am happy with my project. I love Minecraft and I would like to see if I can be able to get something similar working. Then, after that, I will go on making my own stuff with the things I have learned. This is my plan.
sproingie

JGO Kernel

Medals: 202

 « Reply #118 - Posted 2013-04-03 19:01:47 »

Does anyone here plan anything?

I may not always think much of the level of software engineering in much of the code that's slung around these parts, but that said: what's wrong with hacking just for fun?
Vermeer

JGO Coder

Medals: 16

 « Reply #119 - Posted 2013-04-03 19:20:06 »

Just a random Question again:
Does anyone that makes a Voxel Engine make any plans?
It seems like everyone just want's to clone Minecraft as fast as possible,
ignoring all good programming principles while doing so.

Does anyone here plan anything?

- Longor1996

Hi Longor

I do have a specific project in mind. It's nothing to do with a voxel game, but it does involve geometry created at runtime, and by working on this voxel project I have been developing the missing skills need to make the other project work. I will be posting the new project once its in a state to do so. I know others in this thread are also using this project to learn some new skills. As for ignoring programming principles, yes I am guilty - but like I say, it literally was just to test how something worked like VBO's, lighting etc.
Pages: 1 2 3 [4] 5 6 7
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Riven (31 views) 2015-04-16 10:48:47 Duke0200 (43 views) 2015-04-16 01:59:01 Fairy Tailz (33 views) 2015-04-14 20:13:12 Riven (35 views) 2015-04-12 21:36:37 bus hotdog (50 views) 2015-04-10 02:39:32 CopyableCougar4 (52 views) 2015-04-10 00:51:04 BurntPizza (52 views) 2015-04-06 22:06:58 ags1 (54 views) 2015-04-02 10:58:48 Riven (53 views) 2015-04-01 18:27:05 ags1 (70 views) 2015-03-31 10:55:12
 theagentd 27x BurntPizza 17x wessles 15x 65K 11x kingroka123 11x Rayvolution 11x alwex 11x KevinWorkman 9x kevglass 8x phu004 8x Ecumene 7x Roquen 7x chrislo27 7x Hanksha 7x SHC 7x Olo 7x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 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