Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (538) Games in Android Showcase (132) games submitted by our members Games in WIP (601) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
1  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 22:29:59
Do you not need to get your cameras rotation?

Something along the lines of:

 1  2  3  4  5  6  7  8 `Vector3f pos = getYourCameraPosition();double cameraPitchInRadians = Math.toRadians(YourCamerasPitch);double cameraYawInRadians = Math.toRadians(YourCamerasYaw);float newX = (float) Math.sin(cameraYawInRadians);float newY = (float) Math.sin(cameraPitchInRadians);glRotatef(newY-90f, 0.0f, 1.0f, 0.0f);glTranslatef(x+.3f, y-0.3f, z-0.3f);glRotatef(newX, 1.0f, 0.0f, 0.0f);`

Of course, your rx and ry maybe the same as newX and newY above?!

Regards

Thanks so much steg90 I used the code that you provided and ended up adapting it a bit to get it to work with my engine and this was the final product I came to;
 1  2  3  4  5  6  7  8 `glLoadIdentity();double cameraPitchInRadians = Math.toRadians(rY);double cameraYawInRadians = Math.toRadians(rX);float newX = (float) Math.sin(cameraYawInRadians);float newY = (float) Math.sin(cameraPitchInRadians);glRotatef(newX, 1.0f,0.0f, 0.0f);glTranslatef(1.1f-0.8f,-1.1f,-1.3f);glRotatef(newY-90.0f, 0.0f, 1.1f, 0.0f);`
2  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 19:13:02
Hi there!

 1  2  3 `glRotatef(rY-90f, 0.0f, 1.0f, 0.0f);glTranslatef(x+.3f, y-0.3f, z-0.3f);glRotatef(rX, 1.0f, 0.0f, 0.0f);`

That should work.

- Longor1996

I tried that combination before and it didn't seem to work, thanks anyway for your help.
3  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 19:05:01
Can someone help me on this one problem I seem to keep having;

I can render my players weapon but when I rotate the weapon dosn't rotate and keep at the same position as what I intended it to be at.

 1  2  3 `glTranslatef(x+.3f, y-0.3f, z-0.3f);glRotatef(rX, 1.0f, 0.0f, 0.0f);glRotatef(rY-90f, 0.0f, 1.0f, 0.0f);`

This is my code for the model rotation for the weapon can someone help me please and thanks if you do
 4 Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 17:27:05 So i have been playing around with my 2D sprite-sheet to 3D model converter and was wondering what everyone thought of the weapons so far, Models and names can be changed before the final game is released.
5  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 16:52:05
Mmmmm, what about only drawing blocks you can see - i.e not hidden by other blocks?  And only drawing faces of those blocks that have no neighbors blocking them?

You still need to cull your chunks against the viewing frustum ;-)

Oh all my code does is create a 16x16x16 cube that is hollow, for example
 1  2  3  4  5  6  7  8 `if ((y == size.y - 1) || (blockID[x][y + 1][z] == 0)) {                           vertexArray.add(new float[] { pos2.x, pos2.y, pos1.z, pos1.x, pos2.y, pos1.z, pos1.x, pos2.y, pos2.z, pos2.x, pos2.y, pos2.z });                           colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });                        }if ((y == 0) || (blockID[x][y - 1][z] == 0)) {                           vertexArray.add(new float[] { pos2.x, pos1.y, pos2.z, pos1.x, pos1.y, pos2.z, pos1.x, pos1.y, pos1.z, pos2.x, pos1.y, pos1.z });                           colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });                        }`

This checks if the block is the
• max edge block or if the block above is air, if so render top view
• min edge block or if the block below is air, if so render top view

This is then repeated to create a block that is only rendering the sides that are needed
6  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 16:40:07
Ok, did you use frustum culling against the viewing planes?  I'm using some basic distance check at the moment as my frustum culling isn't working correctly!

Just using
 1 `glEnable(GL_CULL_FACE);`
 7 Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 16:34:26 Quote from: steg90 on 2013-04-22 16:31:29PS - did you put in collision detection and any culling?I'm doing collision detection at the moment - the joy of it!I haven't done collision yet and for culling yes the engine does have culling, if it didn't I would be running at like 5fps
 8 Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 16:19:15 Quote from: steg90 on 2013-04-22 16:17:53Thanks,Does the model animate?No I haven't done that but all you probably need to do is have a timer and change the values every few seconds
9  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 16:04:53
Thanks,

Nice and here is the code;
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37 `import java.util.ArrayList;import java.util.List;import org.lwjgl.util.vector.*;public class addBlock {   public Vector3f pos1;   private Vector3f pos2;   private Vector4f colour = new Vector4f(0.0f, 0.0f, 0.0f, 1.0f);   public List vertexArray = new ArrayList();   public List colourArray = new ArrayList();   public addBlock(float x, float y, float z, float xSize, float ySize, float zSize, int r, int g, int b, float a) {            float red = (float)r/255;      float green = (float)g/255;      float blue = (float)b/255;      colour = new Vector4f(red, green, blue, a);            pos1 = new Vector3f(x, y, z);      pos2 = new Vector3f(x + (xSize / 10), y + (ySize / 10), z + (zSize / 10));      vertexArray.add(new float[] { pos2.x, pos2.y, pos1.z, pos1.x, pos2.y, pos1.z, pos1.x, pos2.y, pos2.z, pos2.x, pos2.y, pos2.z });      vertexArray.add(new float[] { pos2.x, pos1.y, pos2.z, pos1.x, pos1.y, pos2.z, pos1.x, pos1.y, pos1.z, pos2.x, pos1.y, pos1.z });      vertexArray.add(new float[] { pos2.x, pos2.y, pos2.z, pos1.x, pos2.y, pos2.z, pos1.x, pos1.y, pos2.z, pos2.x, pos1.y, pos2.z });      vertexArray.add(new float[] { pos1.x, pos2.y, pos1.z, pos2.x, pos2.y, pos1.z, pos2.x, pos1.y, pos1.z, pos1.x, pos1.y, pos1.z });      vertexArray.add(new float[] { pos2.x, pos2.y, pos1.z, pos2.x, pos2.y, pos2.z, pos2.x, pos1.y, pos2.z, pos2.x, pos1.y, pos1.z });      vertexArray.add(new float[] { pos1.x, pos2.y, pos2.z, pos1.x, pos2.y, pos1.z, pos1.x, pos1.y, pos1.z, pos1.x, pos1.y, pos2.z });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });      colourArray.add(new float[] { colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w, colour.x, colour.y, colour.z, colour.w });   }}`

Anything im doing I will do this for them.
Create an array of parts and assign each part to a new addblock then from that do a loop to assign the vertex and colour to the vertext and colour array
 1  2  3  4  5  6  7  8  9  10  11  12 `List vertexArray = new ArrayList();   List colourArray = new ArrayList();   addBlock[] parts = new addBlock[3];parts[0] = new addBlock(0, 18.15f, 0.3f, 4, 4, 4, 237, 198, 123, 1);      parts[1] = new addBlock(0, parts[0].pos1.y - .6f, parts[0].pos1.z + .1f, 4, 6, 2, 36, 70, 157, 1);      parts[2] = new addBlock(parts[1].pos1.x - .201f, parts[1].pos1.y + 0.4f, parts[1].pos1.z + 0.2f, 2, 2, -5.5f, 14, 84, 102, 1);for (addBlock b : parts) {         vertexArray.addAll(b.vertexArray);         colourArray.addAll(b.colourArray);      }`
10  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 14:41:21
You could add block picking ;-)

What about some mobs that walk around?

Looking good and you have made some great progress.  Must ask, how did you do the model for your player and how did you set the camera for it?

I do plan on having a block picker but since I want to work on a survival zombie game 1st like cod zombies I will probably have just weapon selector then when im finish just work on a voxel engine.  I also do plan on adding mobs probably zombies but not just zombies as in the walking dead but zombie dogs and other animals I can think would fit the game.

The model for the player is me just playing around with my own model class I made which just sets the
x,y,z,sizeX,sizeY,sizeZ,R,G,B,alpha

and for the camera is not bound the the player its more or less a 3D vector that when it comes to render I call this method within my camera class;
 1  2  3  4  5  6 `   public void setView() {      glRotatef(_rx, 1, 0, 0);      glRotatef(_ry, 0, 1, 0);      glRotatef(_rz, 0, 0, 1);      glTranslatef(_x, _y, _z);   }`

If you want to know about my model class just ask and ill share it
 11 Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-22 12:06:07 Quote from: Pauler on 2013-04-22 11:56:42Quote from: TH3Fatal on 2013-04-22 11:47:08Are 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 face1   /3|  / |2/   40,10,01,11,0This is just the x and y but you can just adapt it for each of the other faces.
 12 Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-22 11:47:08 Are you talking about a 3D triangle or a 2D triangle?
 13 Game Development / Newbie & Debugging Questions / Re: [LWJGL] 3d Blocks And Noise? on: 2013-04-22 07:58:42 Quote from: PeterNicholson on 2013-04-21 15:47:38Thanks a lot. I guess I didn`t do all of my homework  I would of never of known if I didn't find that post but yea I'm glad I could of helped.
 14 Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 07:12:22 So the past few days I havent done much as in coding wise but I have some nice stuff to show for it tho.I adapted my model class to accommodate for terrain as well so now I can generate walls which are very cool and I am happy I got this working.I also worked on a quick item drop class a few mins ago and its very badly coded atm but what it does as you can see is it gets a 2D sprite and converts it into a 3D representation and this has to be the best thing I have coded so far.Also guys im still open to some suggestions on what I can add later .
15  Game Development / Newbie & Debugging Questions / Re: [LWJGL] 3d Blocks And Noise? on: 2013-04-21 15:35:49
When I was developing / still developing my voxel engine I came across a thread where HeroesGraveDev suggested
http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
and for the code aspect when you get the noise class setup would be
 1 `int height = (int) (SimplexNoise.noise(x/16F, y/16F)*16F);`

Hope this helps you in your engine .
 16 Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-19 20:24:50 Looks awesome so fare. Nice to see save and loading is working for you I just got save and loading done for me voxel game thanks to Vermeer.
17  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-19 19:55:09
Hi

As promised. This does work, but it may not be the best way of doing it. Also its has poor exception handling, and you would need something more robust, but it may help you get it working.
Or it may prompt others to add more robust sugestions.Please ask questions if you cant get it to work.

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67 `public void writeChunk (int chunkNumber){                        byte[][][] writeChunk = new byte[16][16][16];            //write the data into a temp array      for (int xC = 0; xC < 16; xC++) {         for (int zC = 0; zC < 16; zC++) {                     for (int yC = 0; yC < 16; yC++) {                           writeChunk[xC][yC][zC] = (byte) chunks[chunkNumber].getblockID(xC, yC, zC);                                    }         }      }            //output file      String file = new String(chunks[chunkNumber].getName()+".dat");      try {         ObjectOutputStream objOut = new ObjectOutputStream( new FileOutputStream(file));         objOut.writeObject(writeChunk);         objOut.close();      } catch (Exception e) {               e.printStackTrace();      }            System.out.println("Written chunk "+ file);         }      public void readChunk (int chunkNumber){            byte[][][] readChunk = new byte[16][16][16];                        //inputfile file      String file = new String(chunks[chunkNumber].getName()+".dat");      try {                  FileInputStream fileIn = new FileInputStream(file);         ObjectInputStream in = new ObjectInputStream(fileIn);         readChunk = (byte[][][])in.readObject();         in.close();         fileIn.close();            } catch (Exception e) {                  e.printStackTrace();      }            //send the read chunk array      for (int xC = 0; xC < 16; xC++) {         for (int zC = 0; zC < 16; zC++) {                     for (int yC = 0; yC < 16; yC++) {                         chunks[chunkNumber].setblockID(xC, yC, zC, readChunk[xC][yC][zC]);                                    }         }      }      System.out.println("Opened chunk "+ file);         }`

Thanks so much Vermeer, I could kiss you. No homo. I have implemented it into make game and made a few tweaks and now the saving is working nicely I will probably end up adding another save file that will probable hold the map data such as door costs and spawning points for zombies and other mobs. Each chunk takes up 7kb.

In other news I improved my model creating method I made.

So after playing around with my modeling code I ordinarily setup to make mobs and players more detailed and just to overall create stuff I have finally settled on a nice and easy method that works for me.
One function controls everything from the x,y,z position to the size of the shapes and also the colours and alpha channel and with little to no frame drop and if anyone wants to know the details it is rendering 25 blocks for that model
 18 Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-19 11:23:33 Quote from: steg90 on 2013-04-19 06:58:04That looks good. Maybe you could serialize your blocks - use some form of xml?It is best to have minimum data in your block structure.Do you have your camera working?Thanks I have been working on it or a few hours and XML would of been my next approach since I would store the x y z and block ID for each block inside the chunk and if needed the price e.g a door. I also got camera moving and have the pitch locked so you can't keep rotating. Quote from: Vermeer on 2013-04-19 09:38:17Looking good!As steg mentions having a serialzable form of data would help really cut down the amount of loading.you could use a id-number for the block, and a second number for its value...? I guess it depends on how many variable you think you will need? or how large the variables would be. Maybe you can get away with 2 bytes?I just used 1 byte per block for my game.  ID=3 is stone etc....I just saved a serialized array of bytes. Im at work at the moment but I can paste my code here that will save this information for you later if you need it.Thanks Vermeer and yea if you show me the code that would help a lot. Much appreciated. Quote from: BrassApparatus on 2013-04-19 10:22:17This sounds super cool, you gotta keep us all posted It sound cool but its if I can do it and with other stuff I have done I hope I can since a lot of people like it and I will decently keep this thread updated.
 19 Games Center / Cube World Projects / Voxel Engine Zombies Game - Problem on: 2013-04-18 20:52:44 So after a few days of pondering around ideas for a game so I can learn LWJGL I though of doing as many have in the past a minecraft style voxel engine and then I thought what would make this different from other voxel games out there. That is where I came up with the idea of incorporating a zombie survival / map like CoD zombies with a voxel engine since I don't want to dive into the deep end of LWJGL.I am always looking for constructive criticism and ideas on how to improve the game in anyway possible. Taskssave and load chunksmake model making more easier so it allows anyone to create modelsplayer controlled modelzombies and any other mobsMap and doorsConceptSo as I said it is a voxel zombie survival game where the player has to survive rounds of the undead for survival or have an objective to reach that will cause the game to end. I also want it so anyone can be able to make maps and so I want to make a way for the player to be able to customize the maps to the way they want it to be played.ScreenshotsBeen playing around with 2D spritesheet to 3D models. Models and names of weapons can be changed before the final game is released.I adapted my model class to accommodate for terrain as well so now I can generate walls which are very cool and I am happy I got this working.I also worked on a quick item drop class a few mins ago and its very badly coded atm but what it does as you can see is it gets a 2D sprite and converts it into a 3D representation and this has to be the best thing I have coded so far.A small look at my player model since I just implemented it and though I would create something that can be compared to with the size of the worlds blocks.Some simple terrain generation just to handle chunks and also develop on the voxel engine aspect of the game.One function now controls everything from the x,y,z position to the size of the shapes and also the colours and alpha channel and with little to no frame drop and if anyone wants to know the details it is rendering 25 blocks for that model ProblemThe problem that I currently face are as followed;Rotating weapon
 20 Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-17 20:13:35 Quote from: steg90 on 2013-04-17 19:58:13@TH3Fatal - we are all doing these sort of 'minecraft' clones for learning purposes :-)So am I well the voxel aspect because I have an idea for a small game that can use voxels instead of diving in the deep end of java game development
 21 Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-17 19:46:35 This looks very nice but forgive me I just quickly read most the posts and was wondering what makes this different from minecraft? Also do you have a way to save and load maps yet?
 Pages: [1]
 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 rwatson462 (30 views) 2014-12-15 09:26:44 Mr.CodeIt (20 views) 2014-12-14 19:50:38 BurntPizza (42 views) 2014-12-09 22:41:13 BurntPizza (76 views) 2014-12-08 04:46:31 JscottyBieshaar (37 views) 2014-12-05 12:39:02 SHC (50 views) 2014-12-03 16:27:13 CopyableCougar4 (48 views) 2014-11-29 21:32:03 toopeicgaming1999 (114 views) 2014-11-26 15:22:04 toopeicgaming1999 (102 views) 2014-11-26 15:20:36 toopeicgaming1999 (30 views) 2014-11-26 15:20:08
 LiquidNitrogen 35x basil_ 32x Rayvolution 30x HeroesGraveDev 26x BurntPizza 18x kevglass 17x appel 17x kpars 15x Gibbo3771 14x gouessej 14x Riven 12x Ecumene 10x princec 10x SHC 10x KevinWorkman 9x pitbuller 9x
 Resources 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:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50
 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