www.it-ebooks.info Irrlicht 1.7 Realtime 3D Engine Beginner's Guide Create complete 2D and 3D applicaons with this cross-plaorm, high performance engine Aung Sithu Kyaw Johannes Stein BIRMINGHAM - MUMBAI www.it-ebooks.info Irrlicht 1.7 Realtime 3D Engine Beginner's Guide Copyright © 2011 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmied in any form or by any means, without the prior wrien permission of the publisher, except in the case of brief quotaons embedded in crical arcles or reviews. Every eort has been made in the preparaon of this book to ensure the accuracy of the informaon presented. However, the informaon contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark informaon about all of the companies and products menoned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this informaon. First published: October 2011 Producon Reference: 1181011 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84951-398-2 www.packtpub.com Cover Image by Asher Wishkerman (a.wishkerman@mpic.de) www.it-ebooks.info Credits Authors Aung Sithu Kyaw Johannes Stein Reviewers Chrisan Stehno Nikolaus Gebhardt Acquision Editor Usha Iyer Development Editor Maitreya Bhakal Technical Editors Joyslita D'Souza Snehal Gawde Project Coordinator Michelle Quadros Proofreader Linda Morris Indexer Hemangini Bari Graphics Geetanjali Sawant Producon Coordinator Alwin Roy Cover Work Alwin Roy www.it-ebooks.info About the Authors Aung Sithu Kyaw is originally from Myanmar (Burma). He has been a developer in the soware development industry for over seven years and has a great passion for graphics programming, creang video games, wring, and sharing knowledge with others. He holds a M.Sc (Digital Media Technology) from Nanyang Technological University (NTU), Singapore. Aung is currently the CEO of a digital media company, Rival Edge Pte Ltd, Singapore, which he cofounded in 2011 with two other engineers. Visit http://rivaledge.sg for more informaon. He can be followed on twier @aungsithu and his LinkedIn prole http://www. linkedin.com/in/aungsithu . www.it-ebooks.info Acknowledgement It took me over eight months to reach this point wring an acknowledgment secon. It was really an excing journey. I owe these people in my endeavour to write this book and I'd like to take this opportunity to express my gratude. Thanks to Nikolaus 'niko' Gebhardt and Ambiera e.U. for iniang this wonderful Irrlicht engine project and making it open-source, sharing with the community, Chrisan Stenho for reviewing the book and giving lots of useful feedback and all the folks from the Irrlicht forum. And the following people from Packt Publishing; Newton Sequeira (Author Relaon) for contacng me about this opportunity to write a book on Irrlicht, Usha (Acquision Editor), Maitreya Bhakal (Development Editor), and Ashwin Shey (Project Manager) for taking this project into reality, Michelle Quadros (Project Coordinator) for working and coordinang with me along the way, chapter-by-chapter, and Snehal Gawde (Technical Editor) for making sure everything ts together. I'd like to thank my big brother and my parents, who've been supporng me all these years. Without all of your support I wouldn't have been here today. And nally a big thank to my wife, Muriel. If she hadn't let me sit in front of my computer for hours, late nights, and weekends, wring this book, it wouldn't have been possible. Thank you for all your support. I love you. www.it-ebooks.info Johannes Stein is an independent game developer and former student of the university of Augsburg, Germany. He started showing an interest in computer science at the early age of twelve and has expanded his knowledge ever since. Aer learning Visual Basic and Delphi, he got into C/C++ and C#, while he learned Objecve-C and JavaScript, in the last few years. He specializes on cross-plaorm development, which means soware that runs on Windows, Linux, and Mac OS X for example. Apart from cross-plaorm development, he has developed mobile games and web applicaons using the latest technologies such as HTML5 and CSS3. On several occasions, he worked as a freelance journalist and reported from yearly events such as the gamescom in Cologne. Working on a book was a completely new and excing experience for me and rst of all I would like to thank everyone who had the paence to put up with me and helped me during the process. I would like to thank my parents who helped trying to movate me when I was feeling overwhelmed and frustrated. A special thanks goes to my father. I would also like to thank Nikolaus Gebhardt and Chrisan Stehno, who have not only been technical reviewers of this book, but shaped the Irrlicht engine into what it is now. And last, but not least I would like to thank everyone at Packt Publishing, who made this book possible and a simple "Thank you" does not cover how grateful I am. www.it-ebooks.info About the Reviewer Chrisan Stehno has been in touch with Irrlicht since 2004. Being a researcher at that me, he led a group of students to develop a 3D visualizaon tool. Since 2006, he has been part of the development team. Today he is responsible for the general coordinaon of the project and its development. When it comes down to coding, he likes working on the video drivers, but does the bug hunng in all parts of the engine. In real life, Chrisan is married (longer with his wife than with Irrlicht) and has two children. He is the founder and general manager of a small company, developing embedded systems and soware for industrial use. www.it-ebooks.info www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt oers eBook versions of every book published, with PDF and ePub les available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collecon of free technical arcles, sign up for a range of free newsleers and receive exclusive discounts and oers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant soluons to your IT quesons? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's enre library of books. Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine enrely free books. Simply use your login credenals for immediate access. www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Installing Irrlicht 7 Irrlicht license 7 System requirements 8 Time for acon – downloading Irrlicht 9 Contents of the Irrlicht package 10 bin folder 10 doc folder 10 examples folder 11 lib folder 11 include folder 11 media folder 11 source folder 11 tools folder 11 Text les 11 Irrlicht on Windows with Visual Studio 12 Time for acon – adding le references 12 Project-specic conguraon 14 Compiling Irrlicht as a dynamic library using Visual Studio 15 For 6t4-bit Windows 15 Installing Microso's DirectX SDK 15 Time for acon – compiling Irrlicht as a dynamic library 16 Time for acon – compiling the Irrlicht dynamic library with modicaons 16 Addional conguraons 18 Building an example with Visual Studio 18 Time for acon – building an Irrlicht example 18 Using Irrlicht with CodeBlocks 20 Time for acon – creang an applicaon using the CodeBlocks wizard 20 CodeBlocks under Linux 24 www.it-ebooks.info [...]... Using Nodes—The Basic Objects of the Irrlicht 3D Engine Chapter 12, Using Shaders in Irrlicht [ vi ] www.it-ebooks.info 222 224 224 225 225 226 228 229 233 234 236 237 238 239 239 240 241 242 242 242 243 245 245 245 246 246 246 Preface Irrlicht 1.7 Realtime 3D Engine Beginner's Guide will teach you to master all that is required to create 2D and 3D applications using Irrlicht, beginning right from installation,... Installing Irrlicht This chapter will explain what we need to consider when we take our first step with the Irrlicht 3D graphics engine In this chapter, we will: Learn about how the Irrlicht library is structured Set up Irrlicht on Windows using either Visual Studio or CodeBlocks Set up Irrlicht on Linux using the command-line Set up Irrlicht on Mac OS X using XCode Compile the Irrlicht. .. should also have a graphic card with 3D capabilities with supports for DirectX and OpenGL We'll start with setting up Irrlicht on different platforms, so you don't need to have installed Irrlicht on your computer Who this book is for If you have C++ skills and are interested in learning Irrlicht to create 2D /3D applications, this book is for you Absolutely no knowledge of Irrlicht is necessary for you to... recommended to give credit to the Irrlicht development team in your released application, although this is not necessary with an exception of JPEG support Irrlicht uses libjpeg for JPEG support and you must credit JPEG group in your release application, according to their license requirement www.it-ebooks.info Installing Irrlicht System requirements While the Irrlicht 3D graphics engine should work on pretty... when you actually try to set up Irrlicht on different platforms and development environments Time for action – downloading Irrlicht The first step is to download Irrlicht from their official homepage As of the release of this book the latest version of Irrlicht was 1.7. 2 The examples in this book should work fine for that version and above Now, we are going to download Irrlicht and take a look at what... folder The directory lib contains the Irrlicht library and the files that are needed to work with the Irrlicht library Precompiled Irrlicht library files are stored in this directory so that the application linking to Irrlicht doesn't need to recompile the whole engine every time include folder This folder contains all header files that are necessary to connect with the Irrlicht library itself media folder... other data needed to run the examples of the Irrlicht engine Take a note that some of these assets are copyrighted, you should seek further permissions if you plan to use it in commercial applications source folder The folder source contains the complete source code of the Irrlicht engine I will elaborate on that part when I explain how to build the Irrlicht engine from source tools folder As the name... to use DirectX to compile Irrlicht [ 15 ] www.it-ebooks.info Installing Irrlicht Time for action – compiling Irrlicht as a dynamic library Let's get started with compiling Irrlicht as a dynamic library: 1 Open the source folder and open the sub-folder Irrlicht 2 Open the solution file corresponding to your Visual Studio version: If you are using Visual Studio 2003 then open Irrlicht7 .1.sln, if you... DirectX 8 in the Irrlicht, follow these instructions to rebuild the library: Time for action – compiling the Irrlicht dynamic library with modifications Let's recompile the Irrlicht library without DirectX 8: 1 Open the source folder and open the sub-folder Irrlicht 2 Open the solution file corresponding to your Visual Studio version: If you are using Visual Studio 2003 then open Irrlicht7 .1.sln,... load game-related data files such as player save files Chapter 12, Using Shaders in Irrlicht, introduces how the graphics rendering pipeline works and practical usage of shaders in Irrlicht The Appendix, Deploying an Irrlicht Application, explains the procedures and essential dependencies to be included while packaging an Irrlicht application for different platforms such as Windows, Mac, or Linux What . 10 bin folder 10 doc folder 10 examples folder 11 lib folder 11 include folder 11 media folder 11 source folder 11 tools folder 11 Text les 11 Irrlicht on. nodes 13 5 Fly circle 13 6 Fly straight 13 7 Follow spline 13 7 Rotaon 13 7 Delete 13 7 Texture 13 7 Collision response 13 7 Adding a custom scene node 13 8 Time