Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 3 [4] 5 6 7
  ignore  |  Print  
  LWJGL BlockWorld  (Read 27884 times)
0 Members and 1 Guest are viewing this topic.
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #90 - Posted 2013-03-28 03: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

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #91 - Posted 2013-03-28 03: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 precise
final 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.

Offline steg90

Senior Member


Medals: 1



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

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

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

JGO Ninja


Medals: 71
Projects: 1
Exp: 5 years


Java guru wanabee


« Reply #93 - Posted 2013-03-28 17: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 Smiley

Mike

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

Senior Member


Medals: 1



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

Ok,

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

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #95 - Posted 2013-03-28 23: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.

Offline Vermeer

JGO Coder


Medals: 16



« Reply #96 - Posted 2013-03-29 10: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!
Offline steg90

Senior Member


Medals: 1



« Reply #97 - Posted 2013-03-29 10: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!
Offline DziNeIT

Senior Newbie





« Reply #98 - Posted 2013-03-29 14: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.
Offline Vermeer

JGO Coder


Medals: 16



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

Update:
3D picking part 1
Added entities

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

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.

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

Senior Member


Medals: 1



« Reply #100 - Posted 2013-03-29 19: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!

Offline Vermeer

JGO Coder


Medals: 16



« Reply #101 - Posted 2013-03-29 19: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.
Offline steg90

Senior Member


Medals: 1



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

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

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

Hi there!

How about never disabling Texture2D?
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

Sorry for my bad English! That's because i am from Germany.
Offline Vermeer

JGO Coder


Medals: 16



« Reply #104 - Posted 2013-04-01 18: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 href="http://www.youtube.com/v/MGEQ1sIzfGg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/MGEQ1sIzfGg?version=3&amp;hl=en_US&amp;start=</a>

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.
Offline Vermeer

JGO Coder


Medals: 16



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

Update

Loaded a textured .Obj model into game (the badly made and textured furnace!)

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #106 - Posted 2013-04-02 22: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?

Offline Pauler
« Reply #107 - Posted 2013-04-02 22: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.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #108 - Posted 2013-04-02 22: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...

Offline ra4king

JGO Kernel


Medals: 340
Projects: 2
Exp: 5 years


I'm the King!


« Reply #109 - Posted 2013-04-03 00:26:07 »

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

Tutorial link: www.arcsynthesis.org/gltut
Java+LWJGL ports: www.bitbucket.org/ra4king/lwjgl-shader-tutorials/

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #110 - Posted 2013-04-03 00:27:28 »

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

Offline ra4king

JGO Kernel


Medals: 340
Projects: 2
Exp: 5 years


I'm the King!


« Reply #111 - Posted 2013-04-03 00:50:19 »

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

Offline Vermeer

JGO Coder


Medals: 16



« Reply #112 - Posted 2013-04-03 13: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.

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

Senior Member


Medals: 1



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

That is looking fantastic :-)
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



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

Really nice work! I am looking forward to implementing lighting im my project too. This can create amtospheric highlights. Smiley
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! Wink
Online Longor1996
« Reply #115 - Posted 2013-04-03 19: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

Sorry for my bad English! That's because i am from Germany.
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



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

I do. Grin 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.
Offline Sparky83

Senior Member


Medals: 6
Projects: 1



« Reply #117 - Posted 2013-04-03 19: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.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #118 - Posted 2013-04-03 21: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?
Offline Vermeer

JGO Coder


Medals: 16



« Reply #119 - Posted 2013-04-03 21: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!