Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

170 Neutral

About Skyzyx

  • Rank

Personal Information

  • Interests
  1. Skyzyx

    Game Timer / Game Clock

    Ok I don't think that I am rendering to integer pixel boundaries but here is the rendering code. I have not linked my shaders though but the only thing I am doing in them is setting the color and multiplying by the projection matrix. Also the velocity vector doesn't need to have integer values. Even if I set the values to like (0.154f, 0.78f, 0.14784f) it works fine as long as the velocity vector is constant and not varying according to the time variable. I hope I have provided you with enough information and thanks for the help btw!   https://vimeo.com/177815657   GameClock:          http://pastebin.com/Qftx5A8P Player:                   http://pastebin.com/DxNi3wU7 Camera:                http://pastebin.com/0muxcE75 MyGLRenderer:    http://pastebin.com/tPetWSEn
  2. Skyzyx

    Game Timer / Game Clock

    I tried changing it to floating point values but the issue still remains. Note that I changed from milliseconds to seconds now: http://pastebin.com/vegNcwdM   But like you said. The difference is very small so I don't understand why this is an issue. You can see a few calculated values of elapsed time in seconds below.   0.014438041 0.015371792 0.016594417 0.016946709 0.024986375 0.012801459
  3. Hello!   Well I am trying to implement a game clock to my game so that the rendering and the updating of the player is based upon the elapsed time. The problem is that the elapsed time varies a little bit every frame so when I am multiplying with the elapsed time the player is sort of hacking. Now is moving forward but since the velocity vector is not the same every frame it is sort of hacking forward. If I change the multiplication of the variable "elapsedTime" with a constant value the  movement is smooth. I don't know how to fix this issue because I don't want the player to move the same amount every frame. I want to player to move based upon the elapsed time.   Here is some relevant code to look at: http://pastebin.com/f064xR7e   By hacking I mean non smooth movement. It looks like the player is moving 3 steps forward and 1 step back or something like that.   Regards!
  4. Skyzyx

    Rotating Camera

    Well incase it was unclear my character is centered around the center point of my camera. So I want to rotate around that point.
  5. Skyzyx

    Rotating Camera

    Hello!   I am have been reading quite a lot lately on how to rotate the camera around a point (my character) lately but I don't really understand the tutorials online because most of them use their own concepts or different techniques and so on.   So, currently when a user drags his finger across the screen I am registering the distance (deltaX). Now I need to rotate the camera around the Y-Axis accordingly to the maginitude of deltaX. I am using a right-hand coordinate system, so the X-Axis is pointing to the left, the Y-Axis is pointing straight up and the Z-Axis is pointing straight out of the screen. I also have three vectors that describe the orientation of the camera and they are listed below.   eye = new Vector3(0, 1.2f, 0);    //The camera's position up = new Vector3(0, 1, 0);          // Well the up vector center = new Vector3(0, 1, -2);   //The look at point.   Now I am not looking for somebody to do the work for me but rather explain how to rotate the camera properly around the Y-Axis. All I have is the deltaX from the user input and theese three vectors that make up the ViewMatrix which I then later on use to transform the objects in the world.   Regards!
  6. I tried to set the near plane to 0.1f or even 0.01f but everything gets stretched out. I tried using perspectiveM and setting the near plane to 0.1f seemed to do the trick with a 90 degree angle. Thanks for the help!
  7. Hello!   I have encountered some problems and I don't know what might be causing it. The problem is that I can't properly see what is being draw near to the camera.   This is how I am setting up my frustum but I have played around with it alot and it looks like that it is not the issue. http://pastebin.com/Zq9iZm9Y   This is how it looks right now: http://imgur.com/a/uxhgs You can see that if I rotate the world around that there is a wall/path behind me as well but as you can see it is being rendered strangely. If anybody knows what might be causing this please feel free to share the information.   Regards!
  8. Yes I was testing a few things and I noticed that the model's center needs to be at the origin when performing rotations. So basically what you said khatharr. Thanks :)
  9. Hello!   I am trying to rotate a character around it's mid point but apparently it is not working properly. This is the code that is making the transformations. http://pastebin.com/L6J7dbp5 Here are some pictures so you can see how the character is rotating. http://imgur.com/a/rS064   I think I am getting the transformations right but I could be wrong. If anybody might have any clue on why this might be happening or incase you might find a mistake that I might be making please feel free to share the information.   Regards!
  10. Hello!   I am trying to map a picture to some coordinates but the result is messed up. I am using OpenGL ES 2.0 and Java in Android Studio.   This is the cube file that I am loading the data from --> http://pastebin.com/sBcyfvGd   Now this is the end result of my uv coordinates stored in a float array called "TextureCoordinates" --> http://pastebin.com/vhm0jUrp   After that I have my uv coordinates stored in "TextureCoordinates" I am just doing the following --> http://pastebin.com/GHvUZRNn   And this is the result http://imgur.com/a/Dtw6F   Any help is appreciated. Incase you need more information you just have to ask and I will do my best to provide it.   Regards!
  11. Yes I did, I know that the faces need to be decremented by 1 because the indicies in the arrays start at 0.
  12. Hello!   I am trying to load a simple cube from file of type .obj. Something is going wrong but I can't seem to figure out what really because my vertices and the faces/indices for my vertices seems to be fine.   Hopefully somebody here will find the mistake that I am making. I will be posting all the relevant code below. You can assume that I have uploaded the information from the file correctly. I can post that code as well if somebody want to take a look but otherwise I don't want to upload unnecessary code. Also you don't have to worry about anything else but the vertices and the faces for my vertices. Don't bother with the texture coordinates, color, normals and so on.   Here are some pictures of how it looks right now. imgur.com/a/rZ6ap   Regards! public class Mesh { private boolean vertexHasColor = false; private boolean vertexHasTexture = false; private boolean vertexHasNormal = false; private ShortBuffer xyzFBuffer; private FloatBuffer xyzBuffer; private ShortBuffer uvFBuffer; private FloatBuffer uvBuffer; private FloatBuffer colorBuffer; private int h_TextureData; private int NUMBER_OF_XYZF; private int NUMBER_OF_UVF; private int NUMBER_OF_XYZ; private int NUMBER_OF_UV; private float [] TextureCoordinates; public Mesh(MeshData meshData, int h_TextureData) { this(meshData.xyz, meshData.xyzF, meshData.uv, meshData.uvF, null, h_TextureData, null); } /** * If the mesh has no color/normal/texture then pass in any negative * number as Offset. xyz contain the vertices. xyzF contains the faces. */ public Mesh(ArrayList<XMFLOAT3> xyz, ArrayList<Short> xyzF, ArrayList<XMFLOAT2> uv, ArrayList<Short> uvF, float[] color, int h_TextureData, float[] normal) { NUMBER_OF_XYZ = xyz.size() * 3; NUMBER_OF_XYZF = xyzF.size(); if(color != null) { vertexHasColor = true; } if(uv != null) { vertexHasTexture = true; NUMBER_OF_UV = uv.size() * 2; NUMBER_OF_UVF = uvF.size(); } if(normal != null) { vertexHasNormal = true; } this.h_TextureData = h_TextureData; ByteBuffer vbb = ByteBuffer.allocateDirect(NUMBER_OF_XYZ * 4); vbb.order(ByteOrder.nativeOrder()); xyzBuffer = vbb.asFloatBuffer(); xyzBuffer.put(XMFLOAT3.ConvertToArray(xyz)); xyzBuffer.position(0); ByteBuffer ibb = ByteBuffer.allocateDirect(NUMBER_OF_XYZF * 2); ibb.order(ByteOrder.nativeOrder()); xyzFBuffer = ibb.asShortBuffer(); xyzFBuffer.put(ConvertToArray.getArray(xyzF)); xyzFBuffer.position(0); if(color != null) { ByteBuffer colorbb = ByteBuffer.allocateDirect(color.length * 4); colorbb.order(ByteOrder.nativeOrder()); colorBuffer = colorbb.asFloatBuffer(); colorBuffer.put(color); colorBuffer.position(0); } if(uv != null) { StoreTextureCoordinates(uv, uvF); ByteBuffer texturebb = ByteBuffer.allocateDirect(NUMBER_OF_UV * 4); texturebb.order(ByteOrder.nativeOrder()); uvBuffer = texturebb.asFloatBuffer(); uvBuffer.put(TextureCoordinates); uvBuffer.position(0); } } public void StoreTextureCoordinates(ArrayList<XMFLOAT2> uv, ArrayList<Short> uvF) { TextureCoordinates = new float[NUMBER_OF_UVF * 2]; int index = 0; for(int a = 0; a < NUMBER_OF_UVF; a++) { TextureCoordinates[index] = uv.get(uvF.get(a)).u; TextureCoordinates[index + 1] = uv.get(uvF.get(a)).v; index += 2; } NUMBER_OF_UV = TextureCoordinates.length; } public void ClearScreen() { GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); } public void SetupMesh() { xyzBuffer.position(0); GLES20.glVertexAttribPointer(Shaders.h_pos, 3, GLES20.GL_FLOAT, false, 0, xyzBuffer); GLES20.glEnableVertexAttribArray(Shaders.h_pos); if(vertexHasColor) { xyzBuffer.position(0); GLES20.glVertexAttribPointer(Shaders.h_col, 4, GLES20.GL_FLOAT, false, 0, colorBuffer); GLES20.glEnableVertexAttribArray(Shaders.h_col); } if(vertexHasTexture) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, h_TextureData); GLES20.glUniform1i(Shaders.h_uTexture, 0); uvBuffer.position(0); GLES20.glVertexAttribPointer(Shaders.h_tex, 2, GLES20.GL_FLOAT, false, 0, uvBuffer); GLES20.glEnableVertexAttribArray(Shaders.h_tex); } if(vertexHasNormal) { } } public void DrawMesh() { GLES20.glDrawElements(GLES20.GL_LINES, NUMBER_OF_XYZF, GLES20.GL_UNSIGNED_SHORT, xyzFBuffer); } } public class XMFLOAT3 { public float x; public float y; public float z; public static float[] ConvertToArray(ArrayList<XMFLOAT3> XM3ArrL) { float returnArray[] = new float[XM3ArrL.size() * 3]; int XM3ArrLCounter = 0; for(int a = 0; a < returnArray.length; a += 3) { returnArray[a] = XM3ArrL.get(XM3ArrLCounter).x; returnArray[a + 1] = XM3ArrL.get(XM3ArrLCounter).y; returnArray[a + 2] = XM3ArrL.get(XM3ArrLCounter).z; XM3ArrLCounter++; } return returnArray; } } public class XMFLOAT2 { public float u; public float v; public static float[] ConvertToArray(ArrayList<XMFLOAT2> XM2ArrL) { float returnArray[] = new float[XM2ArrL.size() * 2]; int XM2ArrLCounter = 0; for(int a = 0; a < returnArray.length; a += 2) { returnArray[a] = XM2ArrL.get(XM2ArrLCounter).u; returnArray[a + 1] = XM2ArrL.get(XM2ArrLCounter).v; XM2ArrLCounter++; } return returnArray; } } public class MeshData { public ArrayList<XMFLOAT3> xyz; public ArrayList<XMFLOAT2> uv; public ArrayList<Short> uvF; public ArrayList<Short> xyzF; public MeshData() { xyz = new ArrayList<>(); uv = new ArrayList<>(); uvF = new ArrayList<>(); xyzF = new ArrayList<>(); } } //THE CUBE FILE v 0.0 0.0 0.0 v 0.0 0.0 1.0 v 0.0 1.0 0.0 v 0.0 1.0 1.0 v 1.0 0.0 0.0 v 1.0 0.0 1.0 v 1.0 1.0 0.0 v 1.0 1.0 1.0 vt 0.0 0.0 vt 0.0 1.0 vt 1.0 0.0 vt 1.0 1.0 f 1/4/2 7/1/2 5/2/2 f 1/4/2 3/3/2 7/1/2 f 1/2/6 4/3/6 3/1/6 f 1/2/6 2/4/6 4/3/6 f 3/1/3 8/4/3 7/3/3 f 3/1/3 4/2/3 8/4/3 f 5/4/5 7/3/5 8/1/5 f 5/4/5 8/1/5 6/2/5 f 1/2/4 5/4/4 6/3/4 f 1/2/4 6/3/4 2/1/4 f 2/2/1 6/4/1 8/3/1 f 2/2/1 8/3/1 4/1/1
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!