Chapter 14 Simulation, Graphics, Gaming and Other Applications Chapter Goals – THE BIG SLICES •Models and Simulation •Computational Biology •(Complex) Computer Graphics •Computer Gaming 2 Chapter Goals •Models and Simulation • • • • • Complex Systems Continuous and Discrete simulation Object-oriented design and building models Queuing systems Weather and Seismic models 3 Chapter Goals •Computational Biology • • • • Bioinformatics Computational Biomodeling Protein Modeling Molecular Modeling 4 Chapter Goals •Computer Graphics • • • • • The CREATION of complex images CAD Fractal and Other Techniques Light and Rendering Movement 5 Chapter Goals •Computer Gaming • The LAYERS • Design and Development • Game Programming 6 Complexity! • Some real-world systems are complicated • We want to model complex systems to: – better understand them – predict the future 14-7 What is a Model? • An Abstraction of a Real World System – A representation of the objects or quantities within the system (Noun, the Data) – and the rules that govern the interactions between them (Verb, the Code & Algorithms) – Systems that are best suited to being simulated are dynamic, interactive, and complicated 14-8 What Is Simulation? • Simulation is RUNNING a model to PREDICT the results of experimental CHANGES in the system • Doing “What If” analysis “What happens if I change this? “What happens if I don’t?” 14-9 Kinds of Models 13-10 Kinds of Models • There are 2 Big Slices: –Discrete Models –Continuous Models 13-11 Kinds of Models •Discrete event simulation •Made up of entities, attributes, and events – Entity The representation of some object in the real system – Attribute Some characteristic of a particular entity – Event An interaction between entities 12 Air Traffic – A Discrete Model • Air Traffic in USA – Planes are objects – Attributes include speed – Events are planes entering and leaving airspace 14-13 Kinds of Models • Continuous simulation – Treats time as continuous – Expresses changes in terms of a set of differential equations that reflect the relationships among the quantities in the model – Meteorological models falls into this category 14 Hurricanes – A Continuous Model 14-15 A Continuous Models and FEA • Finite Element Analysis (FEA): Dividing a volume of space into small cubes, which contain our quantities of interest • Many Continuous Models Use FEA 14-16 Queuing Systems 13-17 Queuing Systems Queuing system: A particular kind of discrete-event model The system is made up of – Server objects – Clients objects – Queues of clients to be served Please Wait…. 18 Queuing Systems •Can you name at least three queuing systems that you interact with every day? Please wait! 19 Queuing Systems • To construct a queuing model, we must know – The number of events and how they affect the system in order to determine the rules of entity interaction – The number of servers – The distribution of arrival times in order to determine if an entity enters the system – The expected service time in order to determine the duration of an event 20 Queuing Systems •Given a hypothetical service station, what are • the events? • the number of servers? •How can you determine • distribution of arrival time? • expected service time? 21 Meteorological Models 13-22 Weather – A Continuous Model 14-23 Meteorological Models Meteorological models •Models based on the time-dependent partial differential equations of fluid mechanics and thermodynamics •Initial values for the variables are entered from observation, and the equations are solved to define the values of the variables at some later time 24 Meteorological Models How much math does it take to be a meteorologist? 25 Weather – A Continuous Model 14-26 Hurricane Tracking (GFDL) Geophysical and Fluid Dynamics Laboratory Figure 14.2 Improvements in hurricane models 27 Computational Biology 13-28 Computational Biology The application of computer science to problems in biology (or is it the other way around?? ) Encompasses: 29 • bioinformatics • computational biomodeling • molecular modeling • protein structure prediction Computational Biology •Bioinformatics • Discovering and Processing DNA sequences • Human Genome Project and Others 30 Computational Biology •Computational Biomodeling • The simulation of biological systems Knees Cell Wall Protein 31 Cell Metabolism Computational Biology •Protein Structure Modeling • Simulating 3-Dimensional Structure and Function of Protein Molecules 32 Computational Biology •Molecular Modeling • Simulating Structure and Function of Chemical Molecules (usually drug discovery) 33 Graphics 13-34 “Traditional” Graphics •Technical or Engineering Graphics •Originally a language of communication for engineers, designers, and architects •Computer-Aided Design (CAD) •A system that uses computers with advanced graphics hardware and software to create precision drawings or technical illustrations 35 Graphics for Computer Aided Design Figure 14.3 Geometric modeling techniques 36 Simulating Light Ray Tracing The projection of a 3-Dimensional model onto a 2-Dimensional computer screen 37 Simulating Light Illumination model Used to simulate the interaction of light with objects Objects are Shaded Rendered 38 Fractal Techniques 13-39 Modeling Complex Objects What graphics challenges are inherent in natural landscapes ? Figure 14.5 A natural computer generated landscape 40 Fractal Terrain Fractal terrains via Midpoint subdivision (Fractal Mountains) 41 “Cell” Models 13-42 Earth, Wind, Fire and Water •Cell-Based Models • • • • • • Like continuous FEA models Uses quantities and laws from physics “How is a hurricane like a glass of water?” Or a Cloud? Or Fire? Or Smoke? 14-43 Cell Models Figure 14.7 Water pouring into a glass 44 Cell Models Figure 14.8 Cellular automata-based clouds 45 Modeling Complex Objects Cell Models Figure 14.9 A campfire What do clouds, smoke and fire have in common? 46 Gaming 13-47 Computer Gaming • A simulation of a virtual world • Usually based on the rules of our real world • Some rules can be bent • Some rules can be broken • 48 Computer Gaming •Game designers need to know the LAYERS: – – – – Computer graphics Artificial intelligence Human-computer interactions and simulation Software engineering (management of large complex projects) – Computer security – Laws of physics relating to gravity, elasticity, light & sound 49 Creating the Virtual World •Game engine: •A software system within which games can be created (A tool to create games) •Analogous to a compiler (A tool to create programs) •(Similarly, some people write engines, some people write games) 50 A Game Engine Provides •A rendering engine for graphics •A physics engine for collision detection and dynamics •A sound-generating component •A scripting language apart from the code driving the game •Character Animations •Algorithms (e.g., path-finding algorithms) •Artificial intelligence algorithms (NonPlayerCharacters) 51 Game Engine Scene Graphs • Where is your toothbrush? • Where did you park your car? • You use a Scene Graph to find these things in your brain first • A way to store object locations and other data in memory 52 Soft Skills Needed •High Quality Game Design and Development Requires Effective Use of “Soft Skills”: • Effective collaboration with designers, programmers, and artists on various technical ideas throughout entire game design and development process • Flexibility and adaptability as the game design constantly evolves and changes throughout the development and production process 53 Game Programming •After all the design decisions have been finalized, programmers produce the code to create the virtual world of the game •Popular languages include: C++, Java, and C •Some well-established game engineers have created custom languages based on their games, e.g., Epic Game’s UnrealScript for the Unreal Game 54 Game Programming API’s and Platforms •Application Programmers Interface (API): A set of commands used in a programming language to interface with another piece of software •Game Engines provide APIs to help developers with key programming tasks •Game Engines usually target a particular platform such as PC or Xbox or PlayStation, etc 55 Game Programming The “Game Loop” •Coding process begins with the creation of the “game loop” •Game loop is responsible for managing the game world, regardless of any input from the user •For example, the game loop might update enemy movement in the game or check for victory/loss conditions •Basically, the game loop manages the simulation 56 Game Programming Teams and Roles •Large design teams have different programmers focus on different aspects of the game •Thus, you might find yourself working as: – A Junior Engine programmer writing and maintaining code for the game loop or a – A 3D Software Programmer designing and implementing the 3D graphics component or a – A User-Interface Programmer working on the APIs in the game engine – Etc… 57