# JD_Rushing

Member

8

373 Neutral

• Rank
Newbie

• Role
Programmer
• Interests
Art
Design
Programming
1. ## Strange slowdown when model(s) goes off screen

How are you storing and updating your objects?
2. ## Odd issue with Separating Axis Theorem

Without edge testing i was getting false positives.  And the last loop is testing the mix/max for the smallest overlap.  X,Y is min0 and max0.  Z,W is min1, max1.  I don't plan on keeping it like that, as storing the values is definitely not optimized.  It was just for debugging.   Walking passed the "cracks" between 2 oob is apparently a common problem.  I am trying to research and see what I can find.  Although any suggestions on that would be great.   EDIT: I am averaging all the collisions together and then applying the average to the object to move it.  It appears to be working right now with low gravity.  Higher gravity, back to same problem.
3. ## Odd issue with Separating Axis Theorem

Well the code is mostly fixed.  bool Collide(RigidBody* other, Vector4f& collision) { std::vector<Vector3f> axies; std::vector<Vector4f> minmax; int count = 0; float min0, max0; float min1, max1; Vector3f dir; float dist = 10000.f; Vector3f axis; int wAxis = -1; int which = -1; axies.resize(0); minmax.resize(0); Vector3f offset = pos - other->pos; for (count = 0; count < GetFaceSize(); count++) { dir = GetNormal(count); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); } for (count = 0; count < other->GetFaceSize(); count++) { dir = other->GetNormal(count); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); } int counts; for (count = 0; count < GetFaceSize(); count++) { for (counts = 0; counts < other->GetFaceSize(); counts++) { dir = GetNormal(count).CrossProduct(other->GetNormal(counts)); dir.Normalize(); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); } } int aCount = 0; float temp; for (count = 0; count < axies.size(); count++) { if (!axies[count].isEqual(Vector3f(0, 0, 0))) { if ((minmax[count].y - minmax[count].z < minmax[count].w - minmax[count].x) && minmax[count].y > minmax[count].z) { if (dist > minmax[count].y - minmax[count].z) { wAxis = count; axis = axies[count]; dist = minmax[count].y - minmax[count].z; } } else if (minmax[count].w > minmax[count].x) { if (dist > minmax[count].w - minmax[count].x) { wAxis = count; axis = axies[count]; dist = minmax[count].w - minmax[count].x; } } } } if ((pos - other->pos).Dot(axis) < 0) { axis = axis * -1.0f; } collision = Vector4f(axis, dist); return true; } The cross product of the 2 box faces is for edge testing.  And the check for a 0 direction is because cross product of same directions give you a 0.   Ty snake5 on the min/max, that was a problem, and the "touching == true" was unneccessary.   It works mostly.  When two oobs meet, I seem to get caught or pushed out of the hallway.
4. ## Odd issue with Separating Axis Theorem

bool Collide(RigidBody* other, Vector4f& collision) { std::vector<Vector3f> axies; std::vector<Vector4f> minmax; int count = 0; float min0, max0; float min1, max1; Vector3f dir; float dist = 10000.f; Vector3f axis; bool moving = false; bool touching = false; int wAxis = -1; int which = -1; axies.resize(0); minmax.resize(0); for (count = 0; count < GetFaceSize(); count++) { dir = GetNormal(count); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); if (max1 == min0 || max0 == min1) { touching = true; } else { if (max0 > min1 && dir != Vector3f(0, 0, 0)) { if (dist > max0 - min1 && max0 - min1 > 0.0f) { dist = max0 - min1; axis = dir; wAxis = axies.size() - 1; } } else if (dir != Vector3f(0, 0, 0)) { if (dist > max1 - min0 && max1 - min0 > 0.0f) { dist = max1 - min0; axis = dir; wAxis = axies.size() - 1; } } } } for (count = 0; count < other->GetFaceSize(); count++) { dir = other->GetNormal(count); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); if (max1 == min0 || max0 == min1) { touching = true; } else if (max0 > min1 && dir != Vector3f(0, 0, 0)) { if (dist > max0 - min1 && max0 - min1 > 0.0f) { dist = max0 - min1; axis = dir; wAxis = axies.size() - 1; } } else if (dir != Vector3f(0, 0, 0)) { if (dist > max1 - min0 && max1 - min0 > 0.0f) { dist = max1 - min0; axis = dir; wAxis = axies.size() - 1; } } } int counts; for (count = 0; count < GetFaceSize(); count++) { for (counts = 0; counts < other->GetFaceSize(); counts++) { dir = GetNormal(count).CrossProduct(other->GetNormal(counts)); dir.Normalize(); Project(dir, min0, max0); other->Project(dir, min1, max1); if (max0 < min1 || max1 < min0) return false; axies.push_back(dir); minmax.push_back(Vector4f(min0, max0, min1, max1)); if (max1 == min0 || max0 == min1) { touching = true; } else if (max0 > min1 && dir != Vector3f(0, 0, 0)) { if (dist > max0 - min1 && max0 - min1 > 0.0f) { dist = max0 - min1; axis = dir; wAxis = axies.size() - 1; } } else if (dir != Vector3f(0, 0, 0)) { if (dist > max1 - min0 && max1 - min0 > 0.0f) { dist = max1 - min0; axis = dir; wAxis = axies.size() - 1; } } } } if (touching == true && dist > 1000.0f) { dist = 0; } collision = Vector4f(axis * -1.0f, dist); return true; }
5. ## Odd issue with Separating Axis Theorem

I have the collision detection working great.  I have a hallway I generate with a box that moves down it.  I have gravity that will pull the object down when I raise it with [space].  If I turn off collision response, the box will stop if it's next move will collide, every time.  But with collision response on, it will follow most surfaces without penetrating perfectly.  But certain spots of some faces will cause the collision response to tell it to go to an opposing face versus along the face it is against.  Like if it was moving along the face with an -x normal, it will jump to the face with the -y normal instead.  And when I look at the list of axes and min/max, the min/max differences all have a much larger gap that it should.  Has anyone run into anything like this?   The hallway is composed of 4 different OBB, one for each wall.
6. ## Small break, but back to work

I took a break due to work being hectic and everyone seeming to get sick. I added alpha blending and I have working armatures and working on the keyframes to create animations.
7. ## 2d Game Creation

Different screenshots along the way
8. ## It looks like something

I got rid of most of the slider bars now that I have working color picking and constant buffers. So I decided to try and draw something. I was going for the mysterious woman on the water in a row boat. All the shapes now have visible, clickable, control points. I need to work a little bit more on correct mouse movement translations (you move left but the control moves right). But I was able to accomplish this. Next is armatures for actual animation. [sharedmedia=gallery:images:5804]

10. ## C++ porting progress

I am using visual c++ 2010 express, I somewhat like it.  I got used to code::blocks for my c++.  And eclipse for Android/Java.  It has been interesting actually learning some directx, but I like opengl better still.
11. ## Vector Graphics

But I like its efficiency with multiple platform and resolutions.
12. ## Videolog #7 - Answering questions & a 80's montage.

I played the alpha demo on android.......release game, must play more
13. ## Bezier, it's french

It shouldn't be too hard to implement.  You would just interpolate the z as well.  You would probably use 4 control points over a grid.  I believe I have seen examples of it.
14. ## Bezier, it's french

So I got bezier curves kickin', along with variable width of the start, middle, and end. If you have not used bezier ([be.zje]) is actually not a hard concept, but very effective. They use control points to modify a line interpolation from straight line into a curve. Coding Math 19 was very helpful. I used cubic bezier, so I have a start point, end point, and two control points. This is the code, to which I got directly from the video, but it is apparently just the code for quadratic bezier (1 control point) and Cubic bezier (2 control point). t is what percent along the line you are at (between 0.0f and 1.0f). You input the start, 1 or 2 control points depending, and the end point. You give the t and it will change pFinal to the correct point along the curve. The smaller the increments you give for t, the smoother the curve will look. All the curves in the picture are 20 segments. void QuadraticBezier(Vector2f p0, Vector2f p1, Vector2f p2, float t, Vector2f& pFinal){pFinal.x = powf(1.0f - t, 2.0f) * p0.x + (1 - t) * 2.0f * t * p1.x + t * t * p2.x;pFinal.y = powf(1.0f - t, 2.0f) * p0.y + (1 - t) * 2.0f * t * p1.y + t * t * p2.y; }void CubicBezier(Vector2f p0, Vector2f p1, Vector2f p2, Vector2f p3, float t, Vector2f& pFinal){pFinal.x = powf(1.0f - t, 3.0f) * p0.x +powf(1 - t, 2) * 3.0f * t * p1.x +(1 - t) * 3 * t * t * p2.x + t * t * t * p3.x;pFinal.y = powf(1.0f - t, 3.0f) * p0.y +powf(1 - t, 2) * 3.0f * t * p1.y +(1 - t) * 3 * t * t * p2.y + t * t * t * p3.y;} I also used a function I wrote called Wide. It uses the start, middle, and ending widths are parameters. t is the same as the curve. It calculates how wide the line will be. Before halfway through, it ignores the ending width. After halfway through, it ignores the beginning width. It was cleaner than having all this in the loop creating the curve.Vector2f Wide(Vector2f a, Vector2f b, Vector2f c, float t){float x, y;if (t == 0.0f){x = a.x;y = a.y;}else if (t < .5f){float d = t * 2.0f;x = a.x * (1.0f - d) + b.x * d;y = a.y * (1.0f - d) + b.y * d;}else if (t == .5f){x = b.x;y = b.y;}else{t = t - .5f;float d = t * 2.0f;x = b.x * (1.0f - d) + c.x * d;y = b.y * (1.0f - d) + c.y * d;}return Vector2f (x, y);} [sharedmedia=gallery:images:5779]
15. ## Ellipses

Just realized the sqrt part was not needed.  Anything less than one squared will still be less than one.  Anything more than one squared will still be more than one.