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 (535)
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
  ignore  |  Print  
  Voxel Engine Zombies Game - Problem  (Read 4347 times)
0 Members and 1 Guest are viewing this topic.
Offline TH3Fatal

Junior Member


Medals: 2



« Posted 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

Offline steg90

Senior Member


Medals: 1



« Reply #1 - Posted 2013-04-19 08:58:04 »

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

JGO Coder


Medals: 16



« Reply #2 - Posted 2013-04-19 11:38:17 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BrassApparatus

Junior Member





« Reply #3 - Posted 2013-04-19 12:22:17 »

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

Junior Member


Medals: 2



« Reply #4 - Posted 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.

Offline Vermeer

JGO Coder


Medals: 16



« Reply #5 - Posted 2013-04-19 21:04:37 »

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);
     
   }




Offline TH3Fatal

Junior Member


Medals: 2



« Reply #6 - Posted 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

Offline TH3Fatal

Junior Member


Medals: 2



« Reply #7 - Posted 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.

Offline steg90

Senior Member


Medals: 1



« Reply #8 - Posted 2013-04-22 16:35:42 »

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?

Offline TH3Fatal

Junior Member


Medals: 2



« Reply #9 - Posted 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

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

Senior Member


Medals: 1



« Reply #10 - Posted 2013-04-22 17:40:30 »

Thanks,

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

I've just added some pyramid type landscape:


https://www.youtube.com/watch?v=FnEWVR3_rO0


Looking at doing some domes next, half a sphere or even a cardioid (r=2a(1+cos theta) )...

Now domes added :-) :


https://www.youtube.com/watch?v=DyAheqbhbk4


Code to do this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public int SetUpDome() {
      for (int x = 0; x < CHUNK_SIZE; x++) {
         for (int y = CHUNK_SIZE - 1; y > CHUNK_SIZE / 2; y--) {
            for (int z = 0; z < CHUNK_SIZE; z++) {
               
               if (Math.sqrt((float) (x - CHUNK_SIZE / 2)
                     * (x - CHUNK_SIZE / 2) + (y - CHUNK_SIZE / 2)
                     * (y - CHUNK_SIZE / 2) + (z - CHUNK_SIZE / 2)
                     * (z - CHUNK_SIZE / 2)) <= CHUNK_SIZE / 2) {
                  Blocks[x][y-8][z].SetActive(true);
                  Blocks[x][y-8][z].SetType(BlockType.BlockType_GoldBlock);

               } else {
                  Blocks[x][0][z].SetType(BlockType.BlockType_Grass);
                  Blocks[x][0][z].SetActive(true);
               }

            }
         }
      }
      return this.rebuildChunk();
   }

Offline TH3Fatal

Junior Member


Medals: 2



« Reply #11 - Posted 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);
      }

Offline steg90

Senior Member


Medals: 1



« Reply #12 - Posted 2013-04-22 18:17:53 »

Thanks,

How do you animate the model?
Offline TH3Fatal

Junior Member


Medals: 2



« Reply #13 - Posted 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

Offline steg90

Senior Member


Medals: 1



« Reply #14 - Posted 2013-04-22 18:31:29 »

PS - did you put in collision detection and any culling?

I'm doing collision detection at the moment - the joy of it!
Offline TH3Fatal

Junior Member


Medals: 2



« Reply #15 - Posted 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

Offline steg90

Senior Member


Medals: 1



« Reply #16 - Posted 2013-04-22 18:39: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!

Offline TH3Fatal

Junior Member


Medals: 2



« Reply #17 - Posted 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);

Offline Pauler
« Reply #18 - Posted 2013-04-22 18:43:17 »



Just using
1  
glEnable(GL_CULL_FACE);

Same here.
Offline steg90

Senior Member


Medals: 1



« Reply #19 - Posted 2013-04-22 18:47:25 »

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 ;-)
Offline TH3Fatal

Junior Member


Medals: 2



« Reply #20 - Posted 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

Offline steg90

Senior Member


Medals: 1



« Reply #21 - Posted 2013-04-22 18:55:41 »

So this also limits the amount of faces you are drawing then?

Frustum culling could be used to cull chunks that are not in the viewing plane.

I'm looking at using an octree for my chunks now which should make collision easier.
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #22 - Posted 2013-04-22 18:56:30 »

Hi!
If you need it, here is my Frustum class. It includes a method that checks if a block is in the frustum:
https://github.com/marcuiulian13/Cube3D/blob/master/src/ro/enoor/cube3d/world/rendering/Frustum.java

Getting a project done is by far the most hard thing in game development.
Offline TH3Fatal

Junior Member


Medals: 2



« Reply #23 - Posted 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.

Offline TH3Fatal

Junior Member


Medals: 2



« Reply #24 - Posted 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

Offline Longor1996
« Reply #25 - Posted 2013-04-22 21:07:55 »

Hi there!

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

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

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

Junior Member


Medals: 2



« Reply #26 - Posted 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.

Offline steg90

Senior Member


Medals: 1



« Reply #27 - Posted 2013-04-22 21:45:06 »

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
Offline steg90

Senior Member


Medals: 1



« Reply #28 - Posted 2013-04-22 21:57:38 »

@marcuiulian13 - hi, I use something very similar.

How do you use yours? Do you give it the chunks x, y, z position and size, with x,y,z being the center of the chunk and z half its width?

Thanks
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #29 - Posted 2013-04-22 22:06:55 »

No, i give it the chunk's x, y, z and it's total size, because i don't use the center of the object as the origin.

Getting a project done is by far the most hard thing in game development.
Pages: [1] 2
  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.

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

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

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

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

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

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

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00
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!