robee00

Member
  • Content count

    29
  • Joined

  • Last visited

Community Reputation

206 Neutral

About robee00

  • Rank
    Member
  1. Hi!   What kind of shape should I use in a 2D topdown space game for collision? I was thinking about AABB, but as the ships are rotating they are not the best option. I was thinking about OBBs or a group of Bounding Circles. I'm more into the circles because of the performance, and I can define a ship's collider more precisely with more circles. I would like to hear your opinion too
  2. OBJ loader for opengl (LWJGL)

    Ooops that t.y = t.y stayed in the code, I wrote t.y = 1f - t.y to flip the image on the y-axis. The texID's value is 0 by default, so I can check if there is no tex coords for that vertex.   https://mega.co.nz/#!8FtkXDzZ!R6S_71KMoKIhS4edYjq1VnnimMZ7TvLDL6OSmW_Zxuk <- link for obj and texture   It is not a cube, it's a sh*tty hallway, just made something to try the loader. Here is how it looks like http://i.imgur.com/sWXw7Lp.png   http://pastebin.com/38ECG3ge <- code for the class
  3. Hi   I wrote a simple OBJ loader but the texcoords are messed up somehow. I can't figure out what is wrong. I tried flipping the texture on the Y-Axis, no success. (Here is how my object looks like: http://imgur.com/d8edSyw   Code: (FaceData holds the IDs for vertices, normals and texcoords, Vertex class holds the data) public void parseObj(String path) { try { BufferedReader reader = new BufferedReader(new FileReader(new File("").getAbsolutePath() + "/res/" + path)); String line = reader.readLine(); while(line != null) { if(line.startsWith("v ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); pos.add(new Vector3f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]), Float.parseFloat(vertexStr[2]))); } if(line.startsWith("vt ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); tex.add(new Vector2f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]))); } if(line.startsWith("vn ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); norm.add(new Vector3f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]), Float.parseFloat(vertexStr[2]))); } if(line.startsWith("f ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" "); for(int i = 0; i < vertexStr.length; i++) { String verStr = vertexStr[i].replaceAll("//", "/0/"); String[] asd = verStr.split("/"); FaceData data = new FaceData(); data.vertexID = Integer.parseInt(asd[0]); data.texID = Integer.parseInt(asd[1]); data.normalID = Integer.parseInt(asd[2]); faces.add(data); } } line = reader.readLine(); } reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } for(int i = 0; i < faces.size(); i++) { Vertex v = new Vertex(); v.pos = pos.get(faces.get(i).vertexID - 1); if(faces.get(i).texID != 0) { Vector2f t = new Vector2f(); t = tex.get(faces.get(i).texID - 1); t.y = t.y; v.texCoord.set(t); } else v.texCoord = new Vector2f(0,0); v.normal = norm.get(faces.get(i).normalID - 1); vertices.add(v); } }
  4. Loading OBJ model to VBO

    I replaced drawElement with drawArrays, and it draws the cube perfectly, so the problem is with the indices.
  5. Hello guys.   I came across a problem today. I exported a single cube from blender, and I tried to wrote a simple .obj loader to use. I think my parsing method is okay, but I have problem putting the data into a vbo/ibo. The vertex and fragment shader is working, I used them before. What I get is a deformated cube. Like faces (quad) only got one of the tris drawn.   Vertex class contains fields for position, texcoords, and normals   FaceData just holds the ID for vertex, texcoord and normal. public class Model { ArrayList<Vertex> vertices = new ArrayList<Vertex>(); ArrayList<Vector3f> pos = new ArrayList<Vector3f>(); ArrayList<Vector2f> tex = new ArrayList<Vector2f>(); ArrayList<Vector3f> norm = new ArrayList<Vector3f>(); ArrayList<FaceData> faces = new ArrayList<FaceData>(); int vbo; int ibo; public int indexCount; public Model(String name) { parseObj(name); FloatBuffer vertBuffer = BufferUtils.createFloatBuffer(vertices.size() * 8); for(Vertex v : vertices) { vertBuffer.put(v.getElements()); } vertBuffer.flip(); vbo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); IntBuffer indices = BufferUtils.createIntBuffer(faces.size()); for(FaceData f : faces) { indices.put(f.vertexID - 1); indexCount++; } indices.flip(); ibo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); } public void render() { GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 32, 0); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 32, 12); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 32, 20); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo); GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); } public void parseObj(String path) { try { BufferedReader reader = new BufferedReader(new FileReader(new File("").getAbsolutePath() + "/res/" + path)); String line = reader.readLine(); while(line != null) { if(line.startsWith("v ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); pos.add(new Vector3f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]), Float.parseFloat(vertexStr[2]))); } if(line.startsWith("vt ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); tex.add(new Vector2f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]))); } if(line.startsWith("vn ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" " ); norm.add(new Vector3f(Float.parseFloat(vertexStr[0]), Float.parseFloat(vertexStr[1]), Float.parseFloat(vertexStr[2]))); } if(line.startsWith("f ")) { int start = line.indexOf(" "); String sub = line.substring(start + 1); String[] vertexStr = sub.split(" "); for(int i = 0; i < vertexStr.length; i++) { String[] verStr = vertexStr[i].split("/"); FaceData data = new FaceData(); data.vertexID = Integer.parseInt(verStr[0]); //data.texID = Integer.parseInt(verStr[1]); data.normalID = Integer.parseInt(verStr[2]); faces.add(data); } } line = reader.readLine(); } reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } for(int i = 0; i < faces.size(); i++) { Vertex v = new Vertex(); v.pos = pos.get(faces.get(i).vertexID - 1); v.texCoord = new Vector2f(0,0); v.normal = norm.get(faces.get(i).normalID - 1); vertices.add(v); } } }
  6. 2D top down RPG map design

    Hi!   I'm creating some little art for my game, and I don't know how should I make the walls...   I uploaded a pic which shows the 2 method, and I can't decide which one looks better in a game. I would go with 2, but it looks like if there was no wall there. I thought about dropping a shadowed, darker piece of wall instead of that "lines"
  7. Learning C++ with OpenGL

    That's why I ask it. I could learn OGL in a more familiar language than C++, but if I start learning C++ I could continue my OGL learning. So I could learn both of them
  8. Hi!   I'm currently learning modern OpenGL with LWJGL, and I have some experience in Java and C# (2 - 2,5 years). On the other hand, I want to learn C++ too. Is it "hard" to learn both? (C++ and OpenGL too) I have a bit of experience in C++, but I like the managed languages more. But I want to have some more experience in C++ too
  9. Okay, so I reduced it to render just one plane. And I found an other tutorial: http://www.rastertek.com/gl40tut06.html   I use EXACTLY the same shaders, and I use exactly the same position, and normals. But I got a black triangle instead of a yellow one. Looks like intensity is always zero.   The class of what I'm rendering: http://pastebin.com/ez5K9vN3
  10. Oops, I forgot to add that I left out the top and bottom sides. But okay, I'll try to rewrite that, and include the top and bottom sides
  11. Hello!   For now, I used OGL in fixed function mode. But now I want to learn the programmable pipeline now.   I tried to implement a simple diffuse - specular lighting shader from http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/directional-lights-per-pixel/ . But I got wierd results (picture attached)   I uploaded my code to pastebin:   - Rendering: http://pastebin.com/cUDtHcWJ   - Vertex shader: http://pastebin.com/hE8s3KE7   - Fragment shader: http://pastebin.com/pVpr6zhR   And if I move my camera further the object, it gets brighter. Something I had to do with the position right?
  12. Sci fi dungeon crawler?

    Ooooo, thank you! That truly gave me some inspiration! Woah... :)
  13. Hi!   I'm having a plan on doing a 3D first person dungeon crawler. I'm doing the prototype with fantasy items (sword, cave setting, etc..), but I'm a sci-fi fan. I love game that is sci-fi. So, I was thinking about putting the game into sci-fi setting. But I'm having a hard time about melee weapons. Lightsabers are out, of course :P Energy swords? Or staffs? With ranged weapons, it's ok. I can drop in some guns, or something. And with enemies? Robots, aliens? And I'm not sure even if the dungeon crawler genre fits the scifi theme
  14. Check if enemy can see player

    I did it, I used the distance method that shazem given. I get the object with the smallest distance that collided with the ray. If it's the player's AABB, then gotcha, the enemy can see the player.