• Content count

  • Joined

  • Last visited

Community Reputation

154 Neutral

About rubenhak

  • Rank

Personal Information

  1. Hi Everybody, I've got an animated character imported to my engine which I want to scale. First I scaled the mesh vertex positions and the mesh itself looks perfect. The trouble is to scale my bones and animation transformation matrices. How should I multiply my transformation matrix so that animations of my bones would not get completely disassembled. Thank you, Ruben
  2. OpenGL Bloxorz game in OpenGL.

    before you get into a point when you want to move certain object try to create some structure around your code. Instead of hundrets glVertex(...) glTexCoords(...) with hardcoded numbers in those create some easy to use functions that would accept a position as an input and internally would call OpenGL functions to render your objects. Further it would be easier for you to change things upon user action.
  3. [quote name='Ashaman73' timestamp='1337751251' post='4942441'] Better to take a known export format like FBX/collada and write a converter between export file and your binary file. This way you can easily support other modelling tools like blender or maya. [/quote] I've already got a MAXScript that exports from 3ds max to an intermediate format which my engine consumed. It already exports transformation based animations. I've enhanced it to export vertex weights for skinned meshes and everything worked like a charm. Follow this article if somebody would need a similar thing: [url=""][/url]. I had some troubles with "Physique" modifier and could not manage to extract weights from it, but found a utility that converts "Physique" to "Skin" modifier which is a lot simpler to export. [quote name='Ashaman73' timestamp='1337751251' post='4942441'] The bone interpolation should be done on the CPU, the vertex transformation on the GPU. [/quote] Currently do everything with CPU. How would I calculate vertex transformations on GPU? I can have about 30-40 bones, should I need to have those bone information loaded into the shader? Isn't there a limitation on the amount of input data the at the shader can accept?
  4. OpenGL Bloxorz game in OpenGL.

    [quote name='Yasaswi Srikanth' timestamp='1338523862' post='4945194'] The [url=""][/url] . Yes I have seen them. Do you mean the Legacy Tutorials? I think these are very old like in 2000 . Will it be still useful for beginners in OpenGL to follow them? [/quote] Yes, those are the ones that I meant. Yes, it got originated in early 2000's, but will remain useful for another century or so. It will teach you fundamentals of 3D programming which does not change within a decade.
  5. OpenGL Bloxorz game in OpenGL.

    [url=""]dpadam450[/url] is right. but first you'd rather get basics of OpenGL first. Nehe tutorials would be a good and fun start. [url=""][/url] . Links to lessons on the right side.
  6. [quote name='Ed Welch' timestamp='1337948705' post='4943212'] I had problems on some devices if I called AudioSessionInitialize after initialisation of OpenGL. Also, the suspend should be like this: AudioSessionSetActive(NO); suspendContext = alcGetCurrentContext(); alcMakeContextCurrent(NULL); alcSuspendContext(suspendContext); AudioSessionSetProperty should be called at app initialization, not in OpenALInterruptionListener Also, don't forget to check OpenAL return codes for an error. [/quote] Ed, something is still not right in my case. I followed your suggestion and moved AudioSessionSetProperty to app initialization but still my InterruptionListener is not getting called. If that would make differences my engine is written in C++ and all calls to OpenAL are made from C++.
  7. thank you Ed for pointing this out! will move the propertySet at the initialization. All the OpenAL error codes are checked. I basically used a macro to catch and report errors after every OpenAL call.
  8. Ashaman73, for optimization purposes could I do the vertex multiplication only once like this:? [CODE] final_vertex = ( neck_bone_transformation * 0.3 + spine_bone_transformation * 0.2 + left_shoulder_bone_transformation * 0.25 + right_shoulder_bone_transformation * 0.25 ) * vertex; [/CODE] I'm thinking about writing a max script to export that information into a proprietary format and my engine would load that. That way I would not need to deal with other formats. At this point I've got the animation of the skeleton loaded into my engine. I just need to animate my object based on that. With this approach I would not be able to benefit from VBO if I decide to perform caculations on the CPU, right?
  9. [quote name='RobMaddison' timestamp='1337629755' post='4941994'] Google or search GD for skinning, hardware skinning or GPU skinning - there are hundreds of great sites to help with this [/quote] At this point I'd like to do that on a CPU. Later on might consider doing that on a GPU. Came across this article: [url=""][/url] . Is it good enough? The basic idea is to multiply the vertex by transformation matrix of the bone and the weight coefficient. Am I going in the correct direction? Also, how can I pull the information about vertex coefficients from 3ds max? I'm currently using a special 3ds max script that exports the model and transformation animations from the model into my internal format. Thank you!
  10. Hi, I want to load a character animation from a 3ds max. I'm capable to export transformation based animations (when objects are translated/rotated) into my engine. However in this case there is a mesh of the character which is put on top of the animated skeleton. With my current techniques of exporting/importing I get the skeleton animated in my engine, but the actual character is not. What is the technique to make my character to animate instead? Do I need to do some calculations in my engine, or there is more information to grab from 3ds max to make that happen? Thank you, Ruben
  11. Hi Everybody, I'm experiencing a nasty problem on iOS device related to audio playback. Tried to get some help from apple developer forum but does not seem like it is anyhow developer friendly. Hope I can get some help here. The problem is that if during application load user presses "Home" button and minimizes the application the OpenAL does not get initialized properly and no sound comes out off my application anymore. It has to get totally killed and relaunched to get the audio working. The error I'm getting right after activating OpenAL context is: [CODE] <0x3edabd98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>) <0x3edabd98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>) [/CODE] Further I tried to hook up to audio interruption event in order to properly handle audio interrupts, but this does not seem to work. The interrupt handler is not getting called. I initialize the audio session like this: [CODE] AudioSessionInitialize(NULL, NULL, OpenALInterruptionListener, this); [/CODE] and then try to handle the interruption like that: [CODE] void OpenALInterruptionListener(void * inClientData, UInt32 inInterruptionState) { OpenALDevice * device = (OpenALDevice *) inClientData; if (inInterruptionState == kAudioSessionBeginInterruption) { alcSuspendContext(_context); alcMakeContextCurrent(_context); AudioSessionSetActive(false); } else if (inInterruptionState == kAudioSessionEndInterruption) { UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); AudioSessionSetActive(true); alcMakeContextCurrent(_context); alcProcessContext(_context); } } [/CODE] but anyway my "OpenALInterruptionListener" function is not getting called. Any help is appreciated! Thank you, Ruben
  12. Tsus, I didnt have a chance to try the gluUnproject, but will try it out when I get back from work today. Yes, the up vector is (0, 0, 1). Regarding the zero test I know that there is a potential problem, but just want to keep everything simple until it works and then will prettyfy and cover corner cases. Thank you!!! Here are some numbers: [CODE] Camera Position: [100.34367 239.79147 234.27966] PerspectiveAspect: 1.7589803 PerspectiveFovy: 45.000000 PerspectiveZFar: 20000.000 PerspectiveZNear: 0.10000000 Viewport: 1518 x 863 Mouse: 115 x 402 ProjectionMatrix: [1.37251, 0, 0, 0 0, 2.41421, 0, 0 0, 0, -1.00001, -0.200001 0, 0, -1, 0] ProjectionMatrixInverse: [0.728594, 0, -0, 0 0, 0.414214, 0, -0 -0, 0, -0, -1 0, -0, -4.99997, 5.00002] ViewMatrix: [-0.922488, 0.386026, -8.60301e-009, 2.01551e-006 -0.258441, -0.617598, 0.74282, -1.52588e-005 0.286748, 0.685242, 0.669491, -349.937 0, 0, 0, 1 ] ViewMatrixInverse: [-0.922488, -0.258441, 0.286748, 100.344 0.386026, -0.617598, 0.685242, 239.791 -1.49012e-008, 0.74282, 0.669491, 234.28 -0, 0, -0, 1] normalizedCoord2D: [-0.84848487 -0.068366162] worldCoordNear: [100.373, 239.701, 234.211, 1] worldCoordFar: [5965.37, -18037.6, -13690.1, 1] intersectedPoint: [199.023, -67.7272, 0] [/CODE]
  13. Tsus, I'm pulling the hair off from my head. But it still does not help. Something does not work well. I'm not getting correct numbers. In my application I have a chess kind of board, cell has 100px dimension and when I click on the boundary I expect to get coordinate which is divisible by 100. But that does not happen. Here is my code: [CODE] MathLib::mat4 projectionMatrix = GetPerspectiveMatrix(); MathLib::mat4 viewMatrix = GetViewMatrix(); MathLib::mat4 projectionMatrixInverse = glm::inverse(projectionMatrix); MathLib::mat4 viewMatrixInverse = glm::inverse(viewMatrix); MathLib::vec2 screenCoord = MathLib::vec2(x, y); MathLib::vec2 normalizedCoord2D = MathLib::vec2(2.0 * screenCoord.x / viewportSize.x - 1.0, 2.0 * screenCoord.y / viewportSize.y - 1.0); MathLib::vec4 worldCoordNear; MathLib::vec4 worldCoordFar; { MathLib::vec4 normalizedCoordNear = MathLib::vec4(normalizedCoord2D.x, normalizedCoord2D.y, -1.0, 1.0); MathLib::vec4 clipCoordNear = normalizedCoordNear; MathLib::vec4 eyeCoordNear = projectionMatrixInverse * clipCoordNear; worldCoordNear = viewMatrixInverse * eyeCoordNear; worldCoordNear /= worldCoordNear.w; } { MathLib::vec4 normalizedCoordFar = MathLib::vec4(normalizedCoord2D.x, normalizedCoord2D.y, 1.0, 1.0); MathLib::vec4 clipCoordFar = normalizedCoordFar; MathLib::vec4 eyeCoordFar = projectionMatrixInverse * clipCoordFar; worldCoordFar = viewMatrixInverse * eyeCoordFar; worldCoordFar /= worldCoordFar.w; } MathLib::ray viewRay(MathLib::vec3(worldCoordNear), MathLib::vec3(worldCoordFar - worldCoordNear)); MathLib::plane groundPlane(MathLib::vec3(0, 0, 1), 0); MathLib::vec3 intersectedPoint; bool result = viewRay.intersect(groundPlane, intersectedPoint); [/CODE] The intersection function: [CODE] bool intersect(const Plane<Type> & p, glm::detail::tvec3<Type> & point) const { // Type vd = glm::dot(p.GetNormal(), _direction); if (vd == 0) return false; Type v0 = -(glm::dot(p.GetNormal(), getOrigin()) + p.GetDistance()); Type t = v0 / vd; point = _origin + _direction * t; return true; } [/CODE] Thank you! Ruben
  14. Tsus, thank you so much! I appreciate. I guess the next thing would be to build a ray that goes through unprojected near/far coordinates and intersect it with my plane? I'm already using GLM which does not seem to have Ray/Plane implementation. Is there any open library available that I can reuse its Ray and Plane implementations? Would I be able to reuse the depth value to reconstruct 3D coordinate without intersecting the ray with my objects? Would I just need to put the depth value into the: [CODE] vec4 normalizedCoord = vec4(normalizedCoord2D.x, normalizedCoord2D.y, depthValue, 1.0); [/CODE]? Thanks! It really helped!
  15. Hi, I know this has been discussed but want to confirm that I'm doing it the right way. I want to get the coordinate under the mouse pointer for the z=0 plane. This is my code: [CODE] mat4 projectionMatrix = GetPerspectiveMatrix(); mat4 projectionMatrixInverse = glm::inverse(projectionMatrix); mat4 viewMatrix = GetViewMatrix(); mat4 viewMatrixInverse = glm::inverse(viewMatrix); vec2 screenCoord = MathLib::vec2(x, y); vec2 normalizedCoord2D = MathLib::vec2(2.0 * screenCoord.x / viewportSize.x - 1.0, 2.0 * screenCoord.y / viewportSize.y - 1.0); vec4 worldCoordNear; vec4 worldCoordFar; { vec4 normalizedCoordNear = vec4(normalizedCoord2D.x, normalizedCoord2D.y, -1.0, -1.0); vec4 clipCoordNear = normalizedCoordNear; vec4 eyeCoordNear = projectionMatrixInverse * clipCoordNear; worldCoordNear = viewMatrixInverse * eyeCoordNear; } { vec4 normalizedCoordFar = vec4(normalizedCoord2D.x, normalizedCoord2D.y, -1.0, 1.0); vec4 clipCoordFar = normalizedCoordFar; vec4 eyeCoordFar = projectionMatrixInverse * clipCoordFar; worldCoordFar = viewMatrixInverse * eyeCoordFar; } [/CODE] So now if i build a ray with worldCoordFar & workdCoordNear points and intersect it with a the z=0 plane, would I get the correct coordinate? I'm just bit worried about /w division which I'm not sure where to put when unprojecting from 2d to 3d. Thanks, Ruben