Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (289)
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: {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)
2  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
3  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.
4  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
5  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.
6  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!
7  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();
    }
8  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.
9  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
10  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
11  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?
12  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.
13  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.
14  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.
15  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;
    }
}
16  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
17  Games Center / Cube World Projects / Re: View Frustum Culling on: 2013-03-29 19:00:11
I already checked that tutorial, trust me, i did all the research possible on this subject. Is the normalization of planes a must?
18  Games Center / Cube World Projects / Re: View Frustum Culling on: 2013-03-29 18:12:39
I understand what you say. I will optimize the algorithm after i will manage this to work. First i want to make this work, because i understand how it works, but there is a problem with it. Am i using the right matrix? How can i calculate the W component of the points vector? What am i doing wrong in my code?
The second thig is that i'm 10th grade (in Romania), this is 2nd grade of high school and I didn't learned matrix and planes at mathematics.
I am very towards to learning stuff in advance, just tell me what i should do.
19  Games Center / Cube World Projects / [Solved] View Frustum Culling on: 2013-03-29 09:56:58
I give up! Hello everyone!

I am struggling to get the frustum culling working for the last day, but i can't find what's wrong with what i do.
Here is my code for updating the frustum (called eveytime camera is moved) and checking if a point (a box) is in frustum.

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  
public void update() {
        FloatBuffer modelMatrixBuffer = BufferUtils.createFloatBuffer(16);
        glGetFloat(GL_MODELVIEW_MATRIX, modelMatrixBuffer);
        modelMatrixBuffer.rewind();

        Matrix4f modelMatrix = new Matrix4f();
        modelMatrix.load(modelMatrixBuffer);

        planes[0] = new Plane(modelMatrix.m30 + modelMatrix.m00, modelMatrix.m31 + modelMatrix.m01, modelMatrix.m32 + modelMatrix.m02, modelMatrix.m33 + modelMatrix.m03);
        planes[1] = new Plane(modelMatrix.m30 - modelMatrix.m00, modelMatrix.m31 - modelMatrix.m01, modelMatrix.m32 - modelMatrix.m02, modelMatrix.m33 - modelMatrix.m03);
        planes[2] = new Plane(modelMatrix.m30 + modelMatrix.m10, modelMatrix.m31 + modelMatrix.m11, modelMatrix.m32 + modelMatrix.m12, modelMatrix.m33 + modelMatrix.m13);
        planes[3] = new Plane(modelMatrix.m30 - modelMatrix.m10, modelMatrix.m31 - modelMatrix.m11, modelMatrix.m32 - modelMatrix.m12, modelMatrix.m33 - modelMatrix.m13);
        planes[4] = new Plane(modelMatrix.m30 + modelMatrix.m20, modelMatrix.m31 + modelMatrix.m21, modelMatrix.m32 + modelMatrix.m22, modelMatrix.m33 + modelMatrix.m23);
        planes[5] = new Plane(modelMatrix.m30 - modelMatrix.m20, modelMatrix.m31 - modelMatrix.m21, modelMatrix.m32 - modelMatrix.m22, modelMatrix.m33 - modelMatrix.m23);
    }

    public static boolean inFrustum(int x, int y, int z) {
        Frustum camFrustum = Camera.getInstance().fow;

        Vector4f vCube[] = new Vector4f[] {
            new Vector4f(x, y, z, 1f),
            new Vector4f(x + 1, y + 1, z + 1, 1f)
        };

        for(int v = 0; v < 2; v++) {
            for(int i = 0; i < 6; i++)
                if(distanceToPlane(vCube[v], camFrustum.planes[i]) < 0)
                    return false;
        }

        return true;
    }

    public static float distanceToPlane(Vector4f vertex, Plane plane) {
        return plane.a * vertex.x + plane.b * vertex.y + plane.c * vertex.z + plane.d;
    }


The Plane class is containing only the a, b, c and d from the plane's equation.

For the moment i just want to see it working and then i will try to optimize it.
Can anyone please help me?
20  Games Center / Cube World Projects / Re: The Architect (Voxel Engine) on: 2013-03-28 23:44:22
I didn't do frustum culling. Undecided

Oh, ok...
21  Games Center / Cube World Projects / Re: The Architect (Voxel Engine) on: 2013-03-28 23:28:07
Can you please tell me how you did the frustum culling?
I am trying to do it for last 4 hours, but i can't make it work how it should.

Here is how i did the frustum faces loading:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public void update() {
        FloatBuffer projectionBuffer = BufferUtils.createFloatBuffer(16);
        glGetFloat(GL_PROJECTION_MATRIX, projectionBuffer);
        FloatBuffer modelBuffer = BufferUtils.createFloatBuffer(16);
        glGetFloat(GL_MODELVIEW_MATRIX, modelBuffer);

        Matrix4f projectionMatrix = new Matrix4f();
        projectionMatrix.load(projectionBuffer);
        Matrix4f modelMatrix = new Matrix4f();
        modelMatrix.load(modelBuffer);
       
        Matrix4f viewMatrix = new Matrix4f();
        Matrix4f.mul(projectionMatrix, modelMatrix, viewMatrix);

        planes[0] = new Plane(viewMatrix.m30 + viewMatrix.m00, viewMatrix.m31 + viewMatrix.m01, viewMatrix.m32 + viewMatrix.m02, viewMatrix.m33 + viewMatrix.m03);
        planes[1] = new Plane(viewMatrix.m30 - viewMatrix.m00, viewMatrix.m31 - viewMatrix.m01, viewMatrix.m32 - viewMatrix.m02, viewMatrix.m33 - viewMatrix.m03);
        planes[2] = new Plane(viewMatrix.m30 + viewMatrix.m10, viewMatrix.m31 + viewMatrix.m11, viewMatrix.m32 + viewMatrix.m12, viewMatrix.m33 + viewMatrix.m13);
        planes[3] = new Plane(viewMatrix.m30 - viewMatrix.m10, viewMatrix.m31 - viewMatrix.m11, viewMatrix.m32 - viewMatrix.m12, viewMatrix.m33 - viewMatrix.m13);
        planes[4] = new Plane(viewMatrix.m30 + viewMatrix.m20, viewMatrix.m31 + viewMatrix.m21, viewMatrix.m32 + viewMatrix.m22, viewMatrix.m33 + viewMatrix.m23);
        planes[5] = new Plane(viewMatrix.m30 - viewMatrix.m20, viewMatrix.m31 - viewMatrix.m21, viewMatrix.m32 - viewMatrix.m22, viewMatrix.m33 - viewMatrix.m23);
    }
22  Games Center / Cube World Projects / Re: Weird results when using ArrayList + VBO on: 2013-03-27 10:15:20
Thank you! This was so helpfull.
I did everything you said and now the memory usage don't pass 100m.
Thanks again!
23  Games Center / Cube World Projects / [Solved] Weird results when using ArrayList + VBO on: 2013-03-26 21:57:47
So I am learning 3D programming for 3 days now. I managed how to use VBOs, culling and other things.
I store level data in chunks (16 x 16 x 16). I am generating a VBO for every chunk (not for every tile), i get rid of "unseen" faces of cubes.

If I simulate (using 25 chunks) the updating (recalculation of VBO) of all the chunks every 2 seconds, the application's emory use gets >500m in lass than 10 seconds.

I think that the bottleneck is my float[] declaration (the data passed to the FloatBuffer); i am declaring it as 16^3 * 6 (faces) * 4 (vertex per face) * 3 (x, y, z).
As solution, i found using an ArrayList<Float> (so i can have dynamic size) significantly reduces the memory use, but i get very wierd results, apart from OpenGL errors that are making my app to start only sometimes :


NORMAL (HOW IT SHOULD BE)


WEIRD

Here are my Chunk classes (first is the one with float[], and second is the one with ArrayList):

http://pastebin.java-gaming.org/d2fb87c055b
http://pastebin.java-gaming.org/2fb8c850b58


LE: Also, another issue i have is that when the (0, 0, 0) point is in screen (view), my framerate drops to 15-20 FPS, it doesn't matter if i have or not any block at (0, 0, 0).
24  Games Center / WIP games, tools & toy projects / Re: Ruins of Revenge on: 2013-03-02 19:36:58
Just one question: Object's shadows (tree, rock) are generated or are they from the actual tileset?
25  Game Development / Newbie & Debugging Questions / Re: LibGDX tile rendering flicker. on: 2013-02-27 13:03:17
I fonud as a fix casting to int the camera's coordonates, but this is messing my camera code (i am calculating a vector to player's position for a smooth camera effect). Any fix for this? Cheesy

Here's my code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
private void updateCameraPosition() {
   float targetX, targetY;
   
   if(player.getPosition().x - camera.viewportWidth / 2 < 0) targetX = camera.viewportWidth / 2;
   else if(player.getPosition().x + camera.viewportWidth / 2 > world.getLevel().getWidth() * Tile.TILE_SIZE)
      targetX = world.getLevel().getWidth() * Tile.TILE_SIZE - camera.viewportWidth / 2;
   else targetX = player.getPosition().x;
   
   if(player.getPosition().y - camera.viewportHeight / 2 < 8) targetY = camera.viewportHeight / 2 + 8;
   else if(player.getPosition().y + camera.viewportHeight / 2 > world.getLevel().getHeight() * Tile.TILE_SIZE + 8)
      targetY = world.getLevel().getHeight() * Tile.TILE_SIZE - camera.viewportHeight / 2 + 8;
   else targetY = player.getPosition().y;
   
   float dx = targetX - camera.position.x, dy = targetY - camera.position.y, dist = (float) Math.hypot(dx, dy);
   Vector3 cameraVector = new Vector3((float) Math.cos(Math.atan2(dy, dx)), (float) Math.sin(Math.atan2(dy, dx)), 0);
   cameraVector.mul(Math.max(dist / 25f, .2f));
   
   camera.position.add(cameraVector);
   camera.update();
}
26  Game Development / Newbie & Debugging Questions / Re: LibGDX tile rendering flicker. on: 2013-02-27 11:41:15
I don't even think i am using bilinear filtering. Isn't default in libGDX to use GL_NEAREST when loading TextureAtlases ?
27  Game Development / Newbie & Debugging Questions / LibGDX tile rendering flicker. on: 2013-02-26 22:29:54
What's up everybody? Cheesy

Ok, so i am making a top-down 2(.5)D game. My "floor" tiles are stored in a WxH array (not tiles, but their id's). When I want to render them, I use two fors (y and x) get the texture for that tile id and render it at x * Tile.TILE_SIZE (int constant). To optimize the algorithm, i calculate a start and end x and y based on camera's position (a float transformed to a integer), and render only tiles that are on the screen.

Problem:
The problem is that when i move the camera (using a calculated delta -- huge decimal number) i get a visual bug: 1 pixel gap between random rows of tiles (only horizontal gap). My assumption is that the problem is caused by that float -> integer transformation.

Could anyone tell me how can i fix this problem? Also, how can i avoid this type of problems?
Thanks!

LE: Here's one picture of what is happening.

28  Game Development / Newbie & Debugging Questions / Re: Kind of shadow casting. on: 2013-02-24 23:32:46
I understand. Thank you very much for help!  Grin
29  Game Development / Newbie & Debugging Questions / Re: Kind of shadow casting. on: 2013-02-24 22:49:22
Oh, so my ideea of getting the sprite's image, distorting it (flip it vertically and skew (:-??) until it gets 45 degrees) and then making it only black + decreasing it's opacity (tehniques that i use in photoshop to do the shadow) isn't so good. Is it practical? Sad
30  Game Development / Newbie & Debugging Questions / Re: Kind of shadow casting. on: 2013-02-24 21:15:43
I think that if i make the shadows by code, it will be easier to me to avoid things like this:

(notice the shadow rendered under the wall and intensifying the wall's shadow)

Also, it would be easier than drawing and positioning the shadow for every entity i make.
Pages: [1] 2 3 ... 5
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (60 views)
2013-05-17 21:29:12

alaslipknot (69 views)
2013-05-16 21:24:48

gouessej (99 views)
2013-05-16 00:53:38

gouessej (98 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (167 views)
2013-05-12 17:10:36

kutucuk (166 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.901 seconds with 20 queries.