Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
15. June 2011

 

Earlier this week I described the process of building Blender for Windows using CMake and Visual Studio.  While I was doing I actually did a series of screen captures for the more visual learners amongst us.  Problem is, my machine decided editing 1080p video was a crime against humanity, so I wasn’t able to get them posted.  I can happily say, the problems have been rectified.

 

Compiling Blender ‘Avocado’ on Windows

 

 

Of course a great deal of the video will be unreadable in this resolution.  I recommend using an HD version on YouTube.  Or for the Vimeo inclined click here.

Programming


11. June 2011

 

EDIT: Now with video!

 

After yesterday’s post, I noticed there wasn’t a recent build of Avocado available so I got to wondering how much work it would be to build a Blender branch.  In the end the answer is “not much”, with a bunch of caveats.  Frankly the hardest part is configuring your environment.  This guide shows but one way, there of course are other options.

 

First of all, I already have Visual Studio 2010 Professional installed, but many of you may not have professional and there is a big snag with Express C++ in that there is no command line 64bit compiler.  At this point you have one of three options, build for 32bit, download and install the Platform SDK which includes a 64bit cross compiler or you can download and use mingw.  The last two options are beyond the scope of this post and the instructions will assume you are using VC++.

 

Next up you need SVN, which is what you use to get the code from Blender’s repository.  In my case, I am using Cygwin from the command line.  For those of you with a command line aversion, you can use a GUI tool like Tortoise SVN.  Again, my instructions are going to assume you went the Cygwin route, but should still make sense a different SVN.

 

Now, to get Cygwin, run the Setup.exe ( from here ) and choose the default ( install to a directory without spaces! ).  You can add other features, but don’t do this now as some download locations don’t have all the packages, so it could result in your install failing.  Once setup.exe has completed, run it again and search for svn, if it is not installed ( as pictured below ), in the New column, instead of keep it will say “Skip”, click this and it will set it to download.  Then click next and it will figure all of the requisites and dependencies, download and install them.

 

image

 

Assuming all went well, you now have svn.  Only one more file to install, CMake, a cross platform make tool.  The install process is pretty straight forward, now time to grab the sources.  You are going to need to make two directories on your local computer, one where the code is going to be downloaded, then one where the code is going to be built.  In my case ( and in the instructions ) I used C:\Temp\Blendersource and c:\temp\BlenderBuild but you can of course use whatever you want.

 

Now its time to get the source.  Launch “Cygwin Bash Shell”, it should be located in your Start Menu.  Otherwise you can run it from [Cygwin Install Directory]\Cygwin.bat.  Now you need to choose which repository you want to build.  The list of branches is available here.  In your browser navigate to the one you want to build, then into the blender directory and copy this address.  In this case I am building Avocado, so I copied https://svn.blender.org/svnroot/bf-blender/branches/ to my clipboard.

SVN works in the form of:

svn checkout [ paste your clipboard ] [where to copy to]

 

One gotcha is you need to point BASH to a directory on your computer, in this case C:\temp\blendersource.  In order to do this, we use the /cygdrive link.  So, the actual command looks like:

 

$ svn checkout https://svn.blender.org/svnroot/bf-blender/branches/soc-2011-avacado /cygdrive/c/temp/blendersource/

 

That will go ahead and download all the blender code.  You will probably get an error stating server certificate isn’t trusted, check type “t” or “p”.  Later on you are going to need the precompiled binaries from the trunk repository.  They are located at https://svn.blender.org/svnroot/bf-blender/trunk/lib/ in the windows/ and win64/ folders.  Warning! This takes a long time, like go make and drink a pot of tea long time.  We want them copied into the /lib/windows directory of the newly downloaded source.  The command for this is:

 

$ svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows /cygdrive/c/temp/lib/windows

followed by:

 

$ svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64 /cygdrive/c/temp/lib/win64

 

At this point, you have all the sources and libraries you need.

 

Now fire up trusty CMake you downloaded earlier.  In the “where is the source code:” text field put C:/Temp/blendersource/ ( or the location of CMakeLists.txt if you are using a different path).  In the “Where to build the binaries:” text field put c:/temp/BlenderBuild.  Now click “Configure”, the following window will appear, select your compiler:

 

image

 

 

Click Finish once your compiler is selected from the list.  Now your CMake window should look like this:

image

 

Now you can optionally enable/disable features.  If building Avocado, disable WITH_IMAGE_OPENEXR! It will currently cause your build to fail. Once you finalized your selections click Configure again, then Generate.

Now if you look in C:\Temp\BlenderBuild, you will see that CMake has built the proper native build files, in my case for Visual C++ 2010.  There is even a solution file if you want to build using the VC IDE.  In this case I am going to use the command line, launch the Visual Studio X64 64 Bit Command Line.  Now type:

cd \temp\blenderbuild

msbuild Blender.sln /property:Configuration=Release

 

And off to the races…   See, nothing to it! Open-mouthed smile

 

After 5 to 20 minutes later, copy your new Blender.exe ( from bin\release ) into a Blender install and…

 

image

 

AHHHH crap, seriouslyjQuery152044251238950528204_1314637985251?  Well, we apparently have a very streamlined version, perhaps a bit too streamlined.  What exactly is going on here?  Well, truth of the matter is, if you followed along at home and aren’t using Windows 7, nothing, it probably works perfectly fine.  However, if you are like me and are running Windows 7, this post is very interesting.

 

There is some annoying permissions issue with Win 7, depending on who/how/where you install as. A known problem, being worked on. Maybe already fixed. (can you tell I'm not a windows guy?)
Easiest work-around for now is to download the .zip version, unzip it and run from that folder.

 

Welcome to life on the bleeding edge!  It’s called the “bleeding edge” for a very good reason!  Anyways, head over here and download the 64bit ZIP install, extract it and copy your new Blender.exe file over.   Voila!

 

image

 

 

A fresh new 64Bit version of Blender—Avocado, bmesh tools and all.  It may have looked difficult, but in the end, it really isn’t, with the exception of figuring out the most recent bug ( thanks Google ).

 

Seem like too much work?  You can download the blender.exe I generated.  Simply download and install the current 2.57b ZIP from Blender, extract it then extract my Blender.zip over top.

Art Programming


10. June 2011

 

One of the nicest features of going with Blender is the fact that it is open source.  One of the nicest facts of open source is you don’t have to wait for a vendor to release a new version, you can go get the cutting edge version at any time.  That said, building Blender from scratch is a non-trivial task, but nicely for that we have graphicall.org.

 

Basically graphicall allows people to post and share their builds.  You go on the site andBlogEngineLogo choose a build to download.  You can choose by OS, bit-ness or the various features included in the build. Why the heck would you want to do this?  Well, frankly some of these features are incredibly interesting, but perhaps most interesting of all, is the new BMesh tool.  Remember how I said earlier that the weakest link in Blender was the modeling tools, and the one feature it was missing the most was the lack of n-gons?  Well, bmesh addresses this shortcoming.  It is rumoured that it will be part of Blender 2.8, but it as been in development for a very very very long time, so don’t hold your breath. I will hopefully have a demonstration up shortly that illustrates this powerful tool.

 

But bmesh is by no means the only thing to look forward to.  Another area graphicall builds cover is Google Summer of Code builds.  If you have never heard of it, instead of getting a summer job, students instead propose a project in the open source world and if approved, get paid by Google to implement it.  This year, Blender is a pretty big winner on the number of projects sponsored.  About half of the projects on that list will be a huge boon for game development.  The various branches can be viewed here.

 

A quick trip to GraphicAll is going to confuse the hell out of you though…  Avacodo? Radish? Cucumber?  WTF?  Well lets just say the Blender group like their code names!  Last time it was fruit, this time, it’s veggies.  Anyways, this infographic that I brazenly stole from here which in turn they stole from here.  Anyways, it’s a good image, so here goes(click image for original).

 

Gsoc-2011-branches

 

 

Anyways, probably of most interest from a game perspective are the Avocado, Onion and Pepper branches.  Of most interest to game dev work is the Avocado branch, which is the only one based off the BMesh branch instead of the main trunk fork ( Salad branch ).

 

But by no means are we confined to the Summer of Code builds, lots of other stuff is available as well.  There is Blender Cycles a GPU based render, LuxBlend interface for LuxRender, Yafaray as well as builds using OpenMP for better multicore CPU support.

 

So, if you are willing to take a walk on the wild side and put up with a few more bugs and glitches, Graphicall is very much worth checking out!

Art


18. May 2011

 

You bet your ass it does!

 

When moving between applications, each has it’s own unit of measure and frankly 1 has a very different meaning from application to application!  In Wings, a Wings “unit” is completely arbitrary.  So for example if you make a cube 1 by 1 by 1, the “1” means absolutely nothing or frankly, whatever you want it to.  This however gets a bit tricky when moving to another application.

 

In Blender, up until version 2.5 and higher units were completely arbitrary as well.  This means 1 could be a foot, a metre, a cord, a hand or a pan-intergalactic squible, it really didn’t matter.  The problem is, it did, a lot.

 

You see, once you start attaching physics to your models, size truly does matter.  Gravity does not cause things to fall at 9.2 feet per second, it’s 9.2 metres per second and mixing this up will cause things to be wrong by close to a factor of 3 times.  So unless you want gravity to be extremely powerful in your virtual world, you need to standardize on a unit of measure.

 

Now unfortunately to our American and English readers…  Unity picked the standard for us.  In Unity “1” is 1 metre  ( or meter again, for our American readers! Winking smile ) and given that Unity is providing the physics engine, I guess we better conform.  On the bright side, there are systems in place to make the transition as smooth as possible.

 

First off, when working in Wings3D simply treat 1 as 1 metre, then when you export to Blender it should appear as 1 metre in size.  That said, when moving from Wings to other Untitledprograms you may find that the results are exceedingly small.  There however is a fairly simple though remarkably imprecise solution.  Craft your object in Wings, then import it into your graphics program of choice.  Beside it create an object in the native program with that is 1x1x1m in size as a reference, you can then use Wings “Export scale” when exporting to automatically scale up your object when exported until the sizes match.  Once your export looks about right, use this scale factor for all future exports.    Clicking the square icon for the File –> Export –> Collada will bring up the export options window ( as shown to the right ).  The value surrounded in red is the important field.  A value of 1.0 means no change, while 2.0 would be twice as big and .5 would be half the size.  Again, while working with Blender, so long as you treat 1 Wings unit as 1m, you shouldn’t have to do anything.

 

With Blender, fortunately since version 2.5 you can now specify what units are.  Instead of re-inventing the wheel, I will refer you this excellent blog post on the subject.  They do a very good job of describing how to work with actual units.  Once configured, your export to Unity should be configured properly and compatible with the physics system.

Art


18. May 2011

 

We 354px-Cartesian-coordinate-system.svgare all familiar with 2 dimensional Cartesian coordinates for describing positions in 2D space, often used to represent pixels on screen, but ultimately the very foundation of algebra.  The two values, x and y can be thought of to represent Left <-> Right and        Up <->Down respectively, at least when dealing with two dimensions.  But when you throw one more dimension in the mix, it gets a bit trickier.  I mean sure, coming up with Z as the label wasn’t exactly rocket science, but what does Z represent and here is where everything goes to hell!

 

 

 

See, there are two schools of thought on this subject and unfortunately both make perfect sense.  On one hand, one group views X,Y as already representing Left/Right and Up/Down on a computer display, so the most logical conclusion is that Z should represent depth.  Imagine for a second if you could reach INTO your monitor… that would be the Z coordinates.  If you have already done some 2D graphics work, X and Y are probably pretty well entrenched in your mind as representing screen position, so this probably makes a lot of sense to you.  For the record, this type of coordinate system where Z represents depth is referred to as a Y-up as Y represents the up direction.  Personally, this is the most intuitive to me.

 

 

But then there are these other types of people in the world… engineers and architects and to them X,Y are viewed in a much different context.  See instead of thinking in terms of a computer monitor in front of them, they think in terms of blueprints on a table.  With a system 300px-Z_axislike Autocad, the Z-axis is added when the blueprint is extruded in the 3rd dimension.  Think about it in terms of building a house from a floor plan, the X,Y coordinates represent the layout of everything on your floor, then Z represents the distance of things UP from the floor.  So, to a CAD person, it makes complete sense for Z to represent “UP” and Y to represent “depth” like in the figure to the right.  This obviously is referred to as Z-up.

 

 

 

 

 

Now you may be asking yourself… how exactly does this affect me?  Well, that’s an easy one… all kinds of tools work with a different axis set.  Of the 3 we use, Wings 3D is Y-up, Blender is Z-UP and Unity 3D is Y-up.  So… as you are creating your assets they spend a lot of time flipping around between programs!

 

With Wings 3D, if going directly to Unity, you are in luck, no more work has to be done.  Most of the time though, we will be going from Wings to Blender first.  Fortunately this fix is pretty easy.  When you export your model ( via the menu File->Export->Collada ), click the little box icon to bring up options.  Then make sure you select “Swap Y and Z axis” checkbox as shown in the picture below, then OK and export.  This setting is “sticky” so you should only have to choose it once.

UntitledSetting Wings 3D to export Z-up friendly

 

 

 

 

 

 

 

 

Now in Blender things get a bit trickier and therefore it’s really easy.  Frankly, there is nothing you can do.  The axis system is fixed so you can’t change that, and there are no options when exporting.  I suppose you could model everything rotated but that would add a great deal of confusion.

 

 

So that leads us to Unity, currently the importer (version 2.57b ) is working properly, so thankfully you *shouldn’t* have to do anything, it automatically rotates it for you.  That said, this importer isn’t always the most… stable thing.  In cases where it doesn’t import correctly, you have one of two options.  First you can rotate manually 90 degrees about the X axis when you create an asset in Unity.  Otherwise, you can perform the conversion as part of the import process by creating an AssetPostProcessor which is a script run during the importation process, allowing you to make last second alterations.

 

 

 

For the record, this isn’t only a Blender/Unity problem, Max, Maya and Softimage are all Z-Up modelers by default, while I believe Cinema 4D is Y-up.  It is something to be aware of when moving from one application to the next. If it seems like your model is doing a backflip, the axis difference is most likely the cause.

Art


GFS On YouTube

See More Tutorials on DevGa.me!

Month List