Pauler
|
 |
«
Reply #120 - Posted
2013-04-22 11: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.
|
|
|
|
TH3Fatal
|
 |
«
Reply #121 - Posted
2013-04-22 12: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.
|
|
|
|
Longor1996
|
 |
«
Reply #122 - Posted
2013-04-22 12:06:55 » |
|
Hello there. It's very easy to split a Quad into two triangles. 1 2 3 4 5
| 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
| 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);
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
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Pauler
|
 |
«
Reply #123 - Posted
2013-04-22 12: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.
|
|
|
|
Longor1996
|
 |
«
Reply #124 - Posted
2013-04-22 12: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
|
|
|
|
Pauler
|
 |
«
Reply #125 - Posted
2013-04-25 19:12:08 » |
|
Sadly, water can't expand to another chunk.
|
|
|
|
steg90
|
 |
«
Reply #126 - Posted
2013-04-25 20:19:48 » |
|
Looking cool, keep up the good work!
|
|
|
|
Vermeer
|
 |
«
Reply #127 - Posted
2013-04-26 17: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! 
|
|
|
|
Pauler
|
 |
«
Reply #128 - Posted
2013-05-10 10: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: Paul.
|
|
|
|
Mike
|
 |
«
Reply #129 - Posted
2013-05-10 11:57:12 » |
|
Draw it last and don't do any depth testing.
Mike
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Vermeer
|
 |
«
Reply #130 - Posted
2013-05-10 12: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
| GL11.glLoadIdentity(); GL11.glRotatef(20, 1.0f, 0, 0); GL11.glRotatef(360.0f - yrot, 0, 1.0f, 0); GL11.glTranslatef(-xpos, (-walkbias/3) - 0.25f - (float)playerheight - hedHeight, -zpos); 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
|
|
|
|
steg90
|
 |
«
Reply #131 - Posted
2013-05-10 12: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);
|
The above is called after my camera has been translated.
|
|
|
|
Pauler
|
 |
«
Reply #132 - Posted
2013-05-10 12: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);
|
What walkbias is?
|
|
|
|
steg90
|
 |
«
Reply #133 - Posted
2013-05-10 12: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.
|
|
|
|
Vermeer
|
 |
«
Reply #134 - Posted
2013-05-10 13: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.
|
|
|
|
Pauler
|
 |
«
Reply #135 - Posted
2013-05-11 14: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.
|
|
|
|
Longor1996
|
 |
«
Reply #136 - Posted
2013-05-11 16: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
|
|
|
|
HeroesGraveDev
|
 |
«
Reply #137 - Posted
2013-05-11 19: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.)
|
|
|
|
Pauler
|
 |
«
Reply #138 - Posted
2013-05-11 19: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/d6d37427e58Paul.
|
|
|
|
Vermeer
|
 |
«
Reply #139 - Posted
2013-05-11 21:12:34 » |
|
I used 2 render passes for transparent water etc...
|
|
|
|
Pauler
|
 |
«
Reply #140 - Posted
2013-05-11 21:18:43 » |
|
I used 2 render passes for transparent water etc...
Just tried that and it worked. Thank you, HeroesGraveDev.
|
|
|
|
|
HeroesGraveDev
|
 |
«
Reply #142 - Posted
2013-05-16 04:11:48 » |
|
You going to rename the title sometime soon? 
|
|
|
|
Vermeer
|
 |
«
Reply #143 - Posted
2013-05-16 07: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! 
|
|
|
|
Pauler
|
 |
«
Reply #144 - Posted
2013-05-16 15: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?  Better? Or you have anything else in mind?
|
|
|
|
Pauler
|
 |
«
Reply #145 - Posted
2013-06-27 18:00:05 » |
|
*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.
|
|
|
|
Vermeer
|
 |
«
Reply #146 - Posted
2013-06-28 17: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
|
|
|
|
Pauler
|
 |
«
Reply #147 - Posted
2013-06-29 07: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
|
|
|
|
RobinB
|
 |
«
Reply #148 - Posted
2013-06-29 08: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.
|
|
|
|
pitbuller
|
 |
«
Reply #149 - Posted
2013-06-29 11: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.
|
|
|
|
|