1.17k likes | 1.19k Views
This article discusses various motion extraction and animation techniques for game instances, including linear motion extraction, composite motion extraction, variable delta extraction, and animation without rendering.
E N D
CSCE 590E Spring 2007 AI By Jijun Tang
Announcements • April 16th/18th: demos • Show progress/difficulties/change of plans • USC Times will have reporters in the class • High school outreach • Anyone can contact their high school admin to arrange direct talks to students • Of course, in SC only
Homework • P 655 questions 1 and 2 • 5 points total • Due April 16th
Motion Extraction • Moving the Game Instance • Linear Motion Extraction • Composite Motion Extraction • Variable Delta Extraction • The Synthetic Root Bone • Animation Without Rendering
Moving the Game Instance • Game instance is where the game thinks the object (character) is • Usually just • pos, orientation and bounding box • Used for everything except rendering • Collision detection • Movement • It’s what the game is! • Must move according to animations
Linear Motion Extraction • Find position on last frame of animation • Subtract position on first frame of animation • Divide by duration • Subtract this motion from animation frames • During animation playback, add this delta velocity to instance position • Animation is preserved and instance moves • Do same for orientation
Composite Motion Extraction • Approximates motion with circular arc • Pre-processing algorithm finds: • Axis of rotation (vector) • Speed of rotation (radians/sec) • Linear speed along arc (metres/sec) • Speed along axis of rotation (metres/sec) • e.g. walking up a spiral staircase
Variable Delta Extraction • Uses root bone motion directly • Sample root bone motion each frame • Find delta from last frame • Apply to instance pos+orn • Root bone is ignored when rendering • Instance pos+orn is the root bone
The Synthetic Root Bone • All three methods use the root bone • But what is the root bone? • Where the character “thinks” they are • Defined by animators and coders • Does not match any physical bone • Can be animated completely independently • Therefore, “synthetic root bone” or SRB
Animation Without Rendering • Not all objects in the world are visible • But all must move according to anims • Make sure motion extraction and replay is independent of rendering • Must run on all objects at all times • Needs to be cheap! • Use LME & CME when possible • VDA when needed for complex animations
Mesh Deformation • Find Bones in World Space • Find Delta from Rest Pose • Deform Vertex Positions • Deform Vertex Normals
Find Delta from Rest Pose • Mesh is created in a pose • Often the “da Vinci man” pose for humans • Called the “rest pose” • Must un-transform by that pose first • Then transform by new pose • Multiply new pose transforms by inverse of rest pose transforms • Inverse of rest pose calculated at mesh load time • Gives “delta” transform for each bone
Deform Vertex Positions • Each vertex has several bones affect it (the number is generally set to <=4). • Vertices each have n bones • n is usually 4 • 4 bone indices • 4 bone weights 0-1 • Weights must sum to 1 • Deformation usually performed on GPU • Delta transforms fed to GPU • Usually stored in “constant” space
Deform Vertex Normals • Normals are important for shading and are done similarly to positions • When transformed, normals must be transformed by the inverse transpose of the transform matrix • Translations are ignored • For pure rotations, inverse(A)=transpose(A) • So inverse(transpose(A)) = A • For scale or shear, they are different • Normals can use fewer bones per vertex • Just one or two is common
Inverse Kinematics • FK & IK • Single Bone IK • Multi-Bone IK • Cyclic Coordinate Descent • Two-Bone IK • IK by Interpolation
Single Bone IK • Orient a bone in given direction • Eyeballs • Cameras • Find desired aim vector • Find current aim vector • Find rotation from one to the other • Cross-product gives axis • Dot-product gives angle • Transform object by that rotation
Multi-Bone IK • One bone must get to a target position • Bone is called the “end effector” • Can move some or all of its parents • May be told which it should move first • Move elbow before moving shoulders • May be given joint constraints • Cannot bend elbow backwards
Two-Bone IK • Direct method, not iterative • Always finds correct solution • If one exists • Allows simple constraints • Knees, elbows • Restricted to two rigid bones with a rotation joint between them • Knees, elbows! • Can be used in a cyclic coordinate descent
IK by Interpolation • Animator supplies multiple poses • Each pose has a reference direction • e.g. direction of aim of gun • Game has a direction to aim in • Blend poses together to achieve it • Source poses can be realistic • As long as interpolation makes sense • Result looks far better than algorithmic IK with simple joint limits
Multiplayer Modes:Event Timing • Turn-Based • Easy to implement • Any connection type • Real-Time • Difficult to implement • Latency sensitive
Real-Time Communications:Peer to Peer vs. Client/Server N = Number of players
Security:Encryption Methods • Keyed • Public Key • Private Key • Ciphers • Message Digest • Certificates • IPSec
Security:Copy Protection • Disk Copy Protection • Costly Mastering, delay copies to ensure first several months’ sale • Invalid/Special Sector Read • Code Sheets • Ask code from a line in a large manual • Watermarking
Privacy • Critical data should be kept secret and strong encrypted: • Real name • Password • Address/phone/email • Billing • Age (especially for minors) • Using public key for transforming user name and password
Artificial Intelligence:Agents, Architecture, and Techniques
Book Material • The book CD has a lot of material in the chapter content • A state machine language for example • Please try it
Artificial Intelligence • Intelligence embodied in a man-made device • Human level AI still unobtainable • The difficulty is comprehension
Game Artificial Intelligence:What is considered Game AI? • Is it any NPC (non-player character) behavior? • A single “if” statement? • Scripted behavior? • Pathfinding? • Animation selection? • Automatically generated environment? • Best shot at a definition of game AI?
Possible Game AIDefinition Inclusive view of game AI: “Game AI is anything that contributes to the perceived intelligence of an entity, regardless of what’s under the hood.”
Goals of anAI Game Programmer Different than academic or defense industry 1. AI must be intelligent, yet purposely flawed 2. AI must have no unintended weaknesses 3. AI must perform within the constraints 4. AI must be configurable by game designers or players 5. AI must not keep the game from shipping
Specialization ofGame AI Developer • No one-size fits all solution to game AI • Results in dramatic specialization • Strategy Games • Battlefield analysis • Long term planning and strategy • First-Person Shooter Games • One-on-one tactical analysis • Intelligent movement at footstep level • Real-Time Strategy games the most demanding, with as many as three full-time AI game programmers
Game Agents • May act as an • Opponent • Ally • Neutral character • Continually loops through the Sense-Think-Act cycle • Optional learning or remembering step
Sense-Think-Act Cycle:Sensing • Agent can have access to perfect information of the game world • May be expensive/difficult to tease out useful info • Game World Information • Complete terrain layout • Location and state of every game object • Location and state of player • But isn’t this cheating???
Sensing:Enforcing Limitations • Human limitations? • Limitations such as • Not knowing about unexplored areas • Not seeing through walls • Not knowing location or state of player • Can only know about things seen, heard, or told about • Must create a sensing model
Sensing:Human Vision Model for Agents • Get a list of all objects or agents; for each: 1. Is it within the viewing distance of the agent? • How far can the agent see? • What does the code look like? 2. Is it within the viewing angle of the agent? • What is the agent’s viewing angle? • What does the code look like? 3. Is it unobscured by the environment? • Most expensive test, so it is purposely last • What does the code look like?
Sensing:Vision Model • Isn’t vision more than just detecting the existence of objects? • What about recognizing interesting terrain features? • What would be interesting to an agent?
Sensing:Human Hearing Model • Humans can hear sounds • Can recognize sounds • Knows what emits each sound • Can sense volume • Indicates distance of sound • Can sense pitch • Sounds muffled through walls have more bass • Can sense location • Where sound is coming from
Sensing:Modeling Hearing • How do you model hearing efficiently? • Do you model how sounds reflect off every surface? • How should an agent know about sounds?
Sensing:Modeling Hearing Efficiently • Event-based approach • When sound is emitted, it alerts interested agents • Use distance and zones to determine how far sound can travel
Sensing:Communication • Agents might talk amongst themselves! • Guards might alert other guards • Agents witness player location and spread the word • Model sensed knowledge through communication • Event-driven when agents within vicinity of each other
Sensing:Reaction Times • Agents shouldn’t see, hear, communicate instantaneously • Players notice! • Build in artificial reaction times • Vision: ¼ to ½ second • Hearing: ¼ to ½ second • Communication: > 2 seconds
Sense-Think-Act Cycle: Thinking • Sensed information gathered • Must process sensed information • Two primary methods • Process using pre-coded expert knowledge • Use search to find an optimal solution
Thinking:Expert Knowledge • Many different systems • Finite-state machines • Production systems • Decision trees • Logical inference • Encoding expert knowledge is appealing because it’s relatively easy • Can ask just the right questions • As simple as if-then statements • Problems with expert knowledge • Not very scalable
Production systems • Consists primarily of a set of rules about behavior • Productions consist of two parts: a sensory precondition (or "IF" statement) and an action (or "THEN") • A production system also contains a database about current state and knowledge, as well as a rule interpreter