Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-23 00: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 21:13:02
Hi there!

How about:

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 21: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 Smiley
4  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 19: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 18: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 18: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 18:34:26
PS - 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 Tongue
8  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-22 18:19:15
Thanks,

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 18:04:53
Thanks,

Yes, would like to know more about your model class :-)

Nice and here is the code;
The addblock class
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<float[]> vertexArray = new ArrayList<float[]>();
   public List<float[]> colourArray = new ArrayList<float[]>();

   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<float[]> vertexArray = new ArrayList<float[]>();
   List<float[]> colourArray = new ArrayList<float[]>();
   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 16: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 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.
12  Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-22 13: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 09:58:42
Thanks a lot. I guess I didn`t do all of my homework  Roll Eyes

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 09: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 Smiley.
15  Game Development / Newbie & Debugging Questions / Re: [LWJGL] 3d Blocks And Noise? on: 2013-04-21 17: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 Smiley.
16  Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-19 22:24:50
Looks awesome so fare. Nice to see save and loading is working for you Smiley I just got save and loading done for me voxel game thanks to Vermeer.  Cool
17  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-19 21: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 Smiley
18  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 2013-04-19 13:23:33
That 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. Smiley

Looking 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. Smiley

This sounds super cool, you gotta keep us all posted Smiley


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 22: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.

Tasks
  • save and load chunks
  • make model making more easier so it allows anyone to create models
  • player controlled model
  • zombies and any other mobs
  • Map and doors

Concept
So 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.

Screenshots
Been 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 Smiley

Problem
The problem that I currently face are as followed;
  • Rotating weapon
20  Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-04-17 22:13:35
@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 21: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.

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

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

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

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

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

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

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

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

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

CJLetsGame (193 views)
2014-04-01 02:16:10
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

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