1 / 11

CS 497: Computer Graphics

CS 497: Computer Graphics. James Money. Object Collision. What happens if a viewer walks into an object right now?. Object Collision. You walk right through the object!. Object Collision. What do we need to determine when a view comes in contact with an existing object?

liseli
Download Presentation

CS 497: Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 497: Computer Graphics James Money

  2. Object Collision What happens if a viewer walks into an object right now?

  3. Object Collision You walk right through the object!

  4. Object Collision What do we need to determine when a view comes in contact with an existing object? We need to determine the intersection of two volumes.

  5. Object Collision However, intersecting objects is an expensive operation. If we operate on bounding volumes, we can make this a simple operation. We just can check the bounding coordinates of the object’s volume!

  6. Object Collision Boolean Intersect(Object1 *obj1,Object2 *obj2){ if ((obj1->minX < obj2->minX) && (obj1->maxX > obj2->minX)) || ((obj1->minX < obj2->maxX) &&(obj1->maxX > obj2->maxX)){ if ((obj1->minY<obj2->minY)&&(obj1->maxY>obj2->minY)) || ((obj1->minY<obj2->maxY) &&(obj1->maxY>obj2->maxY)){ if ((obj1->minZ < obj2->minZ) && (obj1->maxZ > obj2->minZ)) || ((obj1->minZ < obj2->maxZ) &&(obj1->maxZ > obj2->maxZ)){ return TRUE; } } } if ((obj2->minX < obj1->minX) && (obj2->maxX > obj1->minX)) || ((obj2->minX < obj1->maxX) &&(obj2->maxX > obj1->maxX)){ if ((obj2->minY<obj1->minY)&&(obj2->maxY>obj1->minY)) || ((obj2->minY<obj1->maxY) &&(obj2->maxY>obj1->maxY)){ if ((obj2->minZ < obj1->minZ) && (obj2->maxZ > obj1->minZ)) || ((obj2->minZ < obj1->maxZ) &&(obj2->maxZ > obj1->maxZ)){ return TRUE; } } } return FALSE; }

  7. Object Collision int Polygon3D::PtInPolygon(Point3D &pt){ double total=pt.x*N->v[0] + pt.y*N->v[1] + pt.z*N->v[2] + N->v[3]; if (fabs(total) > 0.5E-5) return FALSE; int numEdges=0; double tx,ty,tz; for(int I=0;I<(numPoints-1);I++){ tx=(pt.x - pts[I].x)/(pts[I+1].x + pt.x - pts[I].x - maxX); ty=(pt.y - pts[I].y)/(pts[I+1].y + pt.x - pts[I].y - maxY); tz=(pt.z - pts[I].z)/(pts[I+1].z + pt.z - pts[I].z - maxZ); if (((tx>=0.5E-5) && (tx<=1.000005)) && ((ty>=0.5E-5) && (ty<=1.000005)) && ((tz>=0.5E-5) && (tz<=1.000005))) numEdges++; } tx=(pt.x - pts[numPoints-1].x)/ (pts[0].x + pt.x - pts[numPoints-1].x - maxX); ty=(pt.y - pts[numPoints-1].y)/ (pts[0].y + pt.x - pts[numPoints-1].y - maxY); tz=(pt.z - pts[numPoints-1].z)/ (pts[0].z + pt.z - pts[numPoints-1].z - maxZ); if (((tx>=0.5E-5) && (tx<=1.000005)) && ((ty>=0.5E-5) && (ty<=1.000005)) && ((tz>=0.5E-5) && (tz<=1.000005))) numEdges++; if (numEdges & 1) return TRUE; return FALSE; }

  8. Moving Up in the World Now we can detect if the user runs into an object in the world. What about stepping on objects or falling?? For stepping up, we can just check to see if the user’s height/4.0 is greater than the height from where you currently are and the top(Ymax) of the bounding rectangle of the object.

  9. Falling in the world! Now for falling, we have to check to see if the base of of the user object if equal to the base of some object in the world.(Remember in intersection that we don’t check if it’s equal!) We can make it easy by checking the point at the middle of the object on the bottom face of the user.

  10. Falling in the world! To make things easy, we keep a record of the last item you were on top of, and check it first. It the points fits the plane equation for that polygon, we do nothing. If not, we search for a polygon in the current room that has a normal that satisfies this point and save that polygon for next time. If none exists, we drop in world Y coordinates by some value(perhaps 0.2 meters) until we hit a polygon.

  11. Falling in the world! To make things even easier, we will not check an object in the room whose Xmin, Xmax, Ymin, Ymax are not within our X,Y user position at the base.

More Related