Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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
1  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.
2  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.
3  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.
4  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+
5  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)
6  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....
7  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-17 13:44:30
Can now display normals in my render engine

8  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!
9  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."
10  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'
11  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.
12  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
13  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
14  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();
15  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.

16  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.

17  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
18  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
19  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.
20  Discussions / Miscellaneous Topics / Re: Is our Universe Simulatable? on: 2014-04-28 17:48:04
2 mice = 42  Grin
21  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.....
22  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.
23  Game Development / Newbie & Debugging Questions / Re: Problems rendering .obj file on: 2014-04-26 15:49:22
I think you haven't used the face data to build the vertex data.
Try this video by Oskar Veerhoek it is pretty good for learning how to load OBJs

https://www.youtube.com/watch?v=izKAvSV3qk0&list=PL19F2453814E0E315&index=25
24  Discussions / General Discussions / Re: libgdx or unity on: 2014-04-21 22:35:59
@Cero
Quote
The fact that code is involved is... accidental 
Did you mean incidental? Cool
Most of my accidental code is just bad coding. It would be so cool to write a game engine by accident. So far I've written a lot and it is mostly intentional  Grin
25  Discussions / General Discussions / Re: Blender Character Animation formats on: 2014-04-17 10:51:35
I used that tutorial to create a collada importer as well. Its the only one I found that I could use to make an importer for Java. It is not the most optimised implementation but it gets the job done. I have all the mesh and texture data I want and an attempt at the joint and skinning info. I'm still trying to get the skinning to work in my render engine and haven't started using the animation data yet. If anyone has a working example of skinning in a shader they want to share, that would be great. I'm using blender and Ultimate Unwrap 3D so my importer has to be able to work with both.
26  Discussions / General Discussions / Re: The Big Linux Distro Thread on: 2014-04-02 09:12:31
I've only tried knoppix, ubuntu, mint and raspbian wheezy for the raspberry pi ( debian cut down version i think), and debian on VMPlayer to run SWGEmu. So far mint is my prefered distro. I just wanted an easy route to linux as I've mostly only used windows for many years. I started with a zx81, BBCs and acorn electron and used to using dos, so the terminal isn't to alien, but I still prefer to point and click and mint lets me use it the way I'm used to most of the time. Installing video drivers can be tricky but there is usually someone who has done it before and written a guide.
27  Discussions / General Discussions / Re: Java 8 on Raspberry Pi on: 2014-03-20 09:09:11
Cheers Riven I'll give JOGL a look.
28  Discussions / General Discussions / Java 8 on Raspberry Pi on: 2014-03-19 19:12:53
Yay! New Raspberry Pi today and Java 8 installed successfully (Linux ARM v6/v7 Hard Float ABI). Now just to figure out what the hell I'm going to do with it  Grin.
I have Netbeans set up to build and send the jar to the Raspberry Pi and then run it. I usually use LWJGL for opengl rendering, does it work on the Raspberry Pi? Or is there a similar alternative?
29  Discussions / General Discussions / Re: Data bases and game programming on: 2014-02-14 10:26:56
I will have to try out kryo, I've not seen that before. As teletubo says I am looking partly to practice what ill be learning in college, but also I intend on using sqlite for server side management of data. I want to make a game that you run a server on you desktop but can play the game on your desktop or phone/pad/tablet, so it takes the pressure off your mobile device and you can play with your friends and host your own games.

I'm developing for windows, Linux and Android, so I am wanting a solution that works for each. As sqlite is on android I thought I would start with  that. Up until now I haven't needed any persistent data, but before I get in too deep I want to consider the options. So far I can load models from *.obj files and Collada *.dae files. I'm working on getting joint animations and skinning to work.

Loading from these sorts of files and having to parse them takes way too long, a large model took up to 6 seconds to load a dae model on windows and over 50 seconds on android for the same model with the same code. So instead I made my own binary model data file and now it loads in 0.2 seconds on pc and android. Plus it is a fraction of the size.

So when it comes to the final release the data will be optimized binary formats, but for development I just want it to be simple, manageable and efficient.
30  Discussions / General Discussions / Data bases and game programming on: 2014-02-13 11:28:07
I'm having to put my game engine on hold (or at least much slower development) as I have just started my final two college courses (Relational databases: theory and practice and Fundamentals of interaction design) for a degree in computing.

The Interaction design course has some specific usage to game design with the interface and interaction, so I'm looking forward to that.

The database course is going to be useful as I am planing on using sqlite-jdbc
for media storage in my development tools, and for possible rpg data, skills, trades ect. in actual games.

So the question is :
     'How have you used databases/DBMS in your games/development?' 

and if not :
     'What other methods do you use to manage your data?

  • xml
  • text file
  • your own binary data format
  • not applicable as everything in your game is completely procedurally generated
  • shush... its top secret.. persecutioncomplex
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (40 views)
2014-09-24 16:13:29

Pippogeek (31 views)
2014-09-24 16:12:22

Pippogeek (21 views)
2014-09-24 16:12:06

Grunnt (47 views)
2014-09-23 14:38:19

radar3301 (29 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06

BurntPizza (55 views)
2014-09-19 03:14:18
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!