Book Image

Irrlicht 1.7 Realtime 3D Engine Beginner's Guide

By : Johannes Stein, Aung Sithu Kyaw
Book Image

Irrlicht 1.7 Realtime 3D Engine Beginner's Guide

By: Johannes Stein, Aung Sithu Kyaw

Overview of this book

<p>The Irrlicht Engine is a cross-platform high-performance real-time 3D engine written in C++. It features a powerful high-level API for creating complete 3D and 2D applications such as games or scientific visualizations.<br /><br />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 and proceeding step-by-step to deployment.<br /><br />Beginning with installation, this book guides you through creating a basic template application, followed by meshes, overlays, and UI. You will then scan through data types, nodes, scenes, camera, lights, and particle systems. Finally, you will learn about some advanced concepts such as handling data, files, and shaders, followed by the last stage – deployment.</p>
Table of Contents (21 chapters)
Irrlicht 1.7 Realtime 3D Engine
Credits
About the Authors
Acknowledgement
About the Reviewer
www.PacktPub.com
Preface

Time for action - reading specific data types from an XML file


irrXML has some helper methods to read the attribute values of specific data types from the XML. These methods basically do fast conversion between string and other numeric types such as integers and floats. Let's see how we can take advantage of those methods:

  1. 1. First, let's prepare an XML file something as follows:

    <?xml version="1.0"?>
    <player name="Aung Sithu" level="9" xp="900" speed="0.05" />
    
  2. 2. Then add the following code to your main() function after creating the Irrlicht device:

    IFileSystem* fs = irrDevice->getFileSystem();
    IXMLReader* xml = fs->createXMLReader("player_data.xml");
    if(!xml)
    return 1;
    stringc playerName = "Player: ";
    int level = 0;
    int xp = 0;
    float speed = 0;
    cout << endl;
    while(xml && xml->read())
    {
    switch(xml->getNodeType())
    {
    case EXN_ELEMENT:
    {
    stringc nodeName= xml->getNodeName();
    if (nodeName.equals_ignore_case("player"))
    {
    playerName.append(xml->getAttributeValue...