Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (803)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2020-02-16 18:30:30 
Started by Feuerrohr - Last post by Guerra2442
Ok thx

Do you have Discord and I can ask you questions if i had one?


Yeah Guerra24#9300, as long I'm online you can ask me anything.

 2 
 on: 2020-02-16 17:36:36 
Started by Feuerrohr - Last post by Feuerrohr
Ok thx

Do you have Discord and I can ask you questions if i had one?

// Rendering
I code a ShapeRenderer like LibGDX and i store all vertices in a array.
Now i dont use a buffer and put the complete array directly with glBufferData.

It increase the fps a bit from 1600 to 1700/1800 (10K quads)

 3 
 on: 2020-02-16 16:35:45 
Started by Mr. Gol - Last post by Mr. Gol
I used to frequently visit this forum around 2006 - 2008. At the time I was a student, and trying to make a game as a part of getting into programming. I'm happy to see this place is still alive, and looking from the posts there are still many people with the same kind of inspiration that I had when I joined.

For some indescribable reason I recently got the urge to make a game again. Since I haven't done anything in this area for severa years, and I was originally trying to make a racing game, I thought I would retrace my steps by making a very simple 2D racing game.

So here's the first version:



You can play against the AI or against other players. Although the graphics are outdated and the car physics are dubious, it does support both keyboard and touch controls, both local and internet multiplayer, and lap records.

You can find the game here: http://lf1.clrz.nl

And yes, that's a web link. I did actually implement the game in Java, but I transpiled it to JavaScript using the excellent TeaVM. Compared to 12 years ago I assumed people are much less likely to download random executables off the internet, so this allows people to have a look without scary security implications.

Finally, some notes:
- Controls are the arrow keys on desktop, plus WASD keys if you're using local 2 player. If you're using a touch device you should get the touch buttons automatically.
- For some reason the web version flickers every now and then. That doesn't happen to the desktop version (though obviously that uses a different renderer), need to figure out what's causing it.
- You decelerate quite slowly. That was kind of on purpose, because racing games where you never have to break aren't that fun. But maybe I overdid it, and alternating between the accelerator and the brakes is a bit annoying when using the touch controls.

Hope someone enjoys this!

 4 
 on: 2020-02-16 16:32:17 
Started by Feuerrohr - Last post by Guerra2442
Ok thanks but why all examples use a buffer when its possible to use a float array directly?

That depends on what are you using to load meshes, usually they are already in *Buffer form and because the performance depends on the JVM if it supports critical natives but since this is a load method and is expected to not run as much you can justify the performance hit. But that's up to you.

And another questions is: How big should I make the buffer?
Because I test it and currently I use 1000 * (count of X, Y, Z, R, G, B, A, U, V) = 9000 [9000 * 4 Bytes -> Float -> 36000]

I test it with higher values but then the fps are 500 and with 1000 i have 1600 fps

You don't need to keep the buffer allocated during the execution, you can allocate the buffer in setVertices with size vertices.length, upload the data to OpenGL and then free it. (or pass the array directly)

This is also a bit of memory optimization because you can create a mesh with a single triangle but the buffer is way too large for it so you're wasting both ram and vram (in the example).

Performance-wise it depends on the driver and gpu, and how it treats buffer that are larger than the requested vertex count so it can vary quite a bit. You should keep them at the same size of the input data.

 5 
 on: 2020-02-16 14:30:49 
Started by BurntPizza - Last post by KaiHH
Wrote a little tutorial about the order in which matrix transformations can be viewed and what effect the different orders have: https://github.com/JOML-CI/JOML/wiki/Tutorial---Matrix-Transformation-Order
Program used for the graphs/illustrations: https://github.com/JOML-CI/joml-lwjgl3-demos/blob/master/src/org/joml/lwjgl/CoordinateSystemDemo.java

 6 
 on: 2020-02-16 12:38:36 
Started by Feuerrohr - Last post by Feuerrohr
And another questions is: How big should I make the buffer?
Because I test it and currently I use 1000 * (count of X, Y, Z, R, G, B, A, U, V) = 9000 [9000 * 4 Bytes -> Float -> 36000]

I test it with higher values but then the fps are 500 and with 1000 i have 1600 fps

 7 
 on: 2020-02-16 12:34:45 
Started by Feuerrohr - Last post by Feuerrohr
Ok thanks but why all examples use a buffer when its possible to use a float array directly?

 8 
 on: 2020-02-16 05:36:58 
Started by Coldstream24 - Last post by Coldstream24
Hey all,
I've been working on a 3d project involving Source Engine models and have gotten stuck with vertex skinning in GLSL.
I've tried a few approaches based on resources I've seen - examples from Khronos, Nvidia, even other projects with a similar aim, which don't seem to have problems, and yet here I am, and I can't get it to work.
It seems that for no real reason, most vertices have their position set to (0, 0, 0) when I try to render them despite nothing really appearing to be the cause - I've even tried passing identity matrices through to the shader and it still doesn't work right.
Currently the code I've landed on is 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  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
#version 330

const int MAX_JOINTS = 150;

attribute vec3 aPosition;
attribute vec3 aNormal;
attribute vec2 aTexCoord0;
attribute vec2 aTexCoord1;
attribute vec3 aTangent;
attribute vec3 aBoneWeights;
attribute ivec4 aBoneIDs;

uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
uniform vec3 viewPos;
uniform mat4 jointMatrices[MAX_JOINTS];

out VS_OUT{
    vec2 texCoord0;
    vec2 texCoord1;
    vec3 fragPos;
    vec3 viewPos;
    vec3 normal;
} vs_out;

mat4 getBoneMatrix(int boneID){    
    return jointMatrices[boneID];
}
mat4 accumulateSkinMatrix(){
    mat4 result;
    vec3 boneWeights = aBoneWeights;
    result = boneWeights.x * getBoneMatrix(int(aBoneIDs.x));
    result = result + boneWeights.y * getBoneMatrix(int(aBoneIDs.y));
    result = result + boneWeights.z * getBoneMatrix(int(aBoneIDs.z));
    return result;
}

void main(){
    vec4 newVertex = vec4(0.0);
    vec4 newNormal = vec4(0.0);
   
    mat4 skinMatrix = accumulateSkinMatrix();
    newVertex = skinMatrix * vec4(aPosition, 1.0);
    newNormal = skinMatrix * vec4(aNormal, 0.0);

    vs_out.fragPos = vec3(modelMatrix * newVertex);

    vs_out.texCoord0 = aTexCoord0;
    vs_out.texCoord1 = aTexCoord1;

    vs_out.normal = mat3(transpose(inverse(modelMatrix))) * newNormal.xyz;
    vs_out.viewPos = viewPos;

    gl_Position = projectionMatrix * viewMatrix * modelMatrix * newVertex;
}


I won't bother including the fragment shader as it's very simplistic and only really renders the texture at the given TexCoords, which aren't causing issues.

The result I get with passing data from the file itself is:


And when I set all vertex weights to be 1.0 (by changing boneWeights to be equal to vec3(1.0) instead of aBoneWeights, I get a mostly working but still obviously broken render:


Debugging in RenderDoc hasn't given me too much of a hint either. I know that I'm correctly calculating the bone positions as the lines beneath the model are being rendered after the model itself for debugging and are in the right place. It shows that I'm passing matrices correctly for the bones each time but for some inexplicable reason the vertex position is being set to 0.

I've made the most progress on it today after weeks of scratching my head and doing other things but I'd really like to get this right and move onto other things. Any insights would be greatly appreciated.

 9 
 on: 2020-02-15 23:16:06 
Started by MossyForest - Last post by MossyForest
Thanks KaiHH! didn't applied into my code yet, but it seems it will solve my problem.

 10 
 on: 2020-02-15 08:49:13 
Started by MossyForest - Last post by KaiHH
This is what shearing can be used for. You want to move the z coordinate of a rectangle with respect to its x or y coordinate while also keeping the x/y coordinates fixed. Here is a very basic LWJGL 3 example:
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  
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;
import org.lwjgl.opengl.GL;
public class OverlappingRectangles {
    private static void drawRectangle(float x, float y, float r) {
        glPushMatrix();
        glTranslatef(x, y, 0);
        glRotatef(r, 0, 0, 1);
        glScalef(0.75f, 0.2f, 1);
        // Create shear matrix that maps (x, y, z) to (x, y, x + z)
        glMultMatrixf(new float[] {
                1, 0, 1, 0,
                0, 1, 0, 0,
                0, 0, 1, 0,
                0, 0, 0, 1});
        glBegin(GL_QUADS);
        glVertex2f(-1, -1);
        glVertex2f(1, -1);
        glVertex2f(1, 1);
        glVertex2f(-1, 1);
        glEnd();
        glPopMatrix();
    }
    public static void main(String[] args) {
        if (!glfwInit())
            throw new RuntimeException("Unable to initialize GLFW");
        long window = glfwCreateWindow(500, 500, "Overlapping Rectangles", NULL, NULL);
        if (window == NULL)
            throw new RuntimeException("Failed to create the GLFW window");
        glfwSetKeyCallback(window, (w, k, s, a, m) -> {
            if (k == GLFW_KEY_ESCAPE && a == GLFW_RELEASE)
                glfwSetWindowShouldClose(window, true);
        });
        glfwMakeContextCurrent(window);
        GL.createCapabilities();
        glEnable(GL_DEPTH_TEST);
        while (!glfwWindowShouldClose(window)) {
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glColor3f(1, 0, 0);
            drawRectangle(0, 0.5f, 0);
            glColor3f(0, 1, 0);
            drawRectangle(0, -0.5f, 180);
            glColor3f(0, 0, 1);
            drawRectangle(-0.5f, 0, 90);
            glColor3f(1, 1, 0);
            drawRectangle(0.5f, 0, 270);
            glfwSwapBuffers(window);
            glfwPollEvents();
        }
    }
}


Pages: [1] 2 3 ... 10
 
Riven (388 views)
2019-09-04 15:33:17

hadezbladez (5272 views)
2018-11-16 13:46:03

hadezbladez (2196 views)
2018-11-16 13:41:33

hadezbladez (5536 views)
2018-11-16 13:35:35

hadezbladez (1149 views)
2018-11-16 13:32:03

EgonOlsen (4582 views)
2018-06-10 19:43:48

EgonOlsen (5461 views)
2018-06-10 19:43:44

EgonOlsen (3118 views)
2018-06-10 19:43:20

DesertCoockie (4014 views)
2018-05-13 18:23:11

nelsongames (4698 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!