(Ebook) Mobile 3D Graphics: with OpenGL ES and M3G by Kari Pulli, Tomi Aarnio, Ville Miettinen, Kimmo Roimela, Jani Vaarala ISBN 9780123737274, 0123737273
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offi ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our web site at www.wiley.com.
The right of the author to be identifi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
978-1-119-97591-5
978-1-119-97626-4 (ebk)
978-1-119-97627-1 (ebk)
978-1-119-97628-8 (ebk)
A catalogue record for this book is available from the British Library.
ABOUT THE AUTHOR
ROMAIN MARUCCHI-FOINO is the original author and founder of the popular mobile game engine SIO2 (http://sio2interactive.com). Formerly a game engine developer, Romain has dedicated his efforts to build a state-of-the-art game engine for mobile devices using OpenGL ES since the arrival of the iPhone. He is currently working as the lead 3D programmer for sio2interactive .com, the offi cial developer of the SIO2 Engine, which powers thousands of games and 3D applications throughout the App Store and the Android market. His experience in the mobile game industry has led him to contribute his work to many online communities, publications, and blogs.
ABOUT THE TECHNICAL EDITOR
EFFIE C. LEE is a self-employed game and graphics designer who has been working in the game industry for the last 4 years. With a bachelor’s degree in Computer Science and a real passion for electronic games and computer graphics, she has been involved in multiple mobile game productions. With her wide range of knowledge in the game development process, she has been professionally working as a 2D and 3D graphics designer, game programmer (scripting), and web designer for game sites, as well as managing game quality assurance and localization. If you would like to reach her, send an email to effiecl@gmail.com.
WELCOME TO Game and Graphics Programming for iOS and Android with OpenGL ES 2.0. This book is not your usual “OpenGL Hello Triangle” book — it’s not meant to explain the “why” (Google is there for that), but rather, to show you the “how.” This book will strictly teach you what works and what doesn’t when it comes to game and graphics programming.
Using more than 50 unique tutorials (which also include some full game frameworks), this book adopts a straightforward practical approach (probably never seen before) that only focuses on what you need to learn to insure that you will be able to create a game.
You will learn all the necessary elements in order to create a full-fledged game with rich 3D graphics. If you are looking for an aggressive teaching method that enables you to quickly move forward to create your dream game, this book is for you!
WHO THIS BOOK IS FOR
Be aware that this is not a beginner book. It is an intermediate-level book that assumes you are familiar with linear algebra (matrices, vectors, and quaternions), you have a strong C/C++ programming background, you have at least touched base with OpenGL or OpenGL ES, and you basically know how computer graphics work in general.
If you have this necessary knowledge, and want to make lightning-fast progress in game and graphics programming, then you have found the right publication. This book is written for people who want to learn the hardcore stuff fast in order to be able to create and push a full-fledged game on the App Store and the Android Market.
WHAT THIS BOOK COVERS
Basically everything you need to know in order to create a full game is included in this book. You will learn about all aspects of creating a game, such as loading 3D geometries and textures; how to handle materials, shaders, sounds, cameras, clipping, physics, AI, pathfi nding, skeletal animations; and a lot more.
By the end of this book you will be able to apply the knowledge you’ve learned and combine the different tutorials you’ve completed to create your own state-of-the-art game.
HOW THIS BOOK IS STRUCTURED
This book is structured in such a way that pretty much all chapters depend on each other. Each chapter shows you progressively how to master the necessary techniques to be able to handle the next chapter.
Here is a list of all the chapters and what will be covered in each of them:
Chapter 1, “Getting Started” — You will learn how to set up your development environment, download this book’s SDK, import and re-compile the tutorials, and deal with the template project that you will be using throughout this publication.
Chapter 2, “Setting Up Your Graphic Projections” — Since you have a running template, I will show you how to set up the necessary projection matrix to be able to handle 2D, 2.5D, or 3D. You will also learn how to draw simple geometry onscreen and handle a camera matrix.
Chapter 3, “Dealing with Complex Geometry” — You will create a Wavefront OBJ viewer that will allow you to learn how to load complex geometry from disk. You will also learn how to load and create textures, deal with basic lighting, and respond to touch events.
Chapter 4, “Building a Scene” — This chapter will extend the knowledge that you’ve learned in Chapter 3 and will explain how to handle a more complex scene. You will learn about drawing sequences and how to create reusable shaders.
Chapter 5, “Optimization” — In this chapter, I will show you techniques that will allow you to optimize the performance of your drawing. You will touch base with texture compression and shader optimization, and learn how to convert triangles to triangle strips as well as other tips and tricks to get better FPS.
Chapter 6, “Real-Time Physics” — Since you will know by now how to handle a scene properly, this chapter is about adding real-time physics behaviors to your scene using Bullet. I will show you how to create a physical world and add physical entities to it. You will then learn how to handle in code different techniques that will allow you to add logic upon collision callbacks or based on the contact points between two or more physical entities.
Chapter 7, “Camera” — This chapter will focus entirely on cameras. You will learn to build frustum planes and will be able to determine the visibility of each object of your scene in the field of view of a camera. I will then show you how to implement multiple types of cameras, including a full-fl edged fi rst- and third-person camera with collision, ready to be used in your own apps.
Chapter 8, “Pathfinding” — Artificial intelligence (AI) and pathfinding will play an important role inside your games, and that’s what this chapter is all about. You will learn how to use the Recast and Detour libraries to build a navigation mesh and have entities moving automatically in the scene. In this chapter, I will also demonstrate how to use True Type Font to generate a font texture and draw dynamic text onscreen.
Chapter 9, “Audio and Other Cool Game Programming Stuff” — This one is all about audio using OpenAL. In this chapter, you will learn how to load OGG Vorbis sound fi les and either stream them from memory in real time or statically store them in audio memory. I will also introduce how to create 3D positional and ambient sound sources and will touch base on how to use the accelerometer, along with how to animate textures and create other miscellaneous effects.
Random
documents with unrelated content Scribd suggests to you:
Wold you please to hear of a sang of dule, Of yea sad chance and pittifow case, Makes the peur man powt through many a pule, And leuk on mony an unkend face?
Between the Yule but and the Pasch, In a private place, where as I lay, I heard ane sigh, and cry, alas! What shall I outher dea or say?
A man that’s born of a middle-yeard wight, For wealth or pelth can no be secure; For he may have enough at night, And the next morn he may be fow peur.
I speak this by a Northumberland man, The proverb’s true proves by himself; Since the horse-couping he began, He had great cause to crack of wealth.
Of galloways he was well stockt, What some part first, what some part last; But I’ll no speak much to his praise, For some of them gat o’re lang a fast.
Some of them gat a shrowish cast, Which was nae teaken of much pelth; But yet he hopes, if life dea last, To see the day to crack of welth.
But aye the warst cast still comes last, He had nae geuds left but a Mear, There was mair diseases did her attend Nor I can name in half a year.
If Markham he himself was here, A f f i lth h h b
A famous farrier although he be, It wad set aw his wits astear
To reckon her diseases in their degree.
But her sicknesses we’ll set aside, Now tauk we of the peur man’s cost, And how she lev’d, and how she died, And how his labour aw was lost.
In the winter-time she took a hoast, And aw whilk while she was noe weell; But yet her stomach ne’er was lost, Although she never had her heal.
Now for her feud she went so yare, An the fiend had been a truss of hey, She wad a swallowed him and mickle mare, Bequeen the night but an the dey.
The peur man cries out Armyes aye, I see that she’s noe like to mend, She beggers me with haver and hey, I wish her some untimous end.
Nae sooner pray’d, but as soon heard, She touck a fawing down behind, She wad a thousand men a scar’d, To have felt her how she fill’d the wind.
Her master he went out at night, Of whilk he had oft mickle need, He left her neane her bed to right, Nor neane for to had up her head.
Next day when he came to the town, He ran to see his mear with speed, He thought she had fawn in a swoon, But when he try’d she was cald dead
But when he try d she was cald dead.
It’s ever alas! but what remeed, Had she play’d me this at Michaelmas, It wad a studden me in geud steed, And sav’d me both yeats, hay and grass.
There’s ne’er an elf in aw the town, That hardly weell can say his creed, But he will swear a solemn oath, Crack o’ wealth Ecky’s mear cau’d dead.
Lad, wilt thou for Hob Trumble run? I ken he will come at my need; That seun he may take off her skin, For I mun leeve though she be dead.
Now straight he came with knife in hand, He flead her fra the top to th’ tail, He left nae mare skin on her aw Then wad been a heudin to a flail.
He seld her haill hide for a groat, So far I let you understand, And what he did weed he may well weet, For he bought neither house nor land.
Now have I cassen away my care, And hope to live to get another; And night and day shall be my prayer, The fiend gae down the loaning with her.
Now shall I draw it near an end, And tauk nae mare of her at least, But hoping none for to offend, You shall hear part of her funeral feast.
To her resorted mony a beak,
o e eso ted o y a bea , And birds of sundry sorts of hue; There was three hundred at the least, You may believe it to be true.
Sir Ingram Corby he came first there, With his fair lady clad in black, And with him swarms there did appear Of piots hopping at his back.
The carrion craw she was not slack, Aw cled into her mourning weed, With her resorted mony a mack Of greedy kite and hungry gleede.
When they were aw conven’d compleat, And every yean had taen their place; So rudely they fell tea their meat, But nane thought on to say the grace.
Some rip’d her ribs, some pluck’d her face, Nae bit of her was to be seen; Sir Ingram Corby in that place, Himself he pick’d out baith her eyne.
But wait ye what an a chance befel, When they were at this jolly chear, Sir William Bark, I can you tell, He unexpected lighted there.
Put aw the feasters in sike a fear, Some hopt away, some flew aside, There was not ane durst come him near, Nay not sir Corby, nor his bride.
He came not with a single side, For mony a tike did him attend, I wait he was no puft we pride,
As you shall hear before I end.
See rudely they fell to the meat, But napkin, trencher, salt, or knife; Some to the head, some to the feet, While banes geud bare there was na strife.
In came there a tike, they cau’d him Grim, Sea greedily he did her gripe, But he rave out her belly-rim, And aw her puddings he made pipe.
Her lights, her liver, but an her tripe, They lay all trailing upon the green; They were aw gane with a sudden wipe, Not any of them was to be seen.
But suddenly begeud a feast, And after that begeud a fray; The tikes that were baith weak and least, They carried aw the bats away.
And they that were of the weaker sort, They harl’d her through the paddock-peul, They leugh, and said it was good sport, When they had drest her like a feule.
Thus have you heard of Ecky’s mear, How pitifully she made her end; I write unto you far and near, Who says her death is no well penn’d.
I leave it to yoursel’s to mend, That chance the peur man need again; If it be ill penn’d it is well kend, I got as little for my ‘pain.’
Old Janus advances all cloathed in white, And his long-smother’d tempests sends forth; On the mountains cold bosom, as black as the night, Sinks the dark rolling clouds of the north.
In their winding sheets rob’d are the hills and the dales, And the verdure no longer is seen; Save where the slow streams wind their way thro’ the vales, With their margins besprinkled with green.
On the stump of a thorn, with his bosom of red, See the robin his thankful notes raise For his crumbs—by his precepts, oh! may I be led To give the All-bounteous due praise.
Hark! the blast sweeps the heath; see the mountain fir bend; Thick tempests obscure the pale sky; The fast-gathering drift on the hedge see descend, And streams of faint lightning flash by.
Yes, Northumbria, thy climate is cold and severe; There winter usurps the blithe spring; And through the wide range of the circling year, Chilling damps to thy bosom will cling.
Yet thy health-giving breeze, be it ever so cold, Knits the nerves of thy children for war; Whose proud speaking eye in the soldier behold, And for whose dauntless heart view the tar.
He bounds o’er thy brooks, and he climbs thy wild rocks, Health and vigour inhales from the breeze; Despising in manhood the tempest’s rude shocks, Fearless quits his dear home for the seas.
Lo! the canvas it swell’d: from the banks of the Tyne, Th l d iftl l
The vessel scuds swiftly along; From his eye independant, see stern valour shine, As he hums a Northumbrian song.
Now the battle-day comes, and far, far from his shore, The squadrons of France meet his eyes; Unaw’d his proud heart, ’mid the cannons’ loud roar, He with Collingwood conquers and dies.
From thy hills, too, at sound of the heart-rousing drum, Thy war breathing soldier retires; In lion-like strength seeks the carnage field’s hum, Fights—blesses thy name—and expires!
Such, such are the heroes in thy vallies rear’d, Such, Northumbria, thy children still be: Proud commerce, from Tyne’s banks in glory uprear’d, To her breast clasps the lords of the sea.
Come forward ye dark rolling clouds of the north, Who shrinks from your blasts but the coward and slave? Ye nerve the bold sons that Northumbria sends forth, To fight for her king on Trafalgar’s proud wave.
January2d,1807.
BOTHWELL.
THOMASWHITTLE.
The author of the five succeeding pieces of poetry, a Northumbrian by birth, and was long resident in the neighbourhood of Cambo, as appears by the following lines taken from his WHIMSICAL LOVE with ANN DOBSON:
“At Cambo, on a fatal day, I chanc’d to see and view This Celia’s face, more fresh than May, When every blossom’s new; Like patient Grissel, at her wheel, Acting the housewife’s part, My spirits in my veins did reel, And love danc’d in my heart.”
As also from the History of Northumberland, (1811) Vol. II, page 221.
“Cambo was the favourite residence of the ingenious and eccentric Thomas Whittle, whose comic productions often beguile the long winter evenings of our rustic Northumbrians. His parents and the place of his birth are unknown. It is believed that he was the natural son of a gentleman of fortune, and that he was called Whittle from the place of his nativity, which some say was in the parish of Shilbottle, and others in the parish of Ovingham.
“Though Whittle was a profligate in his life, and sometimes licentious in his compositions, yet the superior talents he has displayed in his best productions, sufficiently entitle him to our notice in this work. His poems and songs have long been perused by the people of the county with eager admiration and delight, and will
probably be a source of entertainment to many succeeding generations. His Whimsical Love is a master-piece of its kind; and his Poetic Letter to the Razor-setter, his satirical Poem on William Carstairs, and his song called the Mitford Galloway, are replete with wit and humour, and will afford a mental feast to all who have a taste for comic poetry.” The last of which was published during his life, with the following old wood cut, as a head piece to it:
Bidford Galloway.
THE MIDFORD GALLOWAY’s RAMBLE.
BY THOMAS WHITTLE.
To the Tune of, RantingroaringWilly.
The routing the earl of Mar’s forces, Has given their neighbours supplies; They’ve stock’d us with Highlanders horses, Like kileys for madness and size: The whirligig-maker of Midford Has gotten one holds such a stear, He’s had worse work with it, I’ll say for’t Than Ecky e’er had with his mear.
The devil ne’er saw such a gelding As this to be foal’d of a mear; The size ont’s a shame to be teld on, And yet it could skip like a deer; For colour and size (I’m a sinner, I scorn, as the folks say, to slide,) ’Twas just like Hob Trumble’s gimmer, Which he sold for six-pence a side.
It was a confounded bad liver, Like Ferry the piper’s old cat; It ne’er could be brought to behaviour, Though it has got many a bat; It had been so spoil’d in up-bringing, It vext his poor heart every day; Sometimes with biting and flinging, And sometimes with running away.
Perhaps it was brought up a Tory, And knew the poor man for a Whig; But just to make short of the story, I’ll tell you one day what it did: When business came thicker and thicker, And would not admit of delay, As fast as the heels on’t could bicker, It scamper’d right northward away.
O’er rocks, over mountains and ditches, Dike-gutters and hedges it speels; A courser could never keep stretches With it for a large share of heels: From hill unto dale like a fairy, It hurry’d and pranced along, While Geordy was in a quandary, And knew not what way it was gone.
A day or two after, have at it, He north in pursuit on’t took chase, And like a dub-skelper he trotted, To many strange village and place; All Rothbury forest he ranged, From corner to corner like mad, And still he admired and stranged, What vengeance was gone with his pad.
He circled about like a ring-worm, And follow’d the scent of his nose, And from Heslyhurst unto Brinkburn, With Fortune the clothier he goes. To honest Tom Fawdon’s the fuller, The rattle-brain’d roisters both went, Tho’ they made the gelding their colour, Another thing was their intent.
Tom Fawdon soon knew what they wanted, And straightway the table was set, With bread, butter and cheese it was planted, And good ale, as well as good meat; Their grace took but little inditing, ’Twas short and they had it by heart; And they took as little inviting, But strove who should have the fore-start.
They used no bashful dissembling
They used no bashful dissembling, But to in a passion did fall, The dishes did by them stand trembling, Their mercy appeared so small: The butter, the cheese, and the bannocks, Dissolved like snow in a fresh, And still as they stuck in their stomachs, With liquor they did them down wash.
The Dutch, nor the Welsh, nor wight Wallace, Did ever like them show their spleen, The cheese bore the marks of their malice, Their knives and their teeth were so keen. Two stone they destroyed, shame be’n them, And pour’d down their liquor like spouts, Their guts to hold what they put in them, Were drest like a pair of strait boots.
With bellies top-full to the rigging, I leave them to settle a bit, ’Till making good use of the midding, ‘Do’ bring them unto a right set. Now come we to speak of the gelding, Who knowing that he did offend, Stay’d two or three days about Weldon, To make justice Lisle stand his friend.
He after that grew so unlucky, On mischief and ill he was bent, He prov’d a right North-country jockey, Still cheating where ever he went. At many men’s charges he dined, But never ask’d what was arrear; Yet no man could get him confined, So slily himself he did clear.
The town of Longframlington further
Can give an account what he is, He came within acting of murder, As near as a horse could to miss; For unto a house he went scudding, And seeing a child all alone, If Providence had not withstood him, He’d struck it as dead as a stone.
The rest of his acts are recorded, ’Tis nonsense to mention them here; I’ll go back and fetch Geordy forward, He’s tarri’d too long I do fear! From Brinkburn he started and held on, Directly to Framlington town, And then to the miller’s at Weldon, He back o’er the hill tumbled down.
Not finding the thing that he wanted, Unto Hedleywood he did trot, He was tost like a dog in a blanket, O’er Coquet and back in the boat: All Framlington fields he sought over, And from spot to spot he did run, For fear the grass chanced to cover His pad, as it once did Tom Thumb.
Then up to John Alders he drabbeth, And there all the night did repose, And then, the next day being Sabbath, Away he to Whittingham goes; Where he to revenge the miscarriage Of his little scatter-brain’d nag, He went to the clerk of the parish, To get him expos’d for a vague.
The clerk he soon set up his cropping, And made a great bustle and stear;