Java-Gaming.org Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (612)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (659)
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  Game Development / Newbie & Debugging Questions / World architecture and internal construction? on: 2015-08-02 06:13:04
I have a WorldMap class that currently stores arrays of Rooms, Regions, and Connections, kinda like a big node-looking map.

- Rooms are more broad than a house room, a room can be thought of as any one screen, or one level, but much less complex at the moment.
- Connections connect two Rooms at specific points.  The entrances have specific styles associated with them (fancy, plain, (boss!), etc).
- Regions are simply a bucket of Rooms that will later provide rendering details (styles, etc), so rooms within a Castle region will have brick walls (probably).

My question is, what would JGO recommend when it comes to just how stuff is structured internally?  The ideas I have in mind are:

1. see the above, basically the world is a big bag of everything.  Objects have a global identifier instead of more localized ones.  Arguably with this approach, I could get rid of Regions and instead make rooms self-contained with stuff for styles and traps and everything else.  It feels a lot closer to entity-component-based design at that point, unless I'm crazy, which could potentially work very well for whenever I decide to add dungeon traps and loot and everything else that a game could probably have, since stuff is "decoupled" so to speak.

2. The world stores an array of regions and an array of connections between regions.  The regions store a collection of rooms and a collection of connections between those rooms.  The objects would instead have a local identifier value, instead of one as it would be in the entire world.  This feels more like regular object-orientated, inheritance-like (or at least tree-like), since the tree of objects is world, region, room.  (Connections kinda exist in limbo like branches, whatever)  This approach is kinda nice since I won't have spare rooms floating about that I forget to attach or something.  I also don't want to slip into the mindset that I should try to fit everything into ECS design, because there are some things that I feel just don't quite jive with it.

3.  Kinda weak-feeling, but posted for the sake of completeness:  make each room self-contained, with references to its own paths and the region it is in, along with whatever else might come along.  The only problem is that I feel like this is inefficient, not in an optimization sense, but in the sense that I need to store objects repeatedly in different objects and have multiple references.  It sounds like a web instead of a well-ordered chaos, and potentially very messy.

Any feedback is appreciated!  I'm not looking for hard answers, just for some feedback for those that have likely been doing this for probably quite a bit longer than I have.

[EDIT]:  Now that I think about it, this probably belongs in Game Design.  Kinda muddled.
2  Java Game APIs & Engines / Engines, Libraries and Tools / LibGDX drawing of sprites? on: 2015-04-24 05:17:05
So, I have a grid of tiles I wish to render, along with various other objects and bits / pieces atop those tiles.  I've determined that the way I should go about it is to only render the tiles around the player's position, which isn't too hard.

The thing is, LibGDX's SpriteBatch has a maximum size of 5460 sprites per drawing call, correct?  There might well be more than that at any given point, considering the tiles are 8x8 and the screen is 640 x 480, coming up to 4800 sprites in tiles alone.  On top of those might be items and entities and other such nonsense.

Does anyone have any advice for me, whether to use separate spritebatches or something like that?  Would it be more efficient?  Or can I increase the maximum size of a spritebatch and would THAT be more efficient?

Thanks!
3  Game Development / Newbie & Debugging Questions / Drawing voxel pixels? on: 2015-04-23 00:58:05
So, I've looked at games like Voxatron and that weird little thing that Kevglass made, and I liked his strange 2d-3d voxel pixel things enough that I wanted to create something like it.

So far as I've found, I need a 3d grid of cells, and the cells can be occupied by a kind of block with a color.  However, the way to "cull" the blocks (Not draw those behind others to avoid drawing pixels) escapes me.

For that matter, I've looked into rendering with pixels, and I've seen a couple methods, such as OpenGL's glDrawPixels() method and using a BufferedImage and modifying its RGB buffer.  But both were apparently not very good in the optimization department.  For reference, the area that must be rendered in pixels is 640 x 480.

I can easily create a 3d grid system with chunks (also dubious, but seem necessary) but I'm not sure how to translate 3d grid into the individual pixels.

Can anyone give me any pointers to methods of rendering, and how to implement them?
4  Game Development / Newbie & Debugging Questions / Rotation issue - pointing at a certain point on: 2015-03-01 20:11:45
So, I have code here for rotation of an entity.  This is on LIBGDX, if that's important.

1  
rotation.degrees = (MathUtils.atan2(pos.y - position.y , pos.x - position.x) * MathUtils.radiansToDegrees) - 90;


where pos is the position of the mouse, and position is the entity's position.  The strange thing is that atan2 is returning incorrectly or something, since the values I'm getting are NOT what I need.  It's like, the more I go along the X or Y axis, the more it rotates, but only within 90 degrees or something like that.

What am I doing wrong?  I've looked up several solutions and every single one pointed to this code, or a variant thereof.


EDIT: I fixed the problem.  It turns out that it was not a calculations problem, but rather a rendering problem - I didn't account for the rendering system's offset.
5  Game Development / Newbie & Debugging Questions / Strange issue with recursion? on: 2013-12-28 21:26:07
So essentially, the following snippet of code loops endlessly.

1  
2  
3  
4  
5  
      while (parent != null) {
         System.out.println(parent);
         offset.add(offsetFromParentWithRotation());
         parent = parent.getParent();
      }


Why is that?  Am I not allowed to set the parent like that, or am I missing something very obvious?
6  Game Development / Newbie & Debugging Questions / Re: OOP Noob - Extending Classes, or How Else to Create Unique NPCs? on: 2013-11-16 14:13:03
This may be a bit advanced or a jump to get into, but a component-system based approach is quite efficient, from my own experience.  Essentially, each entity is simply an ID that's assigned predefined component classes - like health, or damage, or movement - that another class, a system or handler, takes into account to make the entity do what you want it to.

The one I like currently is the Artemis Entity System.  http://gamadu.com/artemis/
7  Game Development / Game Play & Game Design / Re: Creating a circular "grid" ? on: 2013-11-16 01:28:32
Abuse has the right idea, and philfrei goes a little more in depth.
8  Game Development / Game Play & Game Design / Re: Creating a circular "grid" ? on: 2013-11-11 16:17:46
I would do it that way, were it not for that you're supposed to be viewing these at all angles - the "up" can be in any direction along this single plane.  But since it's like that, it's supposed to look like everything is going towards the center - if I were to use a square grid in this case, if you were looking at it at a 45 degree angle, everything would be diagonal.
9  Game Development / Game Play & Game Design / Creating a circular "grid" ? on: 2013-11-11 15:55:33
My quest is to essentially create different-sized rings, centered around the same point, that are made of 1-unit pieces.

My problems are that I have difficulty understanding the math required to create such.  I know how to create rings that are made of differing SIZED pieces, like 360 degrees = 360 pieces per ring, but the pieces get progressively larger as you go away from the origin point.  I don't want that - I want the pieces to stay the same size, instead creating more as you go outward.

I was hoping someone would help me figure out how to fix up my code in order to do this.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      float radians = (float) Math.toRadians(degrees);
     
      float[] data = new float[] {};
     
      float circ = MathUtil.getCircumference(depth); // Get the circumference at the chosen depth
      float circt = MathUtil.fastfloor(circ); // Round the circumference
     
      for (int c = 0; c < circt; c++) { // For every 1 "unit" do
         float rads = (float) c / circt; // Dividing the count by the circumference gives us the radian measure for each block
         
      }


That was as far as I had gotten before this made itself clear to my mind.
10  Game Development / Newbie & Debugging Questions / Re: Using LWJGL color API? on: 2013-07-13 03:45:16
Adding this snippet of code to ask:  Am I going about this the correct way?  I need 4 floats (one representing each of r, g, b, a) and they're supposed to be values between 0 and 1.  I'm trying to convert from a hexadecimal integer (eg 0xFFFFFFFF) to the four floats.

1  
2  
3  
4  
5  
6  
7  
8  
   protected float[] getRGBA(int color) {
      return new float[] {
            (color & 0xFF) / 255f,
            (color >> 8 & 0xFF) / 255f,
            (color >> 16 & 0xFF) / 255f,
            (color >> 24 & 0xFF) / 255f
      };
   }


Am I thinking about this the right way?
11  Game Development / Newbie & Debugging Questions / Re: Face culling on voxels. on: 2013-07-13 01:26:48
Ahh, that's actually what I was busy doing.  I eventually figured out the whole access issue, although I'm not sure the method that I went about is correct.

By the way, there is no World class;  each voxel group effectively needs to know about all the voxels it contains.  So i suppose there are many World classes in that respect; the basic group and all of the ones that extend it (so they can behave differently - ie a turret of a ship needs to rotate differently than the ship itself.)  To that end, this is what I've come up with:

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  
   public void updateVBO() {
      int numfaces = 0;
      boolean front = false, back = false, left = false, right = false, top = false, bottom = false;
      for (int x = 0; x < width; x++) {
         for (int y = 0; y < height; y++) {
            for (int z = 0; z < length; z++) {

               if (isOOB(x+1, y, z) || !isOCC(x+1, y, z)) {right = true; numfaces++;}
               if (isOOB(x-1, y, z) || !isOCC(x-1, y, z)) {left = true; numfaces++;}
               if (isOOB(x, y+1, z) || !isOCC(x, y+1, z)) {top = true; numfaces++;}
               if (isOOB(x, y-1, z) || !isOCC(x, y-1, z)) {bottom = true; numfaces++;}
               if (isOOB(x, y, z+1) || !isOCC(x, y, z+1)) {right = true; numfaces++;}
               if (isOOB(x, y, z-1) || !isOCC(x, y, z-1)) {left = true; numfaces++;}

               voxelData(x, y, z, voxels[x][y][z].type, numfaces, front, back, left, right, top, bottom);

            }
         }
      }
   }

   protected boolean isOOB(int x, int y, int z) {
      if (x * y * z > width * height * length || x * y * z < 0) return true;
      return false;
   }
   protected boolean isOCC(int x, int y, int z) {
      if (!isOOB(x, y, z)) if (voxels[x][y][z].opaque) return true;
      return false;
   }


Also, I've refrained from putting data into the actual floatbuffer for now because I don't want the buffer being too big.  That being said, compacting it would work to remove the extra space, right?
12  Game Development / Newbie & Debugging Questions / Re: Using LWJGL color API? on: 2013-07-12 23:19:41
So would I only need 1 color "vertex" when interleaving color with position in my FloatBuffer?  From what it looks like, that seems to be the case.
13  Game Development / Newbie & Debugging Questions / Face culling on voxels. on: 2013-07-12 19:56:41
I have a segment of code here that's supposed to cull faces of voxels that should be invisible.

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  
   private FloatBuffer voxelData(int x, int y, int z) {
      float r = rand.nextFloat(), g = rand.nextFloat(), b = rand.nextFloat();
      float xscale = x * scale, yscale = y * scale, zscale = z * scale;
      int numfaces = 6;

      boolean top = true, bottom = false, left = true, right = true, front = true, back = true;
      if (x != width--  && voxels[x + 1][y][z].isActive) {right = false; numfaces--;}
      if (x != 0         && voxels[x - 1][y][z].isActive) {left = false; numfaces--;}
      if (y != height-- && voxels[x][y + 1][z].isActive) {top = false; numfaces--;}
      if (y != 0         && voxels[x][y - 1][z].isActive) {bottom = false; numfaces--;}
      if (z != length-- && voxels[x][y][z + 1].isActive) {front = false; numfaces--;}
      if (z != 0         && voxels[x][y][z - 1].isActive) {back = false; numfaces--;}

      if (numfaces == 0) return null;

      FloatBuffer data = BufferUtils.createFloatBuffer(numfaces * 24);

      if (top) { data.put(new float[] {
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
      });}

      if (bottom) { data.put(new float[] {
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
      });}

      if (left) { data.put(new float[] {
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
      });}

      if (right) { data.put(new float[] {
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
      });}

      if (front) { data.put(new float[] {
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale + 0.5f * scale,   r, g, b,
      });}

      if (back) { data.put(new float[] {
            this.x + xscale + 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale - 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale - 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
            this.x + xscale + 0.5f * scale,      this.y + yscale + 0.5f * scale,      this.z + zscale - 0.5f * scale,   r, g, b,
      });}

      data.flip();
      return data;
   }

The segment is passed the x, y, and z values through a triple-nested for-loop checking each voxel in a 3d array.  However, the code seems to only output left and back sides; never any others.  Even then, it's only the left-bottom-back corner that renders, and not even the bottom face; just the back, and three left faces from the edge, and a face one above that.
Here's a screenshot:  
14  Game Development / Newbie & Debugging Questions / Re: About lists and the elements inside of them. on: 2013-07-12 14:45:13
That's actually a very good tip.  However, isn't it sort of misleading when you're going through the interfaces for each component type rather than the actual object itself?

Also, I've abandoned that method of components for now and instead have a basic VoxelGroup class that has an enum of GroupTypes to determine how it should behave (Another class entirely).  The list of voxels from before is non-existant

With that in mind, would your interface method still work properly?  Or should I change my architecture slightly to accomodate?

And the idea of an abstract base class; would that replace the VoxelGroup class, and then I would create multiple classes for different types of groups, all of which would use an interface for commonly needed methods - that about sum it up?
15  Game Development / Newbie & Debugging Questions / Re: Using LWJGL color API? on: 2013-07-12 03:26:24
Indeed, the bytes thing is a good idea.  Could anyone give me a small example of how to convert bytes to a color, though?  It'd be very, very helpful indeed.
16  Game Development / Game Play & Game Design / Re: Intuitive Interface Design on: 2013-07-12 02:15:14
I like design B more.  It positions all the data that the player (Probably) cares about closer together.  The recent screenshot looks really nice, actually.  Oskuro's suggestion is a very good one too.

Perhaps there should be a way to assign hotkeys?  Those are always nice to have.

Also, a purely aesthetic idea, perhaps make it so that the player can change the GUI color?  Grayscale images + color interpretation?
17  Game Development / Game Play & Game Design / Re: Data structure for voxels? on: 2013-07-11 22:52:44
Would I not have to loop through with an array for collisions, then?  If you could explain a little more how a 3d (or even 1d) array wouldn't require looping for collisions, that'd make it a bit easier for me to wrap my head around.

Also, for the if statement, do you mean checking each index in the array like this, sorta?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
...
for (int x = 0; x < width; x++ {
     for (int y = 0; y < height; y++) {
          for (int z = 0; z < depth; z++) {
               if (voxels[x][y][z] != null) {
                    // mesh update code
               }
          }
     }
}
...


As it stands, that's what I'm using to create the VBO for the object.

While I'm typing this, another question:  how would I go about applying rotations to each object individually?  I know glRotate and glTranslate would work for the entire world or a single object, but I need to be able to move / rotate individual voxel groups, as well as individual voxels within a group.  If I wanted rotating / moving voxels within the group, it seems inefficient to have to go through and re-work the entire mesh of the thing.  So by that logic, I'm assuming I'd need to have the object have multiple groups of voxels?

Again, just brainstorming, putting it out there for any constructive folk who happen along.

EDIT:  On the subject of "subgroups", perhaps have an enum of what types of subgroups there are?

Also, things like:  Would the gun on a turret need to know about what's going on in the casing it's attached to, AND the main body of a ship?  Or would it just need to know the turret only, since the turret would already compensate for knowing the main body?  Is that kind of "inheritance" going to cause issues?  If so, is there another method around this?  (I'm thinking mainly rotation along this path; the main hull would have its rotation, the turret casing would have its rotation relevant to the hull, and the weapons on the turret would have its rotation relevant to the casing, which is relevant to the hull.)

And on the same topic, what about collisions within the same structure?  What if the turret gun knows about the casing, but not about the main ship?  It would collide / be restricted to the casing, but how would it know to collide with or interact with the main hull?  Is it possible to create a system that does all the collision checking and (possibly) queuing for them?  How would it work?  Raycasting?  Or perhaps another method.
18  Game Development / Game Play & Game Design / Re: Data structure for voxels? on: 2013-07-11 22:20:07
But that array again is larger than what's necessary.  Maybe the memory isn't a big issue, but the extra space still has to be looped through.  Wouldn't that affect the cpu load required rather significantly?
19  Game Development / Game Play & Game Design / Data structure for voxels? on: 2013-07-11 20:52:01
Well, I've thought about this for quite some time now, and I've come to hit what I believe is a roadblock.  If you're really going to help me, prepare for a bit of a read since I tend to over-explain things.

See, each of my voxels currently stores its own position values in 3 integers: x, y, z.  I understand that this is very inefficient in most cases, but more on that in a second.  Within my current structure, the voxels are assigned into groups that don't have a fixed count to them, nor a fixed position; they need to be dynamic as the player will be interacting with them, and also each group needs to be able to do things on its own - move, rotate, etc.  When I got to the point of storing the data, I had two separate ideas, which are below.  I'm doing the second option currently.

1  
2  
3  
4  
5  
// first option
private Voxel[][][] group_voxels = new Voxel[w][h][l];

// second option?
private List<Voxel> voxels = new ArrayList<Voxel>();


Now, the question comes down to efficiency of storage and data, as well as perhaps processing and rendering speed - though I'm not 100 percent certain about that last one.

For the first option, the pros are that I can infer the integer positions for each voxel through the index it's at in the 3d array.  However, doing this also creates a lot of wasted space, since odds are the entire group of voxels will never be filled (Giant cube structures aren't going to be very common).  For example, if I have a tree that's 48 voxels tall, 25 voxels wide, and 25 voxels in depth overall, the empty space (like around the trunk) is sitting there and taking up memory (I think?) where it could be better spent on other things.  It also introduces a bit of unneccessary checking when looping through, since it needs to check those empty spaces as well as the far more important occupied spaces.

For the second option, the plus is that there shouldn't ever be wasted space inside of the list, since only enough voxels are assigned at any point to the list to create their object; the wasted space around the tree trunk would disappear since the list never even bothers about that spot.  In addition, I believe that there would be a boost in general speed since when iterating through the list, it again never bothers to check what isn't there.  However, with this method, I can't come up with any way to infer the position of the voxels through usage of indices; the list doesn't know anything about the width or length or height, it just stores the voxels.  This leads me to using the 3-integer method described as above.

My question is, which is more efficient?  I'm not that experienced with serious programming structure and the sort, usually I just throw it together without a care for the efficiency, so I'd like a few opinions as well as maybe some tips and tricks if anyone's willing to share.

Also, if you actually read all of that, thanks for sticking with it.  I can really be a little too wordy at times.
20  Game Development / Newbie & Debugging Questions / Camera rotation around a central pivot point? on: 2013-07-10 21:23:18
I'm trying to use vector math to rotate the view around a central pivot point, which may move around.  This is the code that I have so far:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public void followObject(Object target) {
      if (target instanceof Voxel) {
         Vector3f tpos = new Vector3f(((Voxel)target).x, ((Voxel)target).y, ((Voxel)target).z);
         pitch = Vector3f.angle(new Vector3f(1, 0, 0), tpos);
         yaw = Vector3f.angle(new Vector3f(0, 1, 0), tpos);
         roll = Vector3f.angle(new Vector3f(0, 0, 1), tpos);
         this.setPosition(tpos.x + (pitch * 10.0f * zoom), tpos.y + (yaw * 10.0f * zoom), tpos.z +(roll * 10.0f * zoom));
         GLU.gluLookAt(this.x, this.y, this.z, tpos.x, tpos.y, tpos.z, 0, 1.0f, 0);
      }
   }


Could anyone give me tips or pointers as to how I can get this to work?
21  Game Development / Newbie & Debugging Questions / Using LWJGL color API? on: 2013-07-10 16:16:50
Could anyone break down how to use the Color API of LWJGL to me?  From my testing, all of these colors are apparently the same:
1  
2  
3  
4  
5  
// Color c = new Color(r, g, b, a);

Color c = new Color(255, 155, 0, 255);
Color c = new Color(155, 255, 0, 255);
Color c = new Color(100, 200, 0, 255);

I searched on google for about an hour and didn't come up with anything substantial.  Although I am aware of bitshifting.  Do I need to shift
22  Game Development / Newbie & Debugging Questions / Code snippet that needs reviewing? on: 2013-07-10 05:04:31
I have a segment of code that's supposed to put floats into a FloatBuffer to create a small voxel; however, whenever I try to render it, it comes out as a flat plane.
Could anyone help me with this?

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  
   public float[] voxelVertices(float x, float y, float z) {
      float xx = x * 0.2f, yy = y * 0.2f, zz = z * 0.2f;
      return new float[] {
            //   x,         y,            z
            // Top quad
            xx + 0.1f,      yy + 0.1f,      zz + 0.1f,
            xx - 0.1f,      yy + 0.1f,      zz + 0.1f,
            xx - 0.1f,      yy + 0.1f,      zz - 0.1f,
            xx + 0.1f,      yy + 0.1f,      zz - 0.1f,
            // Bottom quad
            xx + 0.1f,      yy - 0.1f,       zz - 0.1f,
            xx - 0.1f,      yy - 0.1f,      zz - 0.1f,
            xx - 0.1f,      yy - 0.1f,      zz + 0.1f,
            xx + 0.1f,      yy - 0.1f,      zz + 0.1f,
            // Front quad
            xx + 0.1f,      yy + 0.1f,      zz - 0.1f,
            xx - 0.1f,      yy + 0.1f,      zz - 0.1f,
            xx - 0.1f,      yy - 0.1f,      zz - 0.1f,
            xx + 0.1f,      yy - 0.1f,      zz - 0.1f,
            // Back quad
            xx + 0.1f,      yy - 0.1f,       zz + 0.1f,
            xx - 0.1f,      yy - 0.1f,       zz + 0.1f,
            xx - 0.1f,      yy + 0.1f,       zz + 0.1f,
            xx + 0.1f,      yy + 0.1f,       zz + 0.1f,
            // left quad
            xx - 0.1f,      yy + 0.1f,       zz - 0.1f,
            xx - 0.1f,      yy + 0.1f,       zz + 0.1f,
            xx - 0.1f,      yy - 0.1f,      zz + 0.1f,
            xx - 0.1f,      yy - 0.1f,      zz - 0.1f,
            // right quad
            xx + 0.1f,      yy + 0.1f,       zz + 0.1f,
            xx + 0.1f,      yy + 0.1f,      zz - 0.1f,
            xx + 0.1f,      yy - 0.1f,       zz - 0.1f,
            xx + 0.1f,      yy - 0.1f,       zz + 0.1f};
   }
23  Game Development / Newbie & Debugging Questions / Camera spazzing out, as well as render method not working as intended on: 2013-07-09 22:42:50
Never mind, I have figured out what the problem was.  Could someone remove this?
24  Game Development / Newbie & Debugging Questions / Re: About lists and the elements inside of them. on: 2013-07-09 04:51:59
Ahh, thank you very much.  This helps me enormously!
25  Game Development / Newbie & Debugging Questions / About lists and the elements inside of them. on: 2013-07-09 03:51:45
So I have a List of Component.java, right?  Inside of this list, I want to store a few types of classes all of which extends the Component.java class.  See, that part I can do just fine.  At present, I'm storing Wire.java's and Pipe.java's.

However, when it comes to accessing the different types inside of the list, I'm faced with a dilemma.

First I tried it like this:  for (Wire w : component_list)
However, it can't iterate over only a single type of component inside of the list; it's looking for Wires when the iterator only knows to return Components.

Seeing this, I tried:

for (Component c : component_list) {
     if (c.equals(Wire.class)) {
          Wire w = (Wire) c;
     }
}

However, I'm not sure that it's working properly.  I'm wondering, is the second option possible?
26  Game Development / Newbie & Debugging Questions / Re: Computing volume on: 2013-07-09 00:50:50
I honestly wouldn't know how to figure that out.  How would I check to see if a voxel is an exterior corner, or an interior corner?  Like, if I had an L-shaped container?

Each Voxel is assigned to a group called a Component, and the type of Component determines what those voxels do.  For example, a Chamber component can contain liquids, while Containers can hold solid cargo, and Pipes, which can hold and transport liquids.

The volume calculation is important only to Chambers and Containers at present, and the player places the walls of the chamber or container; once the player saves the current set of voxels, a class builds a new in-game Component based on what the voxels would do.  That's why I need to be able to calculate irregular spaces, since odds are that players will be making irregular shapes.
27  Game Development / Newbie & Debugging Questions / Computing volume on: 2013-07-09 00:08:28
What I mean by the title is that I have a set of voxels that are arrayed so that they encompass a 3d space.  The question is, can I compute the volume of this space in an efficient way?

I thought of starting inside of the space and checking the 6 directions from the beginning, and then checking the spaces beyond those, and so on until they hit a voxel, but that seems very inefficient to me.

In any case, any pointers are greatly appreciated.
28  Game Development / Newbie & Debugging Questions / Re: LWJGL camera zooming? on: 2013-07-08 18:13:01
Aha, yeah, I figured something like that would be needed.  Thanks for the help, though!  It really did help a lot.
29  Game Development / Newbie & Debugging Questions / Re: LWJGL camera zooming? on: 2013-07-08 16:25:04
Linear interpolation, huh?  I'll keep that in mind, thanks.

EDIT: nevermind, figured that one out.

However, my question now is:  Mouse.getDWheel() is returning an int of 120.  Is the 120 a universal value across all mouses, or do I need to create something to accomodate a change in that value?
30  Game Development / Newbie & Debugging Questions / LWJGL camera zooming? on: 2013-07-08 15:52:54
So I have a float value called zoom.  Zoom can be anywhere between 0.0125 and 1, with 1 being fully zoomed out, and 0.0125 being approximately 80 times zoomed in.

I'm attempting to change this value using the mouse scroll wheel, but I'm not sure how I would want to get a smooth zoom.  Would I repeatedly add (0.0125 * scroll wheel change) to the zoom value?

Or would I perhaps multiply zoom by something like 1.05?

Essentially, the question is, how would I go about creating a smooth zooming "range"?
Pages: [1]
 
Andrew_3ds (13 views)
2015-09-01 19:08:10

afikri (15 views)
2015-08-31 09:30:22

afikri (23 views)
2015-08-31 09:30:07

afikri (11 views)
2015-08-31 09:27:24

afikri (15 views)
2015-08-31 09:26:40

Roquen (20 views)
2015-08-29 11:30:54

GamerC4 (32 views)
2015-08-22 20:38:50

GamerC4 (28 views)
2015-08-22 20:37:18

GamerC4 (32 views)
2015-08-22 20:37:01

Kefwar (41 views)
2015-08-22 18:07:24
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37: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!