Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

179 Neutral

About Pris0n

  • Rank
  1. Hi Randy thanks again,   unfortunately  I am still kinda lost.   Does that mean given the vector 1,0,0; I am looking for the edge of my box which is farest away in this direction. Maybe a Picture will help. Red arrow is my example normal and then the small red line would be my edge I am looking for.     What is v exactly? is it my normal or one of my orientation vectors (you called them u, v, w)   So after getting 2 vertices for each edge I have more or less 2 segments. Then I find the closest points to each other on each segment and set the contact point as halfway point between these two points? Am I right?
  2. Hi Randy,   big thanks for your help I finally manged to get some data :) Sutherland-Hodgman clipping works fine for a face-something interaction. But I am stuck at the edge-edge problem. On your website you write about creating supporting edges, but for me it is not quite clear what a supporting edge actually is.   Here is what I understand: - Out of SAT I know the two edges of both OBBs - find a point on both of these edges - get the closest points on each edge to the other - set the contact point as the halfway point between the two points above (closest points)   Is this right? Thanks again for your site :)
  3. Sorry for the confusion.   My obb vs sphere check (pseudocode) A = OBB; B = Sphere; closestPoint = ClosestPointOnOBB(B.center, A); delta = closestPoint - B.center; distance = length(delta); if (distance < B.radius) {... function ClosestPointOnOBB(point, OBB){ A = OBB; B = OBB.data; //4x4 matrix //change the rotation of the baseMatrix (consist of unityMatrix) the same rotation the OBB has newBasematrix = B.baseMatrix * A.rotationMatrix; //convert to vector with 3 var axisX = (newBasematrix[0], newBasematrix[1], newBasematrix[2]); var axisY = (newBasematrix[4], newBasematrix[5], newBasematrix[6]); var axisZ = (newBasematrix[8], newBasematrix[9], newBasematrix[10]); centerRelPointToOBB = point - A.center; closestPoint = A.center; dist = dot(centerRelPointToOBB, axisX); if (dist > B.width / 2) { dist = B.width / 2; } if (dist < -B.width / 2) { dist = -B.width / 2; } closestPoint = closestPoint + axisX * dist dist = dot(centerRelPointToOBB, axisY); if (dist > B.height / 2) { dist = B.height / 2; } if (dist < -B.height / 2) { dist = -B.height / 2; } closestPoint = closestPoint + axisY * dist dist = dot(centerRelPointToOBB, axisZ); if (dist > B.length / 2) { dist = B.length / 2; } if (dist < -B.length / 2) { dist = -B.length / 2; } closestPoint = closestPoint + axisZ * dist return closestPoint; } This code works fine for all OBB models which are centered in their object space center (0,0,0). If the model (e.g. Box) is created in Blender or whatever at  100,0,0 (x,y,z) in object space. Then my check does work as long as I don't try to rotate my model. Then the collision will fail at a certain threshold.   Is it clear now?  
  4. Hi there,   I stumbled upon a bug in my implementation of OBB vs a Sphere. Here is the problem:   I created a simple Box in 3DSMax in positive x direction from the origin so my actual center of the box is somewhere near: 50,5,0   When I have this box in my scene and rotate it, it will always rotate around it's local origin which is fine. I defined my OBB like this: - center - dimensions - base vectors (1,0,0 /0,1,0/0,0,1)   While testing for collisions I recalculate my base vectors with the current rotation Matrix of the model.  In my opinion this is where it's buggy, because I rotate the base vectors regardless of the actual distance the object has to it's real position in object space. Meaning collisions for object centered in object space origin are working fine. But if the object is not centered in it's object space's origin than collision detection is not right any more.   Do you have any suggestion how to fix this problem? Is it clear what I tried to describe?  
  5. Hi,   I implemented the separating axes theorem as described in "Real time collision detection" by Ericson for my OBB vs OBB collision. Got that working.   To continue with my collision response I need more or less the contactNormal.   I thought about keeping track of the axis with the least penetration (penetrationDepth) and use this as the contactNormal. Is my separating axis equals the contactNormal? If so I am currently stuck, because if you look at the picture below this is my testing scene. When I keep track of the axis with minimum penetration, the corresponding axis is Az x Bz but the crossproduct of these two is [0,0,0] which makes sense. But obviously cannot be the right solution for my contactNormal.     The next problem I already think of is how do I know when to flip the contactNormal as I just use 3 positive axes per orientated bounding box. I already had a look at the ODE function dBoxBox which is often suggested around here, but I am not familiar with c++ and actually didn't get it how they find the reference/incident face and flip their normals.
  6. Pris0n

    Capsule vs AABB and OBB intersection

    Haha I don't know why, but after posting this I cam up with a solution :)   I first find the nearest point on the segment from there I treat the check like a sphere vs box collision.
  7. Hi there,   I am struggling with my implementation of a Capsule surrounding the character and collisions versus AABBs and OBBs. The problem I have, that I cannot figure out how to deal with this.  I already implemented Capsule vs Sphere which is quite easy (Point vs Segment). But vs a Box I do not have a constant value like the radius.   What I did so far: - find the nearest point on the segment to the center of the box (dunno if this is useful at all) - detect collision (which is more or less just a box vs box test)   - I thought about Seperating Axis Theorem, but doesn't it only work on boxes or not round objects?   Hoping for a push in the right direction :)   Thanks.
  8. Pris0n

    Capsule Moment Of Inertia

    Nice :) Thanks. I will definitely have a closer look at the axis theorem.
  9. Does anybody know a reference for the formula for the inertia tensor of a capped cylinder / capsule?  I always find the same equation but I actual want to understand the formula and not just use it, cause everybody does.   So the important part for me in the quote below: Ia = M1*(REAL(0.25)*radius*radius + (REAL(1.0)/REAL(12.0))*M1*length*length) + M2*(REAL(0.4)*radius*radius + REAL(0.375)*radius*length + REAL(0.25)*length*length); I understood the following: r = radius l = length of cylinder I = mass_of_cylinder * (1/4 * r * r + 1/12 * l* l) //formula for cylinder inertia + mass_of_sphere * (2/5 * r * r) //formula for sphere inertia + mass_of_sphere * (3/8 * r * l + 1/4 * l * l) //what's this for? I can only assume it maybe has to do something with the distance to the center , so the inertia will grow.  Thanks for your help  
  10. Pris0n

    AABB vs Sphere Collision on edges

    Sorry for the late reply. You were right. There was a small bug mixing up local and world coordinates.  Also I made a bug in calculating my bounding boxes which lead to an offset of the bounding box in x direction :D   Now everything works fine :)   in case of box colliding with sphere I just changed the contactNormal and contactPoint to this negate(delta); contactNormal = normalize(delta); contactPoint = Box.centerOfMass - delta; The behaviour looks right to me, but I am not 100% sure.
  11. Pris0n

    AABB vs Sphere Collision on edges

    Ok, sorry for that. (bold variables are vectors, non-bold are scalars):   centerRelSphereAABB  - center of the sphere relative to the center of the box closestPoint is the closest point on the box to the center of the sphere   ---> So I can do a simple distance check for the collision   I translated my code into pseudo code, I hope it is much more readable now   €: bold is not possible in code format styling  delta , contactNormal ,  contactPoint delta = centerRelSphereAABB - closestPoint; distance = length(delta); if(distance < Sphere.radius){ penetrationDepth = Sphere.radius - distance; contactNormal = delta - Sphere.center; contactNormal = normalize(contactNormal); //contact point contactPoint = Sphere.center - contactNormal * (Sphere.radius - penetrationDepth); }
  12. I implemented a simple AABB vs Sphere collision using this method from gamedev. It works fine when the sphere collides with the box from all sides. The problem is that the sphere will not slip of the edge of the box. Meaning when the sphere falling in -y direction collides on the edge of the box, it will just go in +y direction again. See the picture below (taken after collision). I think the problem is that the contactnormal is in this case always [0, 1, 0]. How do I achieve a more realistic behavior? For vector calculations I am using glMatrix. var delta = vec3.create(); vec3.subtract(delta, centerRelSphereAABB, closestPoint); distance = vec3.length(delta); if(distance < C.radius){ penetrationDepth = C.radius - distance; contactNormal = vec3.create(); vec3.subtract(contactNormal, delta, A.centerOfMass); vec3.normalize(contactNormal, delta); //contact point contactPoint = vec3.create(); vec3.scale(contactPoint, contactNormal, C.radius - penetrationDepth); vec3.subtract(contactPoint, model_1.centerOfMass, contactPoint); } The data is then forwarded to my collision response. [attachment=23468:Clipboard02.jpg]
  13. Ah ok, maybe I confuse you :)   I want to reconstruct my VertexPosition in view space from depth. So far I read through tons of artictles but wasn't able to get thinks working.   vec3 origin = should be my final VertexPosition in view space   Currently I'll do this, taken from http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/ vec3 origin = vec3(screenPos.xy, 1.0) * linearDepth; screenPos are the ndc of the screen: vec2 screenPos = vec2(gl_FragCoord.x / 512, gl_FragCoord.y / 512.0); But I dunno what origin should look like so i can validate the that it worked.
  14. I continued my research and found out that I need to project my vertices of the quad to the corners of the farplane by multiplying  it with the inverse of my perspective matrix in the vertex shader. So far so good. vViewRay = vec3(vec4(VertexPosition, 1.0) * invPerspectiveMatrix).xyz; Displaying viewray in the fragment shader looks like this:     I think it looks just fine with exception of the missing blue values. This could possible be the result of the z-value of my quad all being 1.0 before the inverseprojection. So it is gone after that. Putting z of the far clipping plane (z=1000); in, didn't change anything.   Any suggestions?
  15. Hi there,   I'm currently trying to implement a SSAO in WebGL. My inspiration is this site: Tutorial   But my current problem is to reconstruct the fragments view space position from depth. If I understood the viewray right it is a vector from the camera to a point on the far plane. I read through all of MJP s articles, but they confused me somehow. I render a fullscreen quad, so i get the TexCoords and the positions of x and y of the vertex. So my thought was, that only z is needed which I filled with the linearized depth value at the position of the TexCoord.     For visualisation I switched the coordinates from -1,+1 to 0,1; But even with that info I don't really know what the outcome should look like. vec3 viewRay = vec3(vViewRay.xy * 0.5 + 0.5 , linearDepth); Here is a fiddle of my 2 shaders I use. http://jsfiddle.net/Peters_Stuff/8ddkt/     Thanks for your ideas :)
  • 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!