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
1  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-12-02 09:33:09
Doing a total rewrite of a 'complete' collada importer! Grin
2  Game Development / Newbie & Debugging Questions / Re: Clean code & Smooth development on: 2014-10-16 12:56:58
Readability Cool! I try to keep method and class to a size that I can understand in one viewing. If I have to think too hard about it I break the task up into methods that can be understood. I agree that most of the time a class should do one thing, a balance needs to be attained, the code should work for you.

If a section of code is used more than once it often goes in a method Pointing. If there are a lot of helper methods in a class that are useful in general they get put in a new class for reuse, tested and documented.

Divide and conquer ftw! Grin
3  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-10-16 08:31:35
I made a simple class that extracts the native files from a jar, for the operating system and platform. I changed my asset loading practice so that I can load media from jar files instead of separate folders. So it is now much easier to package up my program and distribute. Also I added the ability to use JavaFX with my game engine.
4  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-10-14 08:11:13
@HeroesGraveDev Have you considered using fractal patterns as well? They can help produce more natural landscapes.
5  Discussions / General Discussions / Re: What is wrong with reinventing the wheel? on: 2014-10-08 11:29:45
If everyone just used the same wheel we would all still be using wagon wheels.  We would never have airplanes if everyone just carried on using the same old tec. Remember that crisis is the mother of invention. Even if you have a deadline sometimes that is when you produce something new and fantastic. Many inventors have been people who just having lost their job have a great idea and choose to go for it.
6  Game Development / Newbie & Debugging Questions / Re: Exporting Slick Game without JarSplice on: 2014-10-06 19:01:38
Native packaging in Netbeans using Inno 5 setup. Creates an exe installer which packages a java runtime as well. Works really well and easy to use. Also alternative native packaging for Linux and mac.
7  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-10-03 23:25:17
Now my collada loader supports multiple materials Grin (phong so far) in the same mesh.  My engine can render just the diffuse textures. Still ironing out the bugs Emo with the skinning some models animate fine while others are a bit odd Cranky.

I've found that if I get stuck one part, if I switch to another bit of the engine and work on that and then go back to the other part again I make more progress.

Making the loader for myself is a lot easier than trying to design a stand alone library that could be used in anyones project, so I might need some help with that if other people wanted to use it. I'm not planing on supporting every part of the specification as I don't need it, but may be others could complete it. Or just use it to make their own.
8  Discussions / General Discussions / [solved]Re-scaling images on: 2014-10-03 10:36:56
What is the best way in java to scale an image ?

Say you wanted to load an folder of images and for each one you want the image to be made square whatever the dimensions :
 eg rescale the width of 256 so it matches the height of 512. It needs to be interpolated (eg Cubic) and not just stretched. Preferably in console mode.

[edit]Nevermind found out how to do it. Roll Eyes
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-09-25 21:42:15
@princec Its still a bit fragile and not fully tested. Plus it doesn't support everything Collada offers,  I might release it when done. But for now my priority is to get my game engine done.
10  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-09-25 19:07:15
Woot yay! .. finally got my collada loader working properly with skinning Grin.
11  Game Development / Newbie & Debugging Questions / Re: Collada format interleaved index buffer? on: 2014-09-21 12:32:20
/facepalm given that the collada format isn't in the format of an interleaved array then no. you have to convert it as described.
12  Game Development / Newbie & Debugging Questions / Re: Collada format interleaved index buffer? on: 2014-09-21 10:46:45
Next step is in opengl to use the interleaved buffer.
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  
 int VERTEX_POS_SIZE = 3;
int VERTEX_NORMAL_SIZE = 3;
int FLOAT_SIZE_BYTES = 4;
stride = FLOAT_SIZE_BYTES * VERTEX_POS_SIZE +VERTEX_NORMAL_SIZE ; // length of the vertex 3 + 3


// create buffer
int vertBuffer= glGenBuffer();

glBindBuffer(GL_ARRAY_BUFFER, vertBuffer);
      glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);//vertices are what what made in the previous post.
      glBindBuffer(GL_ARRAY_BUFFER, 0);

in indexBuffer = glGenBuffer();
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer );
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices, GL_STATIC_DRAW);//indices where also made in the previous post.
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

//bind buffer
glBindBuffer(GL_ARRAY_BUFFER, vertBuffer);
 

glEnableVertexAttribArray(shader.getPositionHandle()); // however you get your handles your self
glEnableVertexAttribArray(shader.getNormalHandle()); // dito


int offset =0;

            glVertexAttribPointer(shader.getPositionHandle(),
                            VERTEX_POS_SIZE, GL_FLOAT, stride, 0);      
            offset += FLOAT_SIZE_BYTES *3;
     
            glVertexAttribPointer(shader.getNormalHandle(),
                            VERTEX_NORMAL_SIZE, GL_FLOAT, stride, offset);            
            offset += FLOAT_SIZE_BYTES*3;

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer );
//draw
glDrawElements(GL_TRIANGLES, vertices.length, GL_UNSIGNED_SHORT, 0);


// unbind
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(shader.getPositionHandle());
glDisableVertexAttribArray(shader.getNormalHandle());


My code presumes the verts and indexs are in the format your methods can take.. you might need to convert to FloatBuffer or IntBuffer first.

This code is not the latest as it works for GLES2 so I'm sure there is a proper way to do it for 4+
13  Game Development / Newbie & Debugging Questions / Re: Collada format interleaved index buffer? on: 2014-09-21 10:24:09
I take it you want to parse the <triangle> node of a collada file. <p> is the indexes 
1  
<p>2 0 0 0 1 0 3 1 2 1 1 1<p>


so I presume you have parsed the
1  
<input semantic="VERTEX" source="#your-mesh-vertices" offset="0"/>


and  also
1  
<input semantic="NORMAL" source="#your-mesh-normals" offset="1"/>


1  
int normal_offset =1;


so with that in mind you need a class to hold your triangle data I call mine Face but you can call it triangle if you like.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class Face 
{

// Indices for each vertex point, 3 points for each face.
      int v1, v2, v3, n1,n2, n3;

                public Face(int v1, int v2, int v3){
         this.v1 = v1;
         this.v2 = v2;
         this.v3 = v3;
   
      }
               
      public void setNormal(int n1,int n2, int n3)
                {
         this.n1 = n1;
         this.n2 = n2;
         this.n3 = n3;
      }
}
               


You need the stride of your array which is the number of inputs.. 2 in this case.

1  
int triStride =2;




So putting it together we can loop through p to save the array in a format that is easy to use.

1  
2  
3  
4  
5  
6  
7  
8  
9  
for (int i = 0; i < p.length;i+= 3*triStride)
        {
               Face face = new Face(p[i],p[i+triStride],p[i+triStride+triStride]);

               face.setNormal(p[i+normal_offset],
                                      p[i+normal_offset+triStride],
                                      p[i+normal_offset+triStride+triStride]);
               facesArrayList.addFace(face);
        }        


With the faces created you can now decide if you want to create an interleaved index buffer or just separated type. I use interleaved so I explain that one.

I use a class called Vertex to store the data in a per vertex way instead of per face, which is then used to create an interleaved buffer without repeated vertex data. I've striped out all the checks that I usually make for brevity, also usually the vertex class has UV color and bone data included.

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 class Vertex {
    private final float[] xyz = new float[3];
    private float[] norm;
    private int size;

   public void setVertex(Vec3 vec){
        xyz[0] = vec.x;
        xyz[1] = vec.y;
        xyz[2] = vec.z;
        size = 3;
    }
   
    public void setNormal(Vec3 vec){
        norm = new float[3];
        norm[0] = vec.x;
        norm[1] = vec.y;
        norm[2] = vec.z;
        size +=3;
    }

public float[] getVerts(){
    float[] verts = new float[size];              
    int i = 0;                
    System.arraycopy(xyz, 0, verts, i, 3);
    i += 3;
    System.arraycopy(norm, 0, verts, i, 3);
    i += 3;// for other data not included here....
    return verts;
}


Vertex also overrides the equals method and hashCode

The next step is to take the ArrayList of faces, ArrayList of verts and ArrayList of norms; ( which I presume you have already filled from the <mesh> nodes<source id="your-mesh-positions"> and <source id="your-mesh-normals"> respectively), and put them in to the a vertexs ArrayList, and also put indexs into an indexes ArrayList (demonstrated next).


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  
 for(Face each : faces)
            {
                 
                // vertex 1 -----------------------------------------------
                Vertex v = new Vertex();              
                v.setVertex(verts.get(each.v1));
                v.setNormal(norms.get(each.n1));                  

// check to see if the vertex already exists, if it does just ad the index to the index array if not add it do both.              

                short index = (short) this.vertexs.indexOf(v);      
                if (index < 0) {                    
                    this.vertexs.add(v);
                    index = (short) (this.vertexs.size() - 1);
                }
                indexes.add(index);

                // vertex 2 ------------------------------------------------
// do the same for each vertex in the face.

                v = new Vertex();
                v.setVertex(verts.get(each.v2));                
                v.setNormal(norms.get(each.n2));  

                index = (short) this.vertexs.indexOf(v);        
                if (index < 0) {                      
                    this.vertexs.add(v);
                    index = (short) (this.vertexs.size() - 1);
                }
                indexes.add(index);

                // vertex 3      -------------------------------------------

                v = new Vertex();
                v.setVertex(verts.get(each.v3));
                v.setNormal(norms.get(each.n3));  
 
                index = (short) this.vertexs.indexOf(v);        
                if (index < 0) {                    
                    this.vertexs.add(v);
                    index = (short) (this.vertexs.size() - 1);
                }
                indexes.add(index);
                }
            }
         }


The last part is for you to decide which you put the data straight into a FloatBuffer and IntBuffer or just use regular java arrays. It depends on what you want to do with the data. I personally convert it to my own model format and save in a binary file to load later, but you might want to check that your code works first and view your model.

You can get the data into arrays with this following code.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
            int size = vertexs.get(0).size();

            float[] vertices = new float[vertexs.size() * size];      

            // puts the vertex data in to a float array.
            for (int i = 0;i < vertexs.size();i++){
                System.arraycopy(vertexs.get(i).getVerts(), 0, vertices, i*size, size);        
            }

            // put the indexes into an short array
            short[] ind = new short[indexes.size()];
            for (int i = 0; i < indexes.size();i++){
                            ind[i] = indexes.get(i);            
            }



Incidentally you can use the same code to parse <polylist>  so long as the <vcount> node only contains 3s (triangulate from your modeling program first)
14  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-09-16 16:35:06
Managed to write a shader to show bone weights.

 

Still trying to get my skinning code to work....
15  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-17 13:44:30
Can now display normals in my render engine

16  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-07-14 13:28:40
 Grin Yay I got the xbox 360 controller working on the Raspberry pi using Jinput. Next is to get my game pad library to work on Android, so it is the same across Windows/ Linux /android /raspberry pi. I already have my rendering code running on each of these. It is great when things work!
17  Game Development / Newbie & Debugging Questions / Re: [lwjgl] Changing an undecorated window to decorated without destroying on: 2014-06-24 09:42:42
If you just want a splash screen before the main window shows, you could just use swing to make the splash screen then open a LWJGL display after.

or you could use Launch4j to make "Native pre-JRE splash screen in BMP format shown until the Java application starts."
18  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-06-19 22:46:22
Thank you cylab for your helpful suggestion. Roll Eyes  l will have to try out this new fangled 'google'
19  Discussions / Miscellaneous Topics / Re: Interesting Profile pictures on: 2014-06-19 15:39:34
My profile picture has changed many times. But I like this one so might stick with it.
20  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-06-19 15:19:07
Cas
Quote
"just use" LWJGL-ES with that context.

That would be handy. Definite time saver. Grin
21  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-06-19 12:39:42
@PandaMoniumHUN I would give LWJGL a go on the Raspberry Pi if there was a tutorial to show me how to use it. As far as I know there is the source code for OpenGL ES2 but I don't know what to do with it.
My library doesn't use the x window system just the hdmi full screen surface that you can use without booting up the desktop. I'm hoping it will be a performance boost. I'm not sure yet how to do input, which might require a window. Unless I can find a library that lets me use the keyboard, mouse or joypad without making a window first.

As to the performance of the Raspberry Pi.. I started programming on the ZX81 when I was about 12 a long time ago so anything with more then 16k RAM, feels like an upgrade! Wink When you don't have to wait half an hour for a tape drive to load the game.. after crashing 3 times....

Anyhoo.. The raspberry pi is a lot of fun. I'm not sure how much of a serious games system it could be. But with quotes about xbox1 level graphics ect.. and some pretty nifty demos I've seen on youtube. Its good for learning on. I might have to buy a couple or more RPIs and make a game engine that spreads its processing across more then one. Graphics on one, sound on another, ai another...etc
22  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-06-18 17:42:19
Yay I now have my own OpenGL ES2 library working on Raspberry Pi and Java 8. I  made a very simple wrapper using jni, to give a full screen context with EGL and then I can use the GL code freely. Now just to work out how to make an Input library and sound...

The Display class only has 5 methods so far but it gets the job done.

 createDisplay();
 swapBuffers();
 destroyDisplay();
 getDisplayWidth();
 getDisplayHeight();
23  Discussions / Miscellaneous Topics / Re: What do you develop your games on? on: 2014-05-07 12:29:19
In the spirit of friendly chit chat and making the noobs feel welcome  Pointing

I used to have a full sized room.. now I have the space under the stairs.... sobs.... Only just wide enough to fit in two 24in screens. Still a lot better then 14in black/white!

Here is a pic of my rig.

24  Discussions / General Discussions / Re: Are there any artists on this forum? on: 2014-05-05 12:53:45
I only work in 3D, shame I don't have any time right now. College assignments are weighing me down. My be when I'm done I might be able to join in.

25  Discussions / Miscellaneous Topics / Re: What do you develop your games on? on: 2014-05-05 12:41:44
Win7 64 bit (down graded from 8.1)
AMD Phenom II x6 2.80GHz
4 GB ram
Nvidia GTX 650 Ti 1 GB ram
(24in acer 1920 x 1080) x 2
26  Discussions / Miscellaneous Topics / Re: Is our Universe Simulatable? on: 2014-04-29 08:42:14
Ok for this LOD we're talking a very lossy compression ratio of.... Pointing

1 .. 2.. skip a few... 99 100  Grin
27  Discussions / Miscellaneous Topics / Re: Is our Universe Simulatable? on: 2014-04-29 08:13:10
Just an observation from my AI course.

Simulation of a natural system is a model that captures the functional connections between inputs and outputs of the system.

Replication of a natural system is a model that captures the functional connections between inputs and outputs of the system and is based on processes that are the same as, or similar to, those of the real-world system.

Emulation of a natural system is a model that captures the functional connections between inputs and outputs of the system, base on processes that are the same as, or similar to, those of the natural system, and in the same materials as the natural system.

Simulacrum is an imitation... something having merely the form or appearance of a certain thing, without possessing its substance or proper qualities.

Simulation has a purpose to model a system on a certain level of detail. So depending on what level of detail you want to get into you could simulate the universe.
28  Discussions / Miscellaneous Topics / Re: Is our Universe Simulatable? on: 2014-04-28 17:48:04
2 mice = 42  Grin
29  Game Development / Newbie & Debugging Questions / Re: Problems rendering .obj file on: 2014-04-28 17:40:21
Just a thought, but can you move your model or move your view/camera around? You might be inside the model if it is the bunny.obj. try rendering in wire mesh mode.

glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

I find it is easy to use a cube model first so you can make sure all the faces are the right way.
Also if you don't multiply by the modelviewprojection matrix ect the model will not be in the right space.....
30  Game Development / Newbie & Debugging Questions / Re: Problems rendering .obj file on: 2014-04-26 16:14:28
It isn't that simple. You need to use the face data otherwise the vertex data is not in the right order.
Pages: [1] 2 3
 

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!