the reality of virtual environments

3
AUGUST/SEPTEMBER 2005 37 0278-6648/05/$20.00 © 2005 IEEE Virtual environments—do they really live up to expectations and reality tests? There has been an increased interest in virtual reality applications thanks to the amazing advances in graphics technol- ogy and computing power. Highly detailed three-dimensional (3-D) com- puter models and environ- ments are commonly used in design, manufacturing, simu- lation, and entertainment. These virtual environ- ments (VEs) are often successful at appearing realistic when time remains still, but as the mobile objects are set into motion and interact with their surroundings, the move- ments often appear unnatural. In many prerendered VEs used for entertainment pur- poses, all of the object’s motions must be handmade by 3-D animators in a process that is time consuming and lacks strict realism. In other VEs such as the first genera- tion of 3-D video games, objects are modeled by their bounding space or by a sphere that surrounds all of the 3-D model’s vertices. In these cases, the motions are often quite linear, and the collision response algo- rithms are quite simplistic; some even revert to stopping an object’s motion when it collides with the environment. These techniques are much too mini- mal and greatly reduce the level of realism in VEs. Letting animations follow their own physics is quickly becoming the new recipe for realism as new techniques for modeling and animation based on the laws of classical mechanics are emerg- ing in all virtual reality applications. Forces and friction In a VE, just as in the real world, forces affect bodies in accordance with the second law of Newton. The sum of all forces through the center of mass of a body equals the mass multiplied by the linear acceleration, and the sum of all torques applied to the object equals the product of the moment of inertia and the angular acceleration. Both the linear and angular velocities will be modified when- ever a force is applied on a line that does not intersect the center of mass since torque will be generated. The object will not only start moving away but it will also start turning on a certain axis. Forces applied to an object are first decomposed into the component that is applied direct- ly through the center of mass and the remainder that causes torque. Com- ponents through the center of mass mod- ify the linear velocity whereas the remainders will modify the angular velocity of the object in question. These principles can be programmati- cally applied to the virtual world efficient- ly. During every program loop, whenever a force is applied to an object it is decom- posed into the component that modifies the linear velocity and the component that modifies the angular velocity; these forces are added to two resulting vectors repre- senting the sum of all the linear forces and the sum of all angular forces on the object. At the end of each program loop when all of the forces have been added to all of the objects in the VE, the total linear and angular forces are used to obtain the linear and angular accelerations of the object in question with Newton’s laws. These results are used with the elapsed time since the last loop to obtain the updated velocities. The elapsed time must be used in this process otherwise the sim- ulation would be frame-rate dependent, i.e., the simulation would run faster on a stronger computer capable of executing the program loop more times per second. Figure 1 shows pseudocode of how forces are handled in a typical program loop. This technique is excellent for realis- tically simulating all kinds of forces, such as natural and noninteractive forces like gravity. This technique is also excellent for managing interactive forces that are controlled by a user or artificial intel- ligence to get an object from A to B. Realistic motion will be the result of thruster forces that are applied to various prede- termined points on the model with specific mag- nitudes and orientations. The motion is usually also affected by friction coeffi- cients on the object that are proportional to the speed of the entity. A user can control the model by various keys, which will enable specific thrusters when pressed. In most situations there will be a main thruster that has a large magnitude and is always pointing towards the front of the model through the center of mass. This force is used to make the model advance without changing the current orientation. There are other forces that have no compo- nent through the center of mass; this means that enabling any of these thrusters won’t be directly responsible for any shift in the position of the model but will only modify the orienta- tion of the object. Usually there are six thrusters to allow rotation around any of the axes in the clockwise and coun- terclockwise directions (Fig. 2). By combining these forces, the user can rotate the ship around any one of its three relative axes (right, top, front) and gains a fully 3-D range of motions. Collision detection and response Two main equations are used to deter- mine post-collision velocities of any The Reality of Virtual Environments Jean-Christian Delannoy ©DIGITAL STOCK CORP.

Upload: j-c

Post on 28-Feb-2017

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: The reality of virtual environments

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

Virtual environments—do 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 object’smotions 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 model’s vertices. Inthese cases, the motions are often quitelinear, and the collision response algo-rithms are quite simplistic; some evenrevert to stopping an object’s 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 Newton’s 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 won’t 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

©DIGITAL STOCK CORP.

Page 2: The reality of virtual environments

38 IEEE POTENTIALS

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

m1�v−1 + m2�v−

2 = m1�v+1 + m2�v+

2 s. (1)

The elasticity of collision law accountsfor 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 don’tchange shape at all. The simulation relieson an empirical relation to quantify theenergy lost during the impact. It’s 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 )

(�v−1 − �v−

2 ). (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 won’t 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 model’s

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 isn’t 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 A’s 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);

Object.ApplyForces();

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

TopFront

Right

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.

Page 3: The reality of virtual environments

AUGUST/SEPTEMBER 2005 39

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+ 1

m2

) , (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

m�vtotal = m�vlinear + 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)

1m1

+ 1m2

+(

(�r1∧�n)∧�r1I1

+ (�r2∧�n)∧�r2I2

)· �n

.

(6)

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 �nm1

�v2 = �v2 + J �nm2

(7)

�ω1 = �ω1 + J(�r1 ∧ �n)

I1

�ω2 = �ω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. O’Reilly, Farnham, 2002.• Delannoy, Petriu, and Wide,

“Mechanics modeling for virtual interactiveenvironments,” in Proc. HAVE 2003, 2003,pp. 55–59.

• K. Kaiser, 3D Collision Detection,Game Programming Gems. Rockland:Charles River Media, 2000, pp. 390–402.

• 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

Normal

Collision Plane