Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
28. January 2014

 

Back in August of 2012 we reported in a free PDF made available by Ryan Hawkins called Vertex.  It was a high detail guide to game art from various industry artists… oh, and it was completely free!

Now, Vertex2 has been released!

Photo: VERTEX 2 IS OFFICIALLY OUT!!!!! Share this link with your Facebook friends and please like us if you have not done so yet. We hope that you enjoy the second volume in the VERTEX series.

On our website below please visit the downloads section and download either book one or book two. Both are great reads and are unique to one another content wise. http://artbypapercut.com/

 

Basically, it’s more of the same!  Erm, I think.  Reality is, I haven’t been able to download it, their website is down.  Apparently hosting a large downloadable file on a sub-standard host isn’t a great idea.

 

You can keep trying that link above, or hopefully I will locate a mirror and share it here.  If you have a mirror, let me know and I will post it!  Once you do in fact get a download of the book, if you like it, be sure to like them on their facebook page or consider using the donation link at the end of the book.  Awesome high quality free content is certainly worth rewarding!

Art


10. December 2013

 

So lately I’ve been working on my LibGDX tutorial series and I am certainly a fan of the library.  Java on the other hand, after years of using C#, just seems flawed.  Not that it is a bad language, just that it’s a bit kludgy.  Fortunately there are a number of languages built over top of the Java Virtual Machine, allowing you to make use of most of the Java eco-system, while working in a different language.  Some of the more popular options are Groovy, a scripting language that targets the JVM and Clojure, a functional LISP like language.  I don’t personally want a fully dynamic language ( I like typed languages for large projects ) so Groovy is out, while LISP might as well be Klingon.  I like some functional programming, but my brain just doesn’t work that way… to warped by years of procedural programming.

 

Fortunately there is Scala.

 

I’ve only just started playing with it but I am already impressed.  It’s almost as if someone took all the aspects of Java I dont like and set out to fix them.  Things I like:

  • runs on the Java VM, so can use libraries like LibGDX without issue but still feels familiar
  • type inference.  Feel like a dynamic language while staying dynamically typed.  I miss var from C#!
  • Functional programming lite.  High Order functions.
  • It’s got REPL ( command line programmability ) even if it’s faked.  Great way to learn the language.
  • Everything is an object, one of Java’s biggest warts
  • Pattern matching… it’s like an uber switch statement and looks to be a huge time saver
  • traits and sealed… I think.  Basically a trait is an interface with codability, while sealed allows a class to define which classes can extend it.  It will take some use, but both seem to solve commonly encountered problems, but both may have huge downsides.
  • makes the language much more compact while still feeling like Java.
  • operator overloading.  This was simply a stupid Java mistake.
  • best conditional expression evaluation I have ever seen.  Optional semi colons.

 

I'm still just at the beginner phase, but I have to say I’ve already had a ton of AHAH moments.  There are a few annoyances, at least initially.  For example, I dont like the variable coming after the variable name… there might be a huge win here somewhere, but it feels very unnatural coming from Java. 

 

Anyway, back when I started looking to catch up on Java I looked for a book that taught Java but did so making certain assumptions about the programmers experiences.  For example, I know what a class is, how a loop works, etc…  Sadly I never found such a book.  This time however, for learning Scala, I did.

 

Scala for the Impatient

cover This book is exactly what I was looking for when I was looking for a Java book for experienced programmers.  In the authors own words:

I wrote this book for impatient readers who want to start programming in Scala right away. I assume you know Java, C#, or C++, and I don’t bore you with explaining variables, loops, or classes. I don’t exhaustively list all the features of the language, I don’t lecture you about the superiority of one paradigm over another, and I don’t make you suffer through long and contrived examples. Instead, you will get the information that you need in compact chunks that you can read and review as needed.

From what I have read this is exactly true.  I have no prior Scala experience, but I have never found myself once struggling with any concepts presented in this book.  Nor frankly have I been bored, something I often struggle with for programming books.

I need to make something extremely clear.  If you do not have a solid prior programming foundation in C# or Java ( or possibly C++ ), this is not the book for you!  The book basically covers how Scala deviates from other languages, so if you don't know the fundamentals, you will struggle.  It is also not a language reference.  If you are new to programming or want a language reference, Programming in Scala is probably the book you want.

One other thing I really appreciate about this book is the authors writing style.  It’s an easy read and he has a sense of humour.  Here for example is his tip on operating overloading:

In Java, you cannot overload operators, and the Java designers claimed this is a good thing because it stops you from inventing crazy operators like [email protected]$&* that would make your program impossible to read. Of course, that’s silly; you can make your programs just as hard to read by using crazy method names like qxywz. Scala allows you to define operators, leaving it up to you to use this feature with restraint and good taste.

That paragraph is pretty typical of how the book goes.

So I’m heading off on this Scala adventure in my spare time.  Expect a few related posts here and there as I go.

Programming


12. September 2013

 

So after finishing up my ongoing Blender tutorial series, I intend to take a closer look at LibGDX and hopefully launch a new tutorial series.  This however presented a bit of a challenge to me.  You see, although I have experience with Java, it’s pretty out of date.  Since the release of C#, I’ve done very little work in Java other than some dabbling here and there.  So my knowledge is certainly out of date.  For example, when I last seriously programmed in Java Annotations ( ie @Override ) didn’t exist and the language didn’t yet have generics.

 

Obviously I need to get up to speed with modern Java before I start writing some truly embarrassing code.  This however presented a terrible problem for me.  Most texts are either targeted towards complete beginners or are more advanced and targeted at a very specific domain or technology.  The beginners texts make me want to scratch my eyeballs out, as after a decade of working in C#, and a few years of working in Java before that, reading about what a class is, or what a private variable does is a little…  behind me.  On the other hand, the little tidbits of information I need ( about what’s new ) are buried in these descriptions. 

 

I’ve been looking for an ideal book and I haven’t found one.  Something along the lines of Effective C++ or JavaScript: The Good Parts would be absolutely ideal.  Both of those books present best practices for experienced programmers in the modern usage of each language.  Both are incredible reads and will change the way you program.  Sadly, I haven’t found a Java equivalent yet.  There are a couple books I’ve tried.

 

The first was Java: The Good Parts.  By the title, I was really expecting something like the JavaScript book I mentioned earlier.  I will say, I do recommend this book, but it really isn’t what I am looking for.  The author Jim Waldo has been at Sun ( er, Oracle ) a very long time and has a deep insight into the Java language and how it evolved.  It answers a lot of the “why the hell did they do this???” questions you might have about various language features.  That said, the target audience seems a bit confused, at times covering brutally simple tasks in detail, like it was aimed at a beginner.  Then jumping into a topic at a more advanced level.  Basically this means I have to read through a lot of stuff I already know quite well.   I don’t regret reading it though, again, it gave some pretty good insight behind the curtain of language development.

 

Then I went with Learning Java 4th Edition as it was one of the most up to date releases ( July 2013 ), was reasonably well reviewed on Amazon and Safari and seemed to be partitioned nicely into beginner and more advanced topics.  At the end of the day, I guess I am resolved to have to go through all the beginner stuff to pick up what’s changed.  Oh well I guess.

 

So, to any of you Java developers out there… are there any books along the lines of what I am looking for?  A text that focused on writing modern Java code.  That illustrate what parts of the language are cruft and what various best practices are?  A text aimed at a non-beginner?  If there is a book you recommend, I would love to hear it!.

Programming


12. August 2013

 

So today on Safari Books Online came a book that was a complete flash from my past.  Computer Graphics: Principles and Practices 3rd edition has been released.  What’s so special about this book?

cgpap3

Three things… 

 

First, it was the textbook I used to learn computer graphics a very long time ago.

Second, it was one of the only ( incredibly expensive ) books I had to purchase for school that I actually found valuable.  ( Code Complete was the other book, if you were curious )

Third, it’s one of the only dead tree books I have kept.  I am almost entirely digital these days, so you have to be a good book for me to keep you around, especially given the size of a few of the condos I’ve moved into over time, I’ve gone through a lot of book purges!  When you consider how incredibly out-dated it had become, the world of graphics has changed a great deal since the second edition of the book was released in 1990!  On top of that, all of the code examples where in Pascal, using a library I’d never heard of at the time, or used since.

 

Fortunately with the release of the 3rd edition, I now have one less piece of dead tree fighting for space in my house!  There are a few things to know about this book, it’s has no code for OpenGL or Direct3D, it’s not really about that.  The book actually uses WPF for it’s examples, but don’t worry, the concepts are easily applied elsewhere. The entire point of this book is to teach graphics programming concepts, not really about the implementation.  If you don’t already know one of those APIs, you are going to want to pick up an additional book on your graphics library of choice ( if needed. )  That said, this will make you **understand** what you are doing with either of those graphics libraries.  You will find when reading this book, it doesn’t really matter what programming languages or library you use, you will be able to digest and adapt to your tools of choice without a lot of effort.  This book has been almost completely re-written at this point, and does cover the modern graphics pipeline.

 

What does it cover?  Well, just about everything actually.  That’s why I kept it around all these years.  For example, here is the Table of Contents:

  1. Introduction
  2. Introduction to 2D Graphics Using WPF
  3. An Ancient Renderer Made Modern
  4. A 2D Graphics Test Bed
  5. An Introduction to Human Visual Perception
  6. Introduction to Fixed-Function 3D Graphics and Hierarchical Modeling
  7. Essential Mathematics and the Geometry of 2-Space and 3-Space
  8. A Simple Way to Describe Shape in 2D and 3D
  9. Functions on Meshes
  10. Transformations in Two Dimensions
  11. Transformations in Three Dimensions
  12. A 2D and 3D Transformation Library for Graphics
  13. Camera Specifications and Transformations
  14. Standard Approximations and Representations
  15. Ray Casting and Rasterizations
  16. Survey of Real-Time 3D Graphics Platforms
  17. Image Representation and Manipulation
  18. Images and Signal Processing
  19. Enlarging and Shrinking Images
  20. Textures and Texture Mapping
  21. Interaction Techniques
  22. Splines and Subdivision Curves
  23. Splines and Subdivision Surfaces
  24. Implicit Representations of Shape
  25. Meshes
  26. Light
  27. Materials and Scattering
  28. Color
  29. Light Transport
  30. Probability and Monte Carlo Integration
  31. Computing Solutions to the Rendering Equation: Theoretical Approaches
  32. Rendering in Practice
  33. Shaders
  34. Expressive Rendering
  35. Motion
  36. Visibility Determination
  37. Spatial Data Structures
  38. Modern Graphics Hardware

 

… so as you may be able to tell, this isn’t a short book.  In fact it’s 1264 pages in length, which would be why this isn’t a proper review, I am not done the book.  In fact, it’s one of those book I will probably never read entirely front to back.  Instead I jump in to the areas I need, unless of course I struggle with the concepts being taught, then I tend to read the entire chapter until I’ve gotten the subject down.  Of course, I read chapters from time to time just for something to do.

 

That’s another great part of this book.  I am no math wiz, I have forgotten far too much, so with many pure math texts I struggle.  This is why this book is very good.  It’s not simple by any means, but it doesn’t just throw an equation at you and leave you scratching your head.  Things are introduced in escalating difficulty, but if you have a late high school or first year university math education, you should be OK.

 

The math is fully explained over the course of the book.  If you have trouble parsing out equations, they are explained fairly well in the book including how to decipher them.   The book doesn’t magically make math easy, but it does do an effective job of explaining it, so that even a non-genius can make sense of things.  Here for example is the excerpt on Euler Angles, and is typical of how things are explained:

 

Example taken from book:


 

11.2.2. Euler Angles

Euler angles are a mechanism for creating a rotation through a sequence of three simpler rotations (called roll, pitch, and yaw). This decomposition into three simpler rotations can be done in several ways (yaw first, roll first, etc.); unfortunately, just about every possible way is used in some discipline. You’ll need to get used to the idea that there’s no single correct definition of Euler angles.

The most commonly used definition in graphics describes a rotation by Euler angles (φ, θ, ψ) as a product of three rotations. The matrix M for the rotation is therefore a product of three others:

1

Thus, objects are first rotated by angle φ in the xy-plane, then by angle θ in the zx-plane, and then by angle ψ in the yz-plane. The number φ is called pitch, θ is called yaw, and ψ is called roll. If you imagine yourself flying in an airplane (see Figure 11.1) along the x-axis (with the y-axis pointing upward) there are three direction changes you can make: Turning left or right is called yawing,pointing up or down is called pitching, and rotating about the direction of travel is called rolling.These three are independent in the sense that you can apply any one without the others. You can, of course, also apply them in sequence.

jet

 

Figure 11.1: An airplane that flies along the x-axis can change direction by turning to the left or right (yawing), pointing up or down (pitching), or simply spinning about its axis (rolling).

Writing this out in matrices, we have

2

3

With the proper choice of φ, θ, and ψ, such products represent all possible rotations. To see this, we’ll show how to find φ, θ, and ψ from a rotation matrix M. In other words, having shown how to convert a (φ, θ, ψ) triple to a matrix, we’ll show how to convert a matrix M to a triple (φ′, θ′, ψ′), a triple with the property that if we convert it to a matrix, we’ll get M.

The (1, 3) entry of M, according to Equation 11.14, must be sin θ, so θ is just the arcsine of this entry; the number thus computed will have a non-negative cosine. When cos θ ≠ = 0, the (1, 1) and (1, 2) entries of M are positive multiples of cos φ and – sin φ by the same multiplier; that means φ = atan2(–m21, m11). We can similarly compute ψ from the last entries in the second and third rows. In the case where cos θ = 0, the angles φ and ψ are not unique (much as the longitude of the North Pole is not unique). But if we pick φ = 0, we can use the lower-left corner and atan2 to compute a value for ψ. The code is given in Listing 11.1, where we are assuming the existence of a 3 × 3 matrix class, Mat33, which uses zero-based indexing. The angles returned are in radians, not degrees.

Listing 11.1: Code to convert a rotation matrix to a set of Euler angles.


  1  void EulerFromRot(Mat33 m, out double psi,
  2                             out double theta,
  3                             out double phi)
  4   {
  5    theta = Math.asin(m[0,2]) 
//using C# 0-based indexing!
  6    double costheta = Math.cos(th);
  7    if (Math.abs(costheta) == 0){
  8       phi = 0;
  9       psi = Math.atan2(m[2,1], m[1,1]);
10    }
11    else
12    {
13       phi = atan2(-m[0,1], m[0,0]);
14       psi = atan2(-m[1,2], m[2,2]);
15    }
16
  }


It remains to verify that the values of θ, φ, and ψ determined produce matrices which, when multiplied together, really do produce the given rotation matrix M, but this is a straightforward computation.


Inline Exercise 11.3:

Write a short program that creates a rotation matrix from Rodrigues’ formula (Equation 11.17 below) and computes from it the three Euler angles. Then use Equation 11.14 to build a matrix from these three angles, and confirm that it is, in fact, your original matrix. Use a random unit direction vector and rotation amount in Rodrigues’ formula.


Aside from the special case where cos θ = 0 in the code above, we have a one-to-one mapping from rotations to (θ, φ, ψ) triples with –π/2 < θ ≤ π/2 and –π < φ, ψ ≤ π. Thus, the set of rotations in 3-space is three-dimensional.

In general, you can imagine controlling the attitude of an object by specifying a rotation using θ, φ, and ψ. If you change any one of them, the rotation matrix changes a little, so you have a way of maneuvering around in SO(3). The cos θ = 0 situation is tricky, though. If θ = π/2, for instance, we find that multiple (φ, ψ) pairs give the same result; varying φ and ψ turns out to not produce independent changes in the attitude of the object. This phenomenon, in various forms, is called gimbal lock, and is one reason that Euler angles are not considered an ideal way to characterize rotations.

 



If you can make sense of the above, you will be good with this book.  This sample is pretty typical of how things in this book are covered.  So if you are looking for a text for learning or brushing up on computer graphics Computer Graphics: Principles and Practices is probably one of the best.  With the exception of Physics, and library specific instructions, this book has pretty much everything you might need to know.

General Programming


24. July 2013

 

 

My somewhat recently published book, PlayStation Mobile Development Cookbook is currently the top ranked game programming book on Amazon…

 

…in Japan …on Amazon …in Kindle format.

 

But it’s still pretty cool. Smile

 

I check Amazon sales rank every once in a while to see how my book is doing ( it’s the only insight into book sales I have, amazingly enough ) and today when I check Japan, I see:

 

image

 

Number one baby!  Open-mouthed smile

 

Granted, Amazon track this value in pretty close to real time, so I am the number one selling game programming book in Japan for RIGHT NOW… in an hour I might be 50th…  but I’ll take it!

 

In another bittersweet milestone, I also just found the book on pirate sites for the first time.  That actually took longer than I expected to be honest.  I suppose an author or game developer should take it as a badge of honour that people will pirate what you created.

 

 

Oh, and Japan, you rock!

Totally Off Topic


GFS On YouTube

See More Tutorials on DevGa.me!

Month List