Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 3 4 [5] 6
  ignore  |  Print  
  LWJGL - Voxel Engine  (Read 16129 times)
0 Members and 1 Guest are viewing this topic.
Offline Pauler
« Reply #120 - Posted 2013-04-22 13:56:42 »

Are you talking about a 3D triangle or a 2D triangle?

I want to draw my cubes using 12 tringles instead of 6 quads.
Offline TH3Fatal

Junior Member


Medals: 2



« Reply #121 - Posted 2013-04-22 14:06:07 »

Are you talking about a 3D triangle or a 2D triangle?

I want to draw my cubes using 12 tringles instead of 6 quads.
Would u not render the points this way giving u 2 triangles per face
1   /3
|  / |
2/   4

0,1
0,0
1,1
1,0

This is just the x and y but you can just adapt it for each of the other faces.

Offline Longor1996
« Reply #122 - Posted 2013-04-22 14:06:55 »

Hello there.

It's very easy to split a Quad into two triangles.

1  
2  
3  
4  
5  
// Label your 4 Vertices from A-D
A GL11.glTexCoord2f(spriteX, spriteY + small);           GL11.glVertex3f(x1, y1 + height, z1);
B GL11.glTexCoord2f(spriteX, spriteY);                     GL11.glVertex3f(x1, y1 + height, z1 + length);
C GL11.glTexCoord2f(spriteX + small, spriteY);           GL11.glVertex3f(x1 + width, y1 + height, z1 + length);
D GL11.glTexCoord2f(spriteX + small, spriteY + small); GL11.glVertex3f(x1 + width, y1 + height, z1);


Clockwise:
Triangle A is: A B C
Triangle B is: A C D

Result:
1  
2  
3  
4  
5  
6  
7  
8  
9  
// Triangle A
A GL11.glTexCoord2f(spriteX, spriteY + small);           GL11.glVertex3f(x1, y1 + height, z1);
B GL11.glTexCoord2f(spriteX, spriteY);                     GL11.glVertex3f(x1, y1 + height, z1 + length);
C GL11.glTexCoord2f(spriteX + small, spriteY);           GL11.glVertex3f(x1 + width, y1 + height, z1 + length);

// Triangle B
A GL11.glTexCoord2f(spriteX, spriteY + small);           GL11.glVertex3f(x1, y1 + height, z1);
C GL11.glTexCoord2f(spriteX + small, spriteY);           GL11.glVertex3f(x1 + width, y1 + height, z1 + length);
D GL11.glTexCoord2f(spriteX + small, spriteY + small); GL11.glVertex3f(x1 + width, y1 + height, z1);


I hope this helps.

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Pauler
« Reply #123 - Posted 2013-04-22 14:41:18 »

Thank you. It work but the problem is that the face culling doesn't draw the bot face anymore. It has something to do if it is clockwise or not.
Offline Longor1996
« Reply #124 - Posted 2013-04-22 14:53:14 »

Hi Pauler.

Thank you. It work but the problem is that the face culling doesn't draw the bot face anymore. It has something to do if it is clockwise or not.

It's incredible easy! Just flip the edge vertices.

Clockwise:
Triangle A is: A B C
Triangle B is: A C D

Counter-Clockwise:
Triangle A is: C B A
Triangle B is: D C A

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Offline Pauler
« Reply #125 - Posted 2013-04-25 21:12:08 »

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

Sadly, water can't expand to another chunk.
Offline steg90

Senior Member


Medals: 1



« Reply #126 - Posted 2013-04-25 22:19:48 »

Looking cool, keep up the good work!
Offline Vermeer

JGO Coder


Medals: 16



« Reply #127 - Posted 2013-04-26 19:48:10 »

Wow that's fantastic! I love how that's all working.

Sadly, water can't expand to another chunk.

I'm sure you will find a way to solve that. When I did the water on my map I stored the water In another array, this was partly because I used a second render pass to draw it semi -transparent. But it also solved the problem of it not being bound to chunks.

I'm not suggesting you do that, but a temporary list of moving water may help get around that. Or some good methods that deal with chunk boundaries.  Looks great! Smiley
Offline Pauler
« Reply #128 - Posted 2013-05-10 12:59:49 »

I found some time and started working on the engine again, but I still cannot get the holding cube right. Can someone send me a working piece of code about the holding cube?

Some of the strangle results:

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

Paul.
Offline Mike

JGO Ninja


Medals: 69
Projects: 1
Exp: 5 years


Java guru wanabee


« Reply #129 - Posted 2013-05-10 13:57:12 »

Draw it last and don't do any depth testing.

Mike

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Vermeer

JGO Coder


Medals: 16



« Reply #130 - Posted 2013-05-10 14:10:29 »

I looks like you are not translating and rotating it properly.

this is from a page on my blockworld page



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
// draw the block the player is holding
     GL11.glLoadIdentity();
      //move the camera
     GL11.glRotatef(20, 1.0f, 0, 0);  //lookupdown
     GL11.glRotatef(360.0f - yrot, 0, 1.0f, 0); //360.0f - yrot
     GL11.glTranslatef(-xpos, (-walkbias/3) - 0.25f - (float)playerheight - hedHeight, -zpos);
     
      //move the block infront of the player
     float xblokpos = xpos - (float) Math.sin((yrot-18) * piover180) * 0.24f;
      float zblokpos = zpos - (float) Math.cos((yrot-18) * piover180) * 0.24f;
     
     
      GL11.glTranslatef(xblokpos, playerheight+1.83f, zblokpos);
      GL11.glRotatef(340.0f + yrot, 0,1f, 0f);
     




its rotated to the side of the player by 18, and tilted down by 20 (GL11.glRotatef(20, 1.0f, 0, 0); )
Once the camera is rotated, I place the block infront of the player with xblokpos zblockpos (the block is 0.24 units from the player camera)
The block is then rotated to maintain its relative rotation to the player
I have also reduced the effect of the walkbias by /3 to minimise, but not remove the bobbing effect on the block, as its close to the camera.

Hope this is of some help. The values you want to use may be trial and error! To get the look you want to have.


you can also download my code, its on there somewhere. This part is halfway down the render method
Offline steg90

Senior Member


Medals: 1



« Reply #131 - Posted 2013-05-10 14:12:47 »

I don't translate the position - just set identity and position the cube after.

I just do:

1  
2  
3  
4  
5  
6  
   glLoadIdentity();  

   GL11.glRotatef(10, 0, 0, 1);
   GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube


The above is called after my camera has been translated.
Offline Pauler
« Reply #132 - Posted 2013-05-10 14:15:48 »

1  
2  
3  
4  
5  
6  
   glLoadIdentity();  

   GL11.glRotatef(10, 0, 0, 1);
   GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube



What walkbias is?
Offline steg90

Senior Member


Medals: 1



« Reply #133 - Posted 2013-05-10 14:23:13 »

It's just a value that is calculated to get a bobbing effect - I got the idea from Vermeer who I believe got it from one of nehe's tuts.

You can just do:

GL11.glTranslatef(-0.05f, 0.9f, 0.4f);

You may have to play around with the values dependant on your camera position.
Offline Vermeer

JGO Coder


Medals: 16



« Reply #134 - Posted 2013-05-10 15:58:54 »

Yes walkbias is from NEHE's tutorial.  I have scaled it down by 2.3 as the motion does not need to be as pronounced as the full bias of the character.
Offline Pauler
« Reply #135 - Posted 2013-05-11 16:03:28 »

Thank you all for your help. I used steg90's method, and it worked. I was expecting something more compilicated with usage of trigonometry to tell you the truth.

-

My current problem is that from some angles, players cannot see the rest of the blocks through a transparent block. At some points it seems like there are no other blocks behind the transparent ones like water. I don't know if my explanation is good enough to understand. I am not sure what causes that.

Paul.
Offline Longor1996
« Reply #136 - Posted 2013-05-11 18:07:29 »

Thank you all for your help. I used steg90's method, and it worked. I was expecting something more compilicated with usage of trigonometry to tell you the truth.

-

My current problem is that from some angles, players cannot see the rest of the blocks through a transparent block. At some points it seems like there are no other blocks behind the transparent ones like water. I don't know if my explanation is good enough to understand. I am not sure what causes that.

Paul.

To fix this problem (almost):
1  
2  
3  
         GL11.glEnable(GL11.GL_BLEND);
         GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
         GL11.glAlphaFunc(GL11.GL_GREATER, (float) 0.1);


And then you will also have to do depth-sort your chunks.
Then render opaque things front-to-back, and then render back-to-front transparent things.

Example:
1  
2  
3  
4  
5  
6  
7  
List<?> visibleChunks = ???;
Collections.sort(visibleChunks,frontBackDistanceSort);

for(int n = 0; n < visibleChunks.size(); n++)
    visibleChunks.get(n).renderCall(OPAQUE);
for(int n = visibleChunks.size()-1; n >= 0; n--)
    visibleChunks.get(n).renderCall(TRANSPARENT);


- Longor1996

Sorry for my bad English! That's because i am from Germany.
Online HeroesGraveDev

JGO Kernel


Medals: 215
Projects: 11
Exp: 2 years


If it wasn't Awesome, it wasn't me.


« Reply #137 - Posted 2013-05-11 21:21:36 »

The creator of Dysis (Arktos) got around that problem by rendering chunks in 2 passes.

The first pass is all the normal blocks.
The second is water and all the other semi-transparent blocks

(Make sure all chunks are rendered by the first pass before going onto the second pass.)

Offline Pauler
« Reply #138 - Posted 2013-05-11 21:48:52 »

Wow, after adding some simple checks to try your solution the game crashes everytime I try to spawn water and this is the error log.

I googled it and some people had this error at minecraft. The possible reason was the graphics card driver, but it is the first time I get this. (Also, first time I use transparency.)

http://pastebin.java-gaming.org/d6d37427e58

Paul.
Offline Vermeer

JGO Coder


Medals: 16



« Reply #139 - Posted 2013-05-11 23:12:34 »

I used 2 render passes for transparent water etc...
Offline Pauler
« Reply #140 - Posted 2013-05-11 23:18:43 »

I used 2 render passes for transparent water etc...
Just tried that and it worked.

Thank you, HeroesGraveDev.
Offline Pauler
« Reply #141 - Posted 2013-05-15 23:47:22 »

This is the current state of the voxel engine. I am not sure if I will continue working on it.

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

JGO Kernel


Medals: 215
Projects: 11
Exp: 2 years


If it wasn't Awesome, it wasn't me.


« Reply #142 - Posted 2013-05-16 06:11:48 »

You going to rename the title sometime soon? Pointing

Offline Vermeer

JGO Coder


Medals: 16



« Reply #143 - Posted 2013-05-16 09:06:00 »

That is looking and working very well. It seems a shame to stop progress on it, but I guess you have an idea for another game now you have developed all the skills with this.

Or maybe you could do a UI and crafting?

I like your water, looks cool, your project has really developed so far! Smiley
Offline Pauler
« Reply #144 - Posted 2013-05-16 17:23:10 »


Or maybe you could do a UI and crafting?

I may give it a shot.

You going to rename the title sometime soon? Pointing
Better? Or you have anything else in mind?
Offline Pauler
« Reply #145 - Posted 2013-06-27 20:00:05 »

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

*Added a simple sky.



I still have the problem I mentioned some posts before.

My current problem is that from some angles, players cannot see the rest of the blocks through a transparent block. At some points it seems like there are no other blocks behind the transparent ones like water. I don't know if my explanation is good enough to understand. I am not sure what causes that.

Paul.
Offline Vermeer

JGO Coder


Medals: 16



« Reply #146 - Posted 2013-06-28 19:39:27 »

If you render the water first at any point, the depth test will prevent terrain being drawn behind it.  Draw all solid terrain first. Then transparent things in s second pass. That may solve it
Offline Pauler
« Reply #147 - Posted 2013-06-29 09:50:19 »

If you render the water first at any point, the depth test will prevent terrain being drawn behind it.  Draw all solid terrain first. Then transparent things in s second pass. That may solve it
I already draw the blocks at 2 passes. But it seems that each kind of transparent block need to be renders are different pass. And the problem is that I cant really find a way to do that automatically, yet
Offline RobinB

JGO Knight


Medals: 37
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #148 - Posted 2013-06-29 10:07:05 »

Not each kind, you need to render the transparent blocks from back to front.
So you always need to render towards the player.
Offline pitbuller
« Reply #149 - Posted 2013-06-29 13:53:35 »

Not each kind, you need to render the transparent blocks from back to front.
So you always need to render towards the player.

You only want to render transparent objects back to front but all else from front to back.

Simple rendering order is like this.

1. Render all opaque. Depth test on. Depth writes On. Front to back.
2. Render all alpha tested. Depth test on. Depth writes On. Front to back.
3. Render all transparent. Depth Test on. Depth writes Off. Back to front. Enable blending.(use premultiplied alpha)
4. Render ui. Depth test off. Depth writes off. Back to front. Enable blending.

These simple rules work 90% of cases.
Pages: 1 ... 3 4 [5] 6
  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.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!