Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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] 2 3 ... 5
1  Game Development / Newbie & Debugging Questions / Re: Top Down Shooter Multiplayer and Box2D questions on: 2013-12-18 19:57:50
@65K, I don't think so...
You can run Box2D only on the server, setting the server to do all the logic, and the client only draw what's happening on server.
2  Game Development / Newbie & Debugging Questions / Re: Top Down Shooter Multiplayer and Box2D questions on: 2013-12-18 19:54:28
Hello there! I can't really answer your first question because i'm not an "expert" with networking.

2 - Yes, Box2D supports bullets. All you have tot do is to set a "isBullet" parameter and Box2D will handle it's collision as for a bullet.
3 - Yes, Box2D also supports line-polygon intersection. All you have to do is to call a rayCast method and you can handle what to do when a polygon is "hit".
3  Game Development / Newbie & Debugging Questions / Re: Box2D PolygonShape getVertex() problem on: 2013-12-09 13:26:51
Ok, now it's really uncommon. If I use libGDX's Array<> class instead of Java's ArrayList, everything is fine. Kind of weird.

LE: Ok, now everything is fine. It looks like when I was adding a vertex in the array, I needed to make a new Vector2, because the getWorldPoint is returning an Vector2 instance reused by the Body class. I hope this will help anyone who is having this problem.
4  Game Development / Newbie & Debugging Questions / Box2D PolygonShape getVertex() problem on: 2013-12-08 19:57:45
Hello!

I think I might have found a bug in LibGDX's Box2D implementation.
I am loading a TiledMap in my game, and the objects that are on the map are added to the Box2D world with this function:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
private void createStaticBody(Vector2 position, Shape shape, String name) {
   BodyDef bodyDef = new BodyDef();
   bodyDef.type = BodyDef.BodyType.StaticBody;
   bodyDef.position.set(position);

   FixtureDef fixtureDef = new FixtureDef();
   fixtureDef.shape = shape;

   Body body = world.createBody(bodyDef);
   Fixture fixture = body.createFixture(fixtureDef);

   if(name != null) fixture.setUserData(name);
}


The objects are added correctly, and are rendered correctly by the Box2DDebugRenderer.
The problem I have occurs when I want to handle myself overlaping of two objects. Using the ContactListener I find what Fixtures overlap (btw, all my game objects are made only by exactly one fixture), and then I do some magic.
The problem is: when I get the vertices from a fixture, all the data I get is the same, altough I request another vertex:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
List<Vector2> subjectPolygon = new ArrayList<Vector2>();
for (int i = 0; i < polyA.getVertexCount(); i++) {
   Vector2 vertex = new Vector2();
   polyA.getVertex(i, vertex);
   subjectPolygon.add(fA.getBody().getWorldPoint(vertex));
}
System.out.print("subject: ");
for(Vector2 vector2 : subjectPolygon) {
   System.out.print(vector2 + ", ");
}


prints

1  
subject: [16.055883:5.8014317], [16.055883:5.8014317], [16.055883:5.8014317], [16.055883:5.8014317]


Can anyone tell me if this is already a known bug, or I am doing something wrong?
5  Games Center / Featured Games / Re: The Intergalactic Trashman - [UPDATED - 08/12/2013] on: 2013-08-28 10:03:16
This looks amazing!!! I like the graphics so much! Shocked Good luck with development and (hopefully) with selling this game!
6  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-15 19:36:58
I have only one question: how you managed to get that transition from grass to sand and sand to water? Are you using a sprite for every type of transition (i.e. every tile to every other tile and every position (N S W E)) ?
7  Game Development / Game Mechanics / Re: Removing block and Moving Character on: 2013-06-26 22:01:35
You could just save the "target" position and move to it every update (assuming you don't want to do it instantly), as long as you are not there.
8  Game Development / Newbie & Debugging Questions / Re: Tiled RPG - Sprites on: 2013-06-26 21:43:22
If you're doing a top-down game (like GTA II) where your sprite is the same in all directions, you only have to rotate the sprite accordingly to the direction you're moving.
9  Game Development / Networking & Multiplayer / Re: Online rpg: best way to send map info on: 2013-06-09 19:09:57
You can divide the map into chunks and then use some sort of binary search to find what chunk you should send to the player.
10  Game Development / Networking & Multiplayer / [KryoNet] Solved. Error during deserialization on: 2013-06-05 22:29:05
SOLVED. I JUST HAD TO REGISTER CLASSES BEFORE STARTING THE SERVER AND CLIENT.



How are you?

I'm trying to do some networking stuff for my new project (yes, another one). What i'm trying to do is to create a client and a server (of course) and link them together. In my game i have the map made of chunks (made of tiles) that are sent (in a 3x3 area around the player) by the server at player connection, and then they (only the chunks that are needed) are sent only when the player moves.

The ploblem i have is that the client simply doesn't want to get the chunks. It throws this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Exception in thread "Client" com.esotericsoftware.kryonet.KryoNetException: Error during deserialization.
   at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:141)
   at com.esotericsoftware.kryonet.Client.update(Client.java:239)
   at com.esotericsoftware.kryonet.Client.run(Client.java:317)
   at java.lang.Thread.run(Thread.java:722)
Caused by: com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 14
   at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:113)
   at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:613)
   at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:724)
   at com.esotericsoftware.kryonet.KryoSerialization.read(KryoSerialization.java:57)
   at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:139)
   ... 3 more


I don't really send the Chunk object, but a Package of what is important of them: position and a byte[] representing the tiles.

Here is my "PackageManager" class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public abstract class PacketManager {
    public static final int TCP_PORT = 54555;
    public static final int UDP_PORT = 54777;

    public static void register(EndPoint endPoint) {
        Kryo kryo = endPoint.getKryo();
        kryo.register(ChunkPacket.class);
        kryo.register(byte[].class);
    }

    public static class ChunkPacket {
        public long chunkX, chunkY;
        public byte[] tiles;
    }
}
11  Game Development / Game Play & Game Design / Re: 2D Simplex noise infinite terrain generation on: 2013-05-30 21:11:13
Wow  Shocked, I just found the problem. I was using as intrepolation equation 3 * t^2 + 2 * t^3 instead of  6 * t3 * t * t - 15 * t3 * t + 10 * t3. I can't belive it makes such a difference. Although, thanks everyone for help. Now I can continue developing ^^.

P.S. : @matheus23, you have one small issue with your noise: when you use negative numbers, it messes up.
The way I fixed it was to change this code from SimplexNoiseLayerLazy get method:
1  
2  
3  
4  
final int cellX0 = ((int) x / density);
final int cellY0 = ((int) y / density);
final int cellX1 = ((int) x / density) + 1;
final int cellY1 = ((int) y / density) + 1;

with
1  
2  
3  
4  
final int cellX0 = GameMath.floor(x / density);
final int cellY0 = GameMath.floor(y / density);
final int cellX1 = GameMath.floor(x / density) + 1;
final int cellY1 = GameMath.floor(y / density) + 1;
12  Game Development / Game Play & Game Design / Re: 2D Simplex noise infinite terrain generation on: 2013-05-30 20:41:29
@matheus23 You say that i shoult try making a new seed for each Tile and set its seed to offsetX * x + offsetY or something like this? I don't really understand what you said in your last post. Sorry.. Cheesy
13  Game Development / Game Play & Game Design / Re: 2D Simplex noise infinite terrain generation on: 2013-05-30 10:18:26
@philfrei: My problem is not the noise generation, but its continuity.

@HeroesGraveDev: Thanks for the reply.

I am generating ech chunk with a double for loop (for tileX in chunk and for tileY in chunk), then I create a new Tile object using as its id a value based on the value returned by the noise get method:
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  
//Chunk generation code
public void generate() {
    for(int tileY = 0; tileY < SIZE; tileY++) {
        for(int tileX = 0; tileX < SIZE; tileX++) {
            tiles[tileY * SIZE + tileX] = new Tile(this, map.getGenerator().get(tileX + offsetX, tileY + offsetY));
        }
    }
}

//MapGenerator get method
public int get(int x, int y) {
    float noiseValue = simplexNoise.get(x, y);

    if(noiseValue > 0) {
        if(noiseValue <= 0.2f) {
            return TileType.SAND.id;
        } else if(noiseValue <= 0.4f) {
            return TileType.GRASS.id;
        } else if(noiseValue <= 0.6) {
            return TileType.TREE.id;
        } else if(noiseValue <= 0.8) {
            return TileType.DIRT.id;
        } else {
            return TileType.STONE.id;
        }
    }
    return TileType.WATER.id;
}
14  Game Development / Game Play & Game Design / 2D Simplex noise infinite terrain generation on: 2013-05-29 22:31:13
Hello!

Long time since my last question (i hope this is good). Grin
I'm struggling these days to achive a infinite map generation in a 2D top-down game. I've tried many noise algorythms, and finally i've sticked with matheus23's implementation from his utils library (https://github.com/matheus23/Utils), more exactly, with his SimplexNoiseLazy2.

The problem i have is the terrain continuity.
As you can see in the next pictures, if i call the get method from the noise with just x and y (tile's coordinates in chunk (from 0 to 15)), i get a scattered terrain, somehow random.
If i call the get method with x / A and y / A (A is a float), i get a smooth terrain, but it is broken, but rellatively correct. What i see is that A represents the width and the height of the generated noise.




P.S.: In both images i used 8 octaves and smoothness 2.

Can anyone help me with this problem?
15  Game Development / Newbie & Debugging Questions / Re: {lwjgl} "lag" problem on: 2013-05-04 14:24:25
Take note your jar isn't working on 64-bit platform. Error:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Iulian\AppDa
ta\Local\Temp\natives-656819368\lwjgl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary1(Unknown Source)
        at java.lang.ClassLoader.loadLibrary0(Unknown Source)
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at org.lwjgl.Sys$1.run(Sys.java:73)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:95)
        at org.lwjgl.Sys.<clinit>(Sys.java:112)
        at Loop.getTime(Loop.java:34)
        at Loop.getDelta(Loop.java:26)
        at Board.<init>(Board.java:14)
        at Game.<init>(Game.java:16)
        at Game.main(Game.java:47)
16  Games Center / Contests / Re: Ludum Dare 26 starting 26th April! on: 2013-04-30 01:37:53
Here is my entry (now for jam because I had a MAJOR bug Sad )

http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=19514
17  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 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.
18  Games Center / Cube World Projects / Re: Voxel Engine Zombies Game - Problem on: 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
19  Game Development / Newbie & Debugging Questions / Re: Invisible Map [LibGDX] on: 2013-04-08 12:14:11
Here is how i did my rendering (notice i'm not using tiled map):
https://github.com/marcuiulian13/rpg/blob/master/RPG/src/ro/enoor/rpg/world/WorldRenderer.java

I think that the camera.translate(width / 2, height / 2); isn't needed.
20  Game Development / Newbie & Debugging Questions / Re: OpenGL Fog not working on: 2013-04-07 20:10:29
<a href="http://www.youtube.com/v/o-tMnrhtmiA?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/o-tMnrhtmiA?version=3&amp;hl=en_US&amp;start=</a>

Here is a video showng my problem. Thanks!
21  Game Development / Newbie & Debugging Questions / OpenGL Fog not working on: 2013-04-07 14:53:12
Hello!

I can't make the fog work in my game: it is not "following" the player, it is depending on z-axis.
I already searched for bad GL_PROJECTION matrix, but i only call it once. Here is my rendering code, if anyone could help me, thank you:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public void updateCamera() {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50f, (float) Main.WIDTH / Main.HEIGHT, 0.1f, 64f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glRotatef(pitch, 1.0f, 0.0f, 0.0f);
        glRotatef(yaw, 0.0f, 1.0f, 0.0f);
        glTranslatef(-position.x, -position.y, -position.z);
    }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
private void initGL() {
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_CULL_FACE);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_FOG);

        // Setup fog
       FloatBuffer fogColor = BufferUtils.createFloatBuffer(4);
        fogColor.put(0f).put(0f).put(0f).put(1f).flip();
        glFogi(GL_FOG_MODE, GL_LINEAR);
        glFog(GL_FOG_COLOR, fogColor);
        glHint(GL_FOG_HINT, GL_DONT_CARE);
        glFogf(GL_FOG_START, 16f);
        glFogf(GL_FOG_END, 32f);

        glClearColor(0f, 0f, 0f, 1f);
    }


1  
2  
3  
4  
5  
6  
public void render() {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        camera.updateCamera();
        HallwayManager.getInstance().renderHallway();
    }
22  Games Center / Cube World Projects / Re: LWJGL BlockWorld on: 2013-04-03 19:48:43
I do. Grin Learning stuff is the priority for me, but I have a vague image of a voxel-based game in my mind.
23  Games Center / Cube World Projects / Re: [Optimization] View Frustum Culling on: 2013-04-01 18:20:56
You need to check every time the camera is moved whether or not a chunk is in the frustum. If it is, you send the chunk to renderer and render it until it is not in the frustum anymore. Only rebuild chunks when a block is removed or it enters the view frustum. If it leaves the screen, save it to disk or delete it or whatever you want to do. But it's a bad idea to rebuild it every frame. Only rebuild it when you absolutely have to. Otherwise, just have a render method that is constantly running for the chunk.
Also, this:
1  
2  
3  
positionBuffer.put(new float[]{x, y, z + 1f, x + 1f, y, z + 1f, x + 1f, y + 1f, z + 1f, x, y + 1f, z + 1f});
            colorBuffer.put(new float[]{1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0});
            vertexCount += 4;

Should not work. You are creating 3 * 4 vertices per face, not just 4. 3 is the size, 4 is the amount of vertices per face. I don't know how you're render function is actually working without that.

It is correct. I am having 4 verices per face, 3 * 4 float numbers per face.
That int is used in
1  
glDrawArrays(GL_QUADS, 0, chunk.vertexCount);


Also, thank you very much for help, that works perfectly for what i am doing. Cheesy
24  Games Center / Cube World Projects / Re: [Optimization] View Frustum Culling on: 2013-04-01 13:25:12
But how i use frustum culling then? I f i don't update the chunks when I move the camera, then the blocks won't show.
I found something on LWJGL Wiki, but it is under GL3.1, but maybe it will work in GL2.1.

http://www.lwjgl.org/wiki/index.php?title=The_Quad_updating_a_VBO_with_BufferSubData
25  Games Center / Cube World Projects / Re: [Optimization] View Frustum Culling on: 2013-04-01 07:58:11
So how can you update the "view" of the chunk if you break a block?
26  Game Development / Newbie & Debugging Questions / Re: Slick2D BasicGame or StateBasedGame ? on: 2013-03-31 18:28:55
StateBasedGame is generally making you easier to code "states" of the game: Main Menu, Options Menu, the game itself, GameOver screen, WinScreen and so on.
IMO the "zones" should be hard coded by you in the game itself.
27  Games Center / Cube World Projects / Re: [Optimization] View Frustum Culling on: 2013-03-31 15:54:23
Now i've made this work i'm struggling to potimize it.

How i use the frustum culling:
1  
2  
3  
4  
if (cameraHasMoved) {
    updateFrustum();
    recalculateVBOOfEveryChunk();
}


I already implemented the octree (one octree per chunk).
The problems are:
- the fps drops from 50-60fps to 5-15fps when i am moving the camera
- memory usage >800mb when moving the camera

Tell me what part of code you need and i will post it.
28  Games Center / Cube World Projects / Re: [Solved] View Frustum Culling on: 2013-03-30 21:17:19
Make sure you call calculateFrustum everytime your camera moves. I'm pretty sure this is the problem you have.
29  Games Center / Cube World Projects / Re: [Solved] View Frustum Culling on: 2013-03-30 08:35:08
Here it is. I can't really tell who's the owner, because i found this on google without any description.

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  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
import org.lwjgl.BufferUtils;

import java.nio.*;

import static org.lwjgl.opengl.GL11.*;

public class Frustum
{
    public static final int RIGHT   = 0;
    public static final int LEFT    = 1;
    public static final int BOTTOM  = 2;
    public static final int TOP     = 3;
    public static final int BACK    = 4;
    public static final int FRONT   = 5;

    public static final int A = 0;
    public static final int B = 1;
    public static final int C = 2;
    public static final int D = 3;

    float[][] frustum = new float[6][4];

    FloatBuffer modelBuffer;
    FloatBuffer projectionBuffer;

    public Frustum() {
        modelBuffer = BufferUtils.createFloatBuffer(16);
        projectionBuffer = BufferUtils.createFloatBuffer(16);
    }

    public void normalizePlane(float[][] frustum, int side) {
        float magnitude = (float) Math.sqrt(frustum[side][A] * frustum[side][A] + frustum[side][B] * frustum[side][B] + frustum[side][C] * frustum[side][C]);

        frustum[side][A] /= magnitude;
        frustum[side][B] /= magnitude;
        frustum[side][C] /= magnitude;
        frustum[side][D] /= magnitude;
    }

    public void calculateFrustum() {
        float[] projectionMatrix = new float[16];
        float[] modelMatrix = new float[16];
        float[] clipMatrix = new float[16];

        projectionBuffer.rewind();
        glGetFloat(GL_PROJECTION_MATRIX, projectionBuffer);
        projectionBuffer.rewind();
        projectionBuffer.get(projectionMatrix);

        modelBuffer.rewind();
        glGetFloat(GL_MODELVIEW_MATRIX, modelBuffer);
        modelBuffer.rewind();
        modelBuffer.get(modelMatrix);

        clipMatrix[ 0] = modelMatrix[ 0] * projectionMatrix[ 0] + modelMatrix[ 1] * projectionMatrix[ 4] + modelMatrix[ 2] * projectionMatrix[ 8] + modelMatrix[ 3] * projectionMatrix[12];
        clipMatrix[ 1] = modelMatrix[ 0] * projectionMatrix[ 1] + modelMatrix[ 1] * projectionMatrix[ 5] + modelMatrix[ 2] * projectionMatrix[ 9] + modelMatrix[ 3] * projectionMatrix[13];
        clipMatrix[ 2] = modelMatrix[ 0] * projectionMatrix[ 2] + modelMatrix[ 1] * projectionMatrix[ 6] + modelMatrix[ 2] * projectionMatrix[10] + modelMatrix[ 3] * projectionMatrix[14];
        clipMatrix[ 3] = modelMatrix[ 0] * projectionMatrix[ 3] + modelMatrix[ 1] * projectionMatrix[ 7] + modelMatrix[ 2] * projectionMatrix[11] + modelMatrix[ 3] * projectionMatrix[15];

        clipMatrix[ 4] = modelMatrix[ 4] * projectionMatrix[ 0] + modelMatrix[ 5] * projectionMatrix[ 4] + modelMatrix[ 6] * projectionMatrix[ 8] + modelMatrix[ 7] * projectionMatrix[12];
        clipMatrix[ 5] = modelMatrix[ 4] * projectionMatrix[ 1] + modelMatrix[ 5] * projectionMatrix[ 5] + modelMatrix[ 6] * projectionMatrix[ 9] + modelMatrix[ 7] * projectionMatrix[13];
        clipMatrix[ 6] = modelMatrix[ 4] * projectionMatrix[ 2] + modelMatrix[ 5] * projectionMatrix[ 6] + modelMatrix[ 6] * projectionMatrix[10] + modelMatrix[ 7] * projectionMatrix[14];
        clipMatrix[ 7] = modelMatrix[ 4] * projectionMatrix[ 3] + modelMatrix[ 5] * projectionMatrix[ 7] + modelMatrix[ 6] * projectionMatrix[11] + modelMatrix[ 7] * projectionMatrix[15];

        clipMatrix[ 8] = modelMatrix[ 8] * projectionMatrix[ 0] + modelMatrix[ 9] * projectionMatrix[ 4] + modelMatrix[10] * projectionMatrix[ 8] + modelMatrix[11] * projectionMatrix[12];
        clipMatrix[ 9] = modelMatrix[ 8] * projectionMatrix[ 1] + modelMatrix[ 9] * projectionMatrix[ 5] + modelMatrix[10] * projectionMatrix[ 9] + modelMatrix[11] * projectionMatrix[13];
        clipMatrix[10] = modelMatrix[ 8] * projectionMatrix[ 2] + modelMatrix[ 9] * projectionMatrix[ 6] + modelMatrix[10] * projectionMatrix[10] + modelMatrix[11] * projectionMatrix[14];
        clipMatrix[11] = modelMatrix[ 8] * projectionMatrix[ 3] + modelMatrix[ 9] * projectionMatrix[ 7] + modelMatrix[10] * projectionMatrix[11] + modelMatrix[11] * projectionMatrix[15];

        clipMatrix[12] = modelMatrix[12] * projectionMatrix[ 0] + modelMatrix[13] * projectionMatrix[ 4] + modelMatrix[14] * projectionMatrix[ 8] + modelMatrix[15] * projectionMatrix[12];
        clipMatrix[13] = modelMatrix[12] * projectionMatrix[ 1] + modelMatrix[13] * projectionMatrix[ 5] + modelMatrix[14] * projectionMatrix[ 9] + modelMatrix[15] * projectionMatrix[13];
        clipMatrix[14] = modelMatrix[12] * projectionMatrix[ 2] + modelMatrix[13] * projectionMatrix[ 6] + modelMatrix[14] * projectionMatrix[10] + modelMatrix[15] * projectionMatrix[14];
        clipMatrix[15] = modelMatrix[12] * projectionMatrix[ 3] + modelMatrix[13] * projectionMatrix[ 7] + modelMatrix[14] * projectionMatrix[11] + modelMatrix[15] * projectionMatrix[15];

        // This will extract the LEFT side of the frustum
       frustum[LEFT][A] = clipMatrix[ 3] + clipMatrix[ 0];
        frustum[LEFT][B] = clipMatrix[ 7] + clipMatrix[ 4];
        frustum[LEFT][C] = clipMatrix[11] + clipMatrix[ 8];
        frustum[LEFT][D] = clipMatrix[15] + clipMatrix[12];
        normalizePlane(frustum, LEFT);

        // This will extract the RIGHT side of the frustum
       frustum[RIGHT][A] = clipMatrix[ 3] - clipMatrix[ 0];
        frustum[RIGHT][B] = clipMatrix[ 7] - clipMatrix[ 4];
        frustum[RIGHT][C] = clipMatrix[11] - clipMatrix[ 8];
        frustum[RIGHT][D] = clipMatrix[15] - clipMatrix[12];
        normalizePlane(frustum, RIGHT);

        // This will extract the BOTTOM side of the frustum
       frustum[BOTTOM][A] = clipMatrix[ 3] + clipMatrix[ 1];
        frustum[BOTTOM][B] = clipMatrix[ 7] + clipMatrix[ 5];
        frustum[BOTTOM][C] = clipMatrix[11] + clipMatrix[ 9];
        frustum[BOTTOM][D] = clipMatrix[15] + clipMatrix[13];
        normalizePlane(frustum, BOTTOM);

        // This will extract the TOP side of the frustum
       frustum[TOP][A] = clipMatrix[ 3] - clipMatrix[ 1];
        frustum[TOP][B] = clipMatrix[ 7] - clipMatrix[ 5];
        frustum[TOP][C] = clipMatrix[11] - clipMatrix[ 9];
        frustum[TOP][D] = clipMatrix[15] - clipMatrix[13];
        normalizePlane(frustum, TOP);

        // This will extract the FRONT side of the frustum
       frustum[FRONT][A] = clipMatrix[ 3] + clipMatrix[ 2];
        frustum[FRONT][B] = clipMatrix[ 7] + clipMatrix[ 6];
        frustum[FRONT][C] = clipMatrix[11] + clipMatrix[10];
        frustum[FRONT][D] = clipMatrix[15] + clipMatrix[14];
        normalizePlane(frustum, FRONT);

        // This will extract the BACK side of the frustum
       frustum[BACK][A] = clipMatrix[ 3] - clipMatrix[ 2];
        frustum[BACK][B] = clipMatrix[ 7] - clipMatrix[ 6];
        frustum[BACK][C] = clipMatrix[11] - clipMatrix[10];
        frustum[BACK][D] = clipMatrix[15] - clipMatrix[14];
        normalizePlane(frustum, BACK);
    }

    public boolean cubeInFrustum(float x, float y, float z, float size) {
        for(int i = 0; i < 6; i++ ) {
            if(frustum[i][A] * (x - size) + frustum[i][B] * (y - size) + frustum[i][C] * (z - size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x + size) + frustum[i][B] * (y - size) + frustum[i][C] * (z - size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x - size) + frustum[i][B] * (y + size) + frustum[i][C] * (z - size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x + size) + frustum[i][B] * (y + size) + frustum[i][C] * (z - size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x - size) + frustum[i][B] * (y - size) + frustum[i][C] * (z + size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x + size) + frustum[i][B] * (y - size) + frustum[i][C] * (z + size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x - size) + frustum[i][B] * (y + size) + frustum[i][C] * (z + size) + frustum[i][D] > 0)
                continue;
            if(frustum[i][A] * (x + size) + frustum[i][B] * (y + size) + frustum[i][C] * (z + size) + frustum[i][D] > 0)
                continue;

            return false;
        }

        return true;
    }
}
30  Games Center / Cube World Projects / Re: View Frustum Culling on: 2013-03-30 00:28:17
Allright. Finally i found some source code of a Frustum class and i use that.
If anyone is interested in that, tell me and i will post it.

Next up: implementing quad / octal trees. Cheesy
Pages: [1] 2 3 ... 5
 

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 (54 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

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
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!