The reality of virtual environments

  • Published on

  • View

  • Download


  • AUGUST/SEPTEMBER 2005 370278-6648/05/$20.00 2005 IEEE

    Virtual environmentsdo they reallylive up to expectations and reality tests?There has been an increased interest invirtual reality applications thanks to theamazing advances in graphics technol-ogy and computing power. Highlydetailed three-dimensional (3-D) com-

    puter models and environ-ments are commonly used indesign, manufacturing, simu-lation, and entertainment.These virtual environ-ments (VEs) are oftensuccessful at appearingrealistic when timeremains still, but as themobile objects are set intomotion and interact withtheir surroundings, the move-ments often appear unnatural.In many prerendered VEsused for entertainment pur-poses, all of the objectsmotions must be handmadeby 3-D animators in a processthat is time consuming andlacks strict realism. In otherVEs such as the first genera-tion of 3-D video games,objects are modeled by theirbounding space or by asphere that surrounds all ofthe 3-D models vertices. Inthese cases, the motions are often quitelinear, and the collision response algo-rithms are quite simplistic; some evenrevert to stopping an objects motionwhen it collides with the environment.These techniques are much too mini-mal and greatly reduce the level ofrealism in VEs.

    Letting animations follow their ownphysics is quickly becoming the newrecipe for realism as new techniques formodeling and animation based on thelaws of classical mechanics are emerg-ing in all virtual reality applications.

    Forces and frictionIn a VE, just as in the real world,

    forces affect bodies in accordance withthe second law of Newton. The sum of

    all forces through the center of mass of abody equals the mass multiplied by thelinear acceleration, and the sum of alltorques applied to the object equals theproduct of the moment of inertia and theangular acceleration. Both the linear andangular velocities will be modified when-ever a force is applied on a line that doesnot intersect the center of mass sincetorque will be generated. The object willnot only start moving away but it willalso start turning on a certain axis. Forcesapplied to an object are first decomposedinto the component that is applied direct-ly through the center of mass and theremainder that causes torque. Com-

    ponents through the center of mass mod-ify the linear velocity whereas theremainders will modify the angularvelocity of the object in question.

    These principles can be programmati-cally applied to the virtual world efficient-ly. During every program loop, whenevera force is applied to an object it is decom-posed into the component that modifiesthe linear velocity and the component thatmodifies the angular velocity; these forcesare added to two resulting vectors repre-senting the sum of all the linear forcesand the sum of all angular forces on theobject. At the end of each program loopwhen all of the forces have been added toall of the objects in the VE, the total linearand angular forces are used to obtain thelinear and angular accelerations of the

    object in question with Newtons laws.These results are used with the elapsedtime since the last loop to obtain theupdated velocities. The elapsed time mustbe used in this process otherwise the sim-ulation would be frame-rate dependent,i.e., the simulation would run faster on astronger computer capable of executingthe program loop more times per second.Figure 1 shows pseudocode of how forcesare handled in a typical program loop.

    This technique is excellent for realis-tically simulating all kinds of forces,such as natural and noninteractiveforces like gravity. This technique isalso excellent for managing interactive

    forces that are controlledby a user or artificial intel-ligence to get an objectfrom A to B. Realisticmotion will be the resultof thruster forces that areapplied to various prede-termined points on themodel with specific mag-nitudes and orientations.The motion is usually alsoaffected by friction coeffi-cients on the object thatare proportional to thespeed of the entity. A usercan control the model byvarious keys, which willenable specific thrusterswhen pressed.

    In most situationsthere will be a mainthruster that has a largemagnitude and is alwayspointing towards the frontof the model through thecenter of mass. This forceis used to make themodel advance without

    changing the current orientation. Thereare other forces that have no compo-nent through the center of mass; thismeans that enabling any of thesethrusters wont be directly responsiblefor any shift in the position of themodel but will only modify the orienta-tion of the object. Usually there are sixthrusters to allow rotation around anyof the axes in the clockwise and coun-terclockwise directions (Fig. 2). Bycombining these forces, the user canrotate the ship around any one of itsthree relative axes (right, top, front) andgains a fully 3-D range of motions.

    Collision detection and responseTwo main equations are used to deter-

    mine post-collision velocities of any

    The Reality of VirtualEnvironmentsJean-Christian Delannoy



    number of colliding bodies: thelaw of conservation of momen-tum (1) and the law of conserva-tion of energy (2). The conserva-tion of momentum law statesthat the sum of the momenta ofthe colliding bodies before thecollision will be equal to thesum after the collision. The lin-ear momentum of a body isobtained by multiplying its masswith its velocity. The rotationalanalogue to linear momentum isthe angular momentum, definedas the product of the moment ofinertia and the angular velocity;it is subject to the same conser-vation of momentum principle

    m1v1 + m2v2 = m1v+1 + m2v+2 s. (1)The elasticity of collision law accounts

    for the amount of energy lost during thecollision. This elasticity is necessary sinceimpacts in reality will create deformationson the colliding objects, whereas in oursimulation the objects are rigid and dontchange shape at all. The simulation relieson an empirical relation to quantify theenergy lost during the impact. Its com-puted by dividing the difference betweenthe velocities of both objects after the col-lision by the difference in velocity of bothobjects before the collision. The coeffi-cient of restitution is a value between 0and 1 and represents the amount of ener-gy lost during the collision

    e = (v+1 v+2 )

    (v1 v2 ). (2)

    No energy is lost in a perfectly elasticcollision, so the restitution coefficient will

    be one; in a perfectly inelastic collision, itwill be zero since all energy will be lost.

    Before any processing can be done tohandle a collision, the collision itself mustbe detected. This is dealt with in a hierar-chical manner: collision detection usingspheres and, if the result of the sphere testwas positive, collision detection using ori-ented bounding boxes (OBBs), a set ofpolygons that encapsulate the 3-D modelmore accurately than the sphere. The OBBwill move and rotate along with the 3-Dmodel it represents in the collision world.

    The collision response can also bethought of as consisting of two parts: thelinear collision response, dealing withthe linear velocities of objects, and theangular collision response, dealing withthe angular velocities of the objects.

    When dealing with linear collisionresponse, the collision detection algo-rithm will only need to supply the normalof the collision plane upon detecting acollision. During a collision, the two col-liding objects wont undergo any modifi-cation to their momentum that is orthogo-nal to the collision plane; so the speedused in both the elasticity and momen-tum equations will be the speed of theobject along the collision normal; thecomponent of the velocity that is orthog-onal to the collision normal will not beaffected. When dealing with both linearand angular collision response, we willneed to know the normal of the collisionplane and also the point of collision.

    Spherical collision detectionIn this first implementation, the vol-

    ume of every object is represented by asphere with a radius equal to the maxi-mum distance between any of the ver-tices of the 3-D model and the models

    center. Collisions occur whenev-er the distance between the cen-ter of two objects is less than orequal to the sum of the radii ofthe two objects. The collisionnormal is the normalized vectorgoing from the center of oneobject to the other.

    OBB collision detectionIf a collision has been

    detected using the method withspheres, we can proceed to oursecond level of collision detec-tion, which is more computa-tionally expensive but alsomuch more accurate. In thismethod the volume of eachobject isnt a sphere but a set ofOBBs, 3-D boxes that rotate

    when the model rotates. Detecting a col-lision with these shapes is more involvedthan it was with spheres. Here is thesequence of events when verifying forcollisions of object A against object B:

    For every set of four neighboringcoplanar vertices of the OBB of objectA, set up a plane equation (Ax + By+C z + D = 0) with the normal headingoutward.

    For every edge of object B, check ifthe line intersects with any of As planes.

    If an intersection point is found, seeif the intersection point is on the polygonand not just on the plane. (A planeranges from negative to positive infinity,and a polygon is limited in its bounds.)

    If the intersection point is on thepolygon, there is a collision.

    The collision normal is the normalof the traversed plane.

    The collision detection routine consistsof two hierarchical levels. Collision detec-tion with spheres is done first since it isquick and provides a good estimate; if acollision is detected with the spheres, thenthe second level of collision detection isdone with the OBBs method. The OBBcollision detection involves much morelogic and calculations than the sphere col-lision test but is also much more precise.Creating a hierarchical collision detectionroutine provides the best of both worlds,efficient and precise results, since theheavier OBB collision detection routine isonly called when two objects are near.

    Collision responseCollision response determines the

    postcollision velocities of objects thathave just been involved in a collision.With linear collision response, theangular velocities of the colliding

    Fig. 1 Pseudocode for force application and decomposition

    Object.TotalForce = (0,0,0);Object.TotalTorque = (0,0,0);


    TotalForce += Force * R;TotalTorque += Force R;

    Object.Acceleration = Object.TotalForce / Object.Mass;Object.AngularAcceleration = Object.TotalTorque / Object.Inertia;

    Object.Velocity += Acceleration * TimeElapsed;Object.AngularVelocity += AngularAcceleration * TimeElapsed;

    Object.Position += Object.Velocity * TimeElapsed;Object.Orientation += Object.AngularVelocity * TimeElapsed;

    Fig. 2 Thruster topology on a 3-D rigidbody



    Force Location and Orientation to Create Angular Velocity around Right and Top.Force Location and Orientation to Create Angular Velocity around Right and Top.

    Force Location and Orientation to Create Angular Velocity around Front.


    objects is not taken into account ormodified. Linear and angular collisionresponse bears its name because ittakes into account and modifies notonly the linear velocity of objects butalso their angular velocity; e.g., a base-ball bat floating in outer space that ishit at one of its extremities will notonly start moving away but will alsogain angular velocity and start spinningon its center of mass.

    Linear collision responseThe impulse method is used to deter-

    mine the postcollision velocities of twoobjects involved in a collision. Much likea real impulse, the method quantifies anindefinitely large force acting for a veryshort time (a collision) and produces afinite change of momentum. In contrast,some simulations make use of penaltymethods to compute the collisionresponse. With penalty methods, objectsare allowed to become embedded inone another. When the bodies areembedded, they both become affectedby repulsion forces that are proportionalto the level of interpenetration betweenthe bodies. These repulsion forces causeboth bodies to move apart and resolvethe collision. The impulse method isbased on the equations of conservationof momentum and elasticity. It consistsof calculating a simple scalar as a func-tion of the velocity and mass of bothobjects and then using this scalar tomodify the velocities of both entities.The impulse scalar is calculated as

    J = (v1 n + v2 n)(e + 1)(1

    m1+ 1m2

    ) , (3)

    where e is the restitution coefficient, nis the collision normal, m is the objectmass, and v is the object velocity.

    The postcollision velocities of bothobjects are then modified using this scalar

    v1 = v1 + J nm1 v2 = v2 +J nm2

    . (4)

    Note that for the second object, theimpulse is subtracted instead of beingadded to the velocity. This confirms thatequal but opposing forces are appliedto the objects during the collision.

    Linear and angularcollision response

    Linear and angular collision responsewill modify the linear and angular veloci-ties of the VE objects. Characteristic equa-tions for this type of collision response

    are the same as they were for the linearcollision (conservation of momentum,energy) except that the angular velocity,the moment of inertia, and the distancefrom the point of collision to the center ofmass will also affect the momentum ofthe objects. This algorithm uses themomentum of the object computed withthe velocity at the specific point of con-tact, which is dependent on the angularvelocity as well as the relative positioningof the point of contact. The moment of arotating body is defined as

    mvtotal = mvlinear + I ( r), (5)

    where I is the moment of inertia, is theangular velocity, and r is the vector fromcenter of mass to collision point.

    The impulse method is used onceagain to bring the number of arithmeticoperations to a minimum. The equa-tions of conservation of momentum andelasticity, used in conjunction with thecomplete momentum formula, createthe complete version of the impulsemethod as shown in

    J =(v1 n + v2 n)(e + 1)


    + 1m2 +(


    + (r2n)r2I2)



    The impulse ( J ) will be used tomodify the linear and angular velocitiesof the objects in our virtual environ-

    ment. Once again, the impulse will beadded to the first object but subtractedfrom the second object (7), (8) sinceboth bodies receive opposing forces

    v1 = v1 + J nm1v2 = v2 + J nm2 (7)

    1 = 1 + J(r1 n)I12 = 2 J(r2 n)I2 . (8)

    ApplicabilityVirtual reality applications used in

    domains such as medicine and entertain-ment benefit greatly from more accuraterepresentations of real-world phenomena;e.g., the aerospace industry can buildentire aircraft without requiring a physicalprototype. Instead, a virtual model is builtand undergoes tests in physically drivenVEs at a fraction of the cost of building aprototype. By using characteristic equa-tions from the environment, the reactionsof the objects are not only much morebelievable but custom programming isnot needed for any single case.

    Read more about it D. Bourg, Physics for Game

    Developers. OReilly, Farnham, 2002. Delannoy, Petriu, and Wide,

    Mechanics modeling for virtual interactiveenvironments, in Proc. HAVE 2003, 2003,pp. 5559.

    K. Kaiser, 3D Collision Detection,Game Programming Gems. Rockland:Charles River Media, 2000, pp. 390402.

    N. Bobic, Advanced CollisionDetection Techniuqes, [Online]. Available:h t tp : / /www.gamas tu ra . com/ fea -tures/20000330/bocic_01.html

    About the authorJean-Christian Delannoy is a gradu-

    ate student in electrical engineering atthe University of Ottawa, Canada.

    Fig. 3 Three-dimensional model withoriented bounding box (OBB)

    Fig. 4 Sphere collision plane



    Collision Plane


View more >