Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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 ... 25
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [engine] 3D model types, and overview on: 2014-10-09 17:43:11
Speaking from experience, don't use 5 or more objects to represent a single vertex. Don't represent verticies as as objects at all.
When you come to a point where you want to display a model which is a bit more complex then a Mine Craft Character you will thank me.

Use a ByteBuffer to store the model data and provide some data layout functionality or accessor methods like setVertexPosition(int vertexId, Vector3f pos). This has not only the benefit of saveing you a lot of memory, but is also needed by opengl.

2  Discussions / General Discussions / Re: String deduplication coming in Java8U20 in the G1 GC on: 2014-09-03 18:24:29
Interned strings are on heap since Java 7 and yes they are garbage collected
Reference?  I'm not seeing any change here: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/String.java

But my point is that interning strings is almost always a bad idea.

Quote
In a Java 8 minor update they add this daemon ...
FTW.  You have a reference?  Hopefully it can be disabled.


www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html
Quote
. Synopsis: In JDK 7, interned strings are no longer allocated in the permanent generation of the Java heap, but are instead allocated in the main part of the Java heap (known as the young and old generations), along with the other objects created by the application. This change will result in more data residing in the main Java heap, and less data in the permanent generation, and thus may require heap sizes to be adjusted. Most applications will see only relatively small differences in heap usage due to this change, but larger applications that load many classes or make heavy use of the String.intern() method will see more significant differences.
RFE: 6962931
3  Discussions / General Discussions / Re: String deduplication coming in Java8U20 in the G1 GC on: 2014-09-02 20:04:53
Interned strings are on heap since Java 7 and yes they are garbage collected
4  Discussions / Miscellaneous Topics / Re: A rant on OpenGL's future on: 2014-08-15 04:45:33
If they don't want to throw away years of work, this is the only possible move from them.
5  Discussions / General Discussions / Re: So... state of the art 3D "engines" in Java on: 2014-07-30 19:41:45
I really liked this blog post:

c0de517e.blogspot.nl/2014/04/how-to-make-rendering-engine.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+C0de517e+(c0de517e)

Quote
Today I was chatting on twitter about an engine and some smart guys posted a few links, that I want to record here for posterity. Or really to have a page I can point to every time someone uses a scene graph.
6  Games Center / WIP games, tools & toy projects / Re: CMEngine - a from scratch, modern GL 3d engine on: 2014-07-30 05:56:41
instead of doing three times the same split, you could only do one. Or to be even faster (the split operation is a regex match), you could just search for the occurrences of the slash char.

Your OBJ loader is at the moment very, very basic. So be aware that there are many pitfalls, which may trap you.
e.g. I had once the problem that I got OutOfMemory Exceptions for larger models (> 25mb). And the problem was that I created java objects for every little detail of the OBJ format.
7  Games Center / WIP games, tools & toy projects / Re: CMEngine - a from scratch, modern GL 3d engine on: 2014-07-29 21:52:22
your OBJ loader is ugly not quite perfect:
- storing the face indices as a float vertex3
- doing unnecessary string manipulations (e.g. split)

and not much more to look at

8  Discussions / General Discussions / Re: Netbeans + Gradle = Im annoyed. on: 2014-07-26 22:30:28
What do you exspect when you have two projects with the same name?
Load your multi-project projects into seperate project groups, maybe?
9  Game Development / Newbie & Debugging Questions / Re: [Solved] Calculating normal vectors on: 2014-07-13 13:15:35
a good way to calculate the normal from a height map, is to use the sobel filter on the height data.
10  Discussions / General Discussions / Re: Android Billing API Restricts China on: 2014-06-23 20:06:58
Also, noone uses the play store over there.
11  Game Development / Newbie & Debugging Questions / Re: Reduce the polys in a voxel engine? on: 2014-06-14 10:21:39
take a look: http://0fps.net/2012/06/30/meshing-in-a-minecraft-game/
12  Games Center / WIP games, tools & toy projects / Re: MERCury - 2d Game Library on: 2014-06-13 06:52:59
If you are using maven, which is a great choice. You shoul get rid of any project folders from any IDE, configurate everything in maven.
If you need help with a proper .gitignore file, go to: gitignore.io
13  Games Center / WIP games, tools & toy projects / Re: MERCury - 2d Game Library on: 2014-06-12 20:45:24
how about:

1  
2  
3  
4  
5  
6  
int v = 0;
while( v < vertices.length)
{
    Vec2 l1v1 = vertices[v], l1v2 = vertices[++v % vertices.length];
    //...
}
14  Discussions / Miscellaneous Topics / Re: Code-style: Cringe pics on: 2014-06-04 18:47:29
I give you some code I had to deal with lately (legacy Java 1.3 or 4 code):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public Double addTwoDouble(Double a, Double b)
{
  if(a != null)
    if(b != null)
      return new Double(a.doubleValue() + b.doubleValue());
    else
      return new Double(0.0);
  else
    return null;
//and the other way around
}


yes I know why they did it, but it is so cringe worthy not the less.
15  Discussions / Miscellaneous Topics / Re: Random syntax tweaks! on: 2014-06-01 14:10:13
This ?? operator just tries to hide a problem instead of fixing it. Getting rid of null and using something like a Option type is way better in my opinion.
16  Game Development / Game Mechanics / Re: Calculating Tangent from Normal on: 2014-05-30 13:03:35
Yes you can do all the work in the shader, but as you can see this requires a lot of math and will slow down the shader considerably.
You will have to decide for yourself which way is easier for you to support and use.
17  Game Development / Game Mechanics / Re: Calculating Tangent from Normal on: 2014-05-30 12:02:03
you only calculate one tangent per triangle, but you have to calculate it for each vertex of every triangle.

lets say that my code is a function which takes three vertices or indices into your vertex array. you would have to call it three times for each trinalge.

1  
2  
3  
4  
5  
6  
Vector3f calcTangent(int v1, int v2, int v3);
for(int i = 0; i < getVerts().length; i += 3) {
getVerts()[i].setTXYZ(calcTangent(i, i + 1, i +2);
getVerts()[i+1].setTXYZ(calcTangent(i+1, i + 2, i);
getVerts()[i+2].setTXYZ(calcTangent(i+2, i, i +1);
}
18  Game Development / Game Mechanics / Re: Calculating Tangent from Normal on: 2014-05-25 16:01:27
As roquen pointed out, you have to use the gradient of the texture coordinates to identify the direction of the tangent. You need to do this if you want your normal maps to work.

I dug out some code I used to do this task:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
//the three position vectors creating a triangle
        Vector3 pos1,  pos2, pos3;
//the three texture coordinate vectors of the same three vertices
        Vector2 uv1,  uv2, uv3;
//the normal of the vector we want to calculate the tangent for (pos1, uv1 int this case)
        Vector3 n;

        Vector3 v2v1 = pos2.sub(pos1);
        Vector3 v3v1 = pos3.sub(pos1);

        float c2c1b = uv2.getY() - uv1.getY();
        float c3c1b = uv3.getY() - uv1.getY();

        Vector3 t = v2v1.mult(c3c1b).sub(v3v1.mult(c2c1b));

        Vector3 b = n.cross(t);

//the final tangent
        Vector3 smoothTangent = b.cross(n).normalize();      
19  Game Development / Newbie & Debugging Questions / Re: Uniform locations return -1 on: 2014-05-24 22:35:02
also, you have to bind the texture unit not the texture id.
GL_Texture0 == 0
GL_Texture1 == 1
...
20  Game Development / Newbie & Debugging Questions / Re: Does anyone create custom annotations in their game code? on: 2014-05-21 19:50:36
Sadly I can't find another example not involving Riven at the moment persecutioncomplex

Sad don't forget my awesome resource injection lib (topic).
I used annotations to collect all used resources at compile time and be able to optimize them (declare single images in code, but the compiler will add them together into texture atlases)
21  Discussions / General Discussions / Re: FastTuple - fast primitive tuples via bytecode generation on: 2014-05-20 17:59:15
Wouldn't it be enough if the identity is only accessible at the native interop layer? They could add stuff to JNI (or the new interface they are planing?) and nobody would care in Java land.
22  Java Game APIs & Engines / OpenGL Development / Re: Problems with Modern OpenGL lighting on: 2014-05-14 21:47:35
They way most people did it was to have an uniform array with data for multiple lights. Such an array will have a constant size, which may be choosen either by performance or memory concerns.

If you have more lights in your scene then you can render at once, you can do two things. Either choose only the most important light sources for each object, or render each object in multiple passes.

Lets say you can only render 5 lights at the same time, but have many 13 lights in total:
1. somehow order the lights for each object(e.g. 1/distance² * intensity) and only select the top 5.
2. render all lights in 3 passes which are blended together. Only apply the ambient term once.
23  Java Game APIs & Engines / OpenGL Development / Re: Problems with Modern OpenGL lighting on: 2014-05-14 06:21:07
The light direction is constant in view space and not in world-space, because your lighting calculation happens in view space. Declare it as a uniform and transform it each frame into view-space on the CPU.

1  
2  
3  
4  
5  
6  
7  
Vec3 lightDir = ...;
Matrix4 view = ...;

Vec3 vsLightDir = view.mult(lightDir);
shader.updateLightDir(vsLightDir);

renderScene();
24  Java Game APIs & Engines / OpenGL Development / Re: Problems with Modern OpenGL lighting on: 2014-05-13 06:32:13
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  
#version 120

varying vec4 color;
varying vec3 vertex;
varying vec3 normal;

uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 normalMatrix;

void main() {
    color = gl_Color;
    vertex = vec3(viewMatrix * modelMatrix * gl_Vertex);
-    normal = vec3(normalize(normalMatrix * gl_Vertex));
+    normal = vec3(viewMatrix * normalMatrix * normal);
    gl_Position = projectionMatrix * viewMatrix * modelMatrix * gl_Vertex;
}

Fragment Shader:
#version 120

varying vec4 color;
varying vec3 vertex;
varying vec3 normal;

vec3 lightSource = vec3(0, 10, 0);
vec4 ambientTerm = vec4(0.1, 0.1, 0.1, 1);
vec4 diffuse = vec4(0.5, 0.5, 0.5, 1);
vec4 specular = vec4(0.1, 0.1, 0.1, 1);
float shininess = 0.1;

void main() {
+   vec3 N = normalize(normal);
   vec3 light =  normalize(lightSource - vertex);
   vec3 eyeCoords = normalize(-vertex);
-   vec3 reflection = normalize(-reflect(light, normal));
+   vec3 reflection = reflect(light, N);
   
   vec4 diffuseTerm = diffuse * max(dot(N, light), 0.0);
-   diffuseTerm = clamp(diffuseTerm, 0.0, 1.0);
   
   vec4 specularTerm = specular * pow(max(dot(reflection, eyeCoords),0.0), 0.3 * shininess);
   specularTerm = clamp(specularTerm, 0.0, 1.0);
   
-    gl_FragColor = color + ambientTerm + diffuseTerm+ specularTerm;
+    gl_FragColor = color * (ambientTerm + diffuseTerm) + specularTerm;
}
25  Java Game APIs & Engines / OpenGL Development / Re: Problems with Modern OpenGL lighting on: 2014-05-12 18:44:30
there shouldn't be any matrices in the fragment shader. Calculate the position, normal and lightdir in the vertex shader. You only need to normalize the normal in the fragment shader.

your fragment shader should look something like this(from my code base):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
    vec3 N = normalize(normal);

    vec3 color, dcolor;
    color = vec3(0.);
    dcolor = diffuse;

    float NdotL = dot(N, light_pos);

    if(NdotL > 0.0){
        float HdotN = dot(N, halfvector);
        vec3 scolor = specular;
        #ifdef SPECULAR_MAPPING
            scolor *= texture(specular_sampler, texcoord).rgb;
        #endif
        color += scolor * pow(max(HdotN, 0.), mat_spec_exp);
        color += dcolor * NdotL;
    }
    color += ambient * dcolor;


where "halfvector" is the vector with half the angle between the eye and the light vector. Calculating the lighting in eye-space instead of world-space(what you tried to do), makes it much easier to calculate this halfvector. Just place this in the vertex shader:
1  
2  
  vec3 normal = view_matrix * normal_matrix * in_normal;
  vec3 halfvector = normalize(normal + vec3(0,0,1))
26  Games Center / WIP games, tools & toy projects / Re: MERCury - 2d Game Library on: 2014-05-05 13:22:14
nobody wants to download a doc to be able to read it, please upload it to some website or add it as a github wiki.
27  Game Development / Newbie & Debugging Questions / Re: A* Pathfinding, multiple paths with equal lengths. on: 2014-05-02 17:23:05
Have a read of the very good introduction to A* of the Stanford University.

The problem of how to break ties is discussed on the second page.
28  Game Development / Newbie & Debugging Questions / Re: Editing a text-file stored inside a JAR on: 2014-04-30 21:39:10
With Java 7, which added Filesystem implementations in nio2, there is a something called ZipFileSystem.

You can open a zip file as a Filesystem and then do normal File operations as you do all the time, which operate directly on the Jar.
An URL to your running Jar can be retrieved by the getURLs method of the classloader.
29  Game Development / Performance Tuning / Re: Parallel insertion sort for almost sorted data sets on: 2014-04-29 20:27:19
where is the code? Wink
30  Game Development / Newbie & Debugging Questions / Re: Reading files within an Executeable JAR file on: 2014-04-28 16:40:08
reading text files can be done a lot easier:
1  
2  
3  
4  
5  
6  
7  
8  
Inputstream in = ...;
try(BufferedReader br = new BufferedReader(new InputstreamReader(in)))
{
   List<String> lines = new Arraylist<String>();
   String line;
   while((line = br.readLine()) != null)
      lines.add(line);
}
Pages: [1] 2 3 ... 25
 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (137 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!