Jump to content
  • Advertisement

forrestuv

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

100 Neutral

About forrestuv

  • Rank
    Newbie
  1. forrestuv

    Applying velocity to a (simple) tennis ball

    [color=#1C2837][size=2] [color=#1C2837][size=2]my english is poor I want to be able to choose a target on the other side of the tennis net and a height that I want the ball to be at when it passes over the net.
  2. forrestuv

    Applying velocity to a (simple) tennis ball

    Sorry if I resume a very old thread but I really need help on the subject. Using mr.Rowl solution I need to write a function that returns a vector containing the vector needed to cross the net but I really didn't understand how to implement it C# static public Vector3 getInitialBallSpeedToCrossTheNet(Vector3 startPoint, float netHeight, Vector3 destPoint, float totalTime) { float x0=startPoint.x; float y0=startPoint.y; float x1=0; float y1=netHeight; float x2=destPoint.x; float y2=destPoint.y; float g=9.8f; float A = (y1-y0); float B = -x1; float C = g*x1*x1/2; float D = (y2-y0); float E = -x2; float F = g*x2*x2/2; float u0 = Mathf.Sqrt(B * F / (A * E - B * D) - C * E / (A * E - B * D)); float v0 = -(A * F - C * D) / (u0 * A * E - u0 * B * D); return new Vector3(0,v0,u0); } basically I should put this vector inside the physic engine setting the velocity of rigidbody at start..but I can't understand how to make it work and how to use/obtain time etc... need help! anyone?
  3. To do that have I to transform the rotated box to axis aligned first? this is what I've found by searching the forum.. Is it the fastest method?Because I need a fast one.. Vector ClosestPointOnOrientedBox(const Vector& Point, const Vector& Centre, const Vector& Extent, const Matrix33& Orientation, bool& inside) { Vector Delta = (Point - Centre).MultiplyByTransposeMatrix(Orientation); inside = true; if (fabs(Delta.x) > Extent.x) { inside = false; Delta.x = Extent.x * sign(Delta.x); } if (fabs(Delta.y) > Extent.y) { inside = false; Delta.y = Extent.y * sign(Delta.y); } if (fabs(Delta.z) > Extent.z) { inside = false; Delta.z = Extent.z * sign(Delta.z); } // point was found outside. all good. if(!inside) { return Centre + Delta.MultiplyByMatrix(Orientation); } // point was found inside. Find which face is closest to our point. if (fabs(Delta.x) < fabs(Delta.y)) { Delta.y = 0.0f; if (fabs(Delta.z) < fabs(Delta.x)) Delta.x = 0.0f; else Delta.z = 0.0f; } else { Delta.x = 0.0f; if (fabs(Delta.z) < fabs(Delta.y)) Delta.y = 0.0f; else Delta.z = 0.0f; } return Centre + Delta.MultiplyByMatrix(Orientation); }
  4. Therefore the steps are: 1)calculate sat box min/max, projecting circle center, on each box axis. 2)check if box and circle are colliding writing the piece of code below.(I don't need a third axis?) /* Solid Box and Solid Sphere */ dmin = 0; for( i = 0; i < n; i++ ) { if( C < Bmin ) dmin += SQR( C - Bmin ); else if( C > Bmax ) dmin += SQR( C - Bmax ); } if( dmin <= r2 ) return TRUE; then? how to obtain the mtv? Damn...can't yet understand sorry :( Could you please go into more detail?..I guess I'm not a very talented programmer.. [Edited by - forrestuv on August 2, 2010 9:44:30 AM]
  5. The SAT for Box vs Box collision works ok. For Box To Circle collision I have to find the closest vertex of the box to the circle center using Voronoi regions. Quote from metanetsoftware.com tutorial: Naively testing the distance to each vertex would undermine the whole point of finding the closest vertex, which is to be able to reject the other vertices trivially, without expensive distance calculations. The very useful concept of voronoi regions can be used.
  6. Unbelieveble...nobody knows how to use voronoi regions? :(
  7. I've read metanetsoftware's tutorials many times, and I've already made a working SAT check, but I wasn't able to implement Circle vs Box collision check. Someone could explain me better how to: 1)calculate voronoi regions of a polygon? 2)know to which voronoi region a circle is inside?I guess voronoi regions are faster than a simple distance check vs all polygon vertex. any help would be very appreciated...I'm a bit frustrated... :(
  8. forrestuv

    SAT - Minimum translation vector

    public function Project(ax:SAT_axis):SAT_projection { var p:Number; var prj:SAT_projection=new SAT_projection() for (var i=0; i<sides; i++) { p = Math.abs(ax.dotProduct(vertexArr)); if (p < prj.min_) { prj.min_ = p; } if (p > prj.max_) { prj.max_ = p; } } return prj } public function testOverlap(prj1:SAT_projection,prj2:SAT_projection):Number { var d0:Number = prj1.max_ - prj2.min_; var d1:Number = prj2.max_ - prj1.min_; if(d0 < 0 || d1 < 0) return 0; if (d0 < d1){return -d0}else{return d1} } are those functions correct then?
  9. I have this situation where obj2box collides with the obj1box one on its top side. (both axis alligned) Check overlap over obj1 axes [0]Overlap :229.68519862516825 axis:Vector3D(-1, 0, 0) [1]Overlap :-2.221934558031876 axis:Vector3D(0, -1, 0) [2]Overlap :-229.68519862516825 axis:Vector3D(1, 0, 0) [3]Overlap :2.221934558031876 axis:Vector3D(0, 1, 0) Check overlap over obj2 axes [0]Overlap :229.68519862516825 axis:Vector3D(-1, 0, 0) [1]Overlap :-2.221934558031876 axis:Vector3D(0, -1, 0) [2]Overlap :-229.68519862516825 axis:Vector3D(1, 0, 0) [3]Overlap :2.221934558031876 axis:Vector3D(0, 1, 0) If I select the smallest one, the -229.68519862516825 is selected...but it is wrong since the vector should push obj2 up. this is my overlap check function(AS3): public function testOverlap(prj1:SAT_projection,prj2:SAT_projection):Number { var d0:Number = prj1.max_ - prj2.min_; var d1:Number = prj2.max_ - prj1.min_; if(d0 < 0 || d1 < 0) return 0; if (d0 < d1){return -d0}else{return d1} } this is my project function(AS3): public function Project ax:SAT_axis):SAT_projection { var p:Number; var prj:SAT_projection=new SAT_projection() for (var i=0; i<sides; i++) { p = ax.dotProduct(vertexArr); if (p < prj.min_) { prj.min_ = p; } if (p > prj.max_) { prj.max_ = p; } } return prj } 1)Something wrong with those scalars or I have to abs them? 2)The scalars of the second check are the same as the first, is it OK? 3)How to calculate the Mtv direction ? As you can see If I get ABS value, I have the two scalars of the same size that point to opposite direction.. After that I want the obj2 bounce over obj1: How to use MTV for that?Maybe I have to apply MTV first and the bounce? public function doBounce(planeVector:SAT_axis) { var dir:Vector3D=new Vector3D(this.vx,this.vy) var dp:Number=dir.dotProduct(planeVector) var mag:Number=dir.length*planeVector.length var sine:Number = dp/mag + Math.PI/2; var cosine:Number = dp/mag; this.vx = planeVector.x * sine - planeVector.y * cosine *2; this.vy = planeVector.x * cosine + planeVector.y * sine *2; } please someone help..thank you
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!