Archives for posts with tag: how-to

A few of you asked about how I got those statistics for my previous post about Blender SVN.

For the inquiring minds, I got the SVN log with the following command

svn log -r 25000:0 --xml https://svn.blender.org/svnroot/bf-blender/branches >> log.xml
svn log -r 25000:0 --xml https://svn.blender.org/svnroot/bf-blender/trunk >> log.xml

These two SVN operation fetches the SVN logs for both the branches and the trunk of Blender and combine them into one 8 megabyte XML file.  Please do not do this often as I imagine querying all the commit logs must put a heavy strain on the Blender SVN server.

Parsing the XML for the author commit frequency is done with the following python script:

import xml.sax

authorList= {}

# create document handler
class SVNXMLHandler(xml.sax.handler.ContentHandler):
	def __init__(self):
		pass

	def startElement(self, name, attrs):
		self.hasAuthor = 0
		self.hasEntry = 0
		if name == "logentry":
			self.hasEntry = 1
			#print attrs.get('revision', ""),
		elif name == "author":
			self.hasAuthor = 1

	def characters(self, data):
		if self.hasAuthor:
			#print data
			try:
				authorList[data] += 1
			except:
				authorList[data] = 1

	def endElement(self, name):
		if name == "author": self.hasAuthor = 0
		if name == "logentry": self.hasEntry = 0

# load and parse log
f = open('log.xml', 'r')
xml.sax.parseString(f.read(), SVNXMLHandler())

# print to console in comma delimited format
for i in authorList:
	print i,",",authorList[i]

Run the above python script like so:

python logParser.py >> crunched.csv

After a few seconds, a CSV file should be created containing all the data you need, ready to be graphed in Microsoft Office.  Yes I used Excel for the graph…

Today I will present a simple graphical guide to build Blender 2.5 on a Windows computer.  A lot of the instructions just need to be done one time, once you have a building environment setup, updating the build is a *really* simple process.  But if you just want a cutting-edge daily release, you can find those pre-compiled for you on Graphicall.org

Firstly, you will need a few piece of software: We are going to use Microsoft Visual Studio 2008 and Cmake to help us build Blender, and to fetch the source code from blender.org, we’ll also need a SVN client, I will use TortoiseSVN.

1. Get Visual Studio 2008. If you have access to a copy of Visual Studio, great!  But I heard the free Express Edition works too.  I went with a custom installation and this is all the components you’ll need to build Blender.

Custome Installation

2. Get CMake and install it.  It’s free.

3. Install TortoiseSVN, also free.

4. Once all the software are installed, we can begin to acquire the Blender source codes!  First, navigate to an empty directory and right click to do a SVN Checkout.  Use the following URL:

https://svn.blender.org/svnroot/bf-blender/trunk/blender

Put the source under C:\Blender\blender. Next, let’s also acquire the libraries needed to build Blender.  Do another check out with the following URL:

https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows

Make sure you put the files under a directory like C:\Blender\lib\Windows.  If you want to make 64bit builds, also check out the 64bit libs:

 https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64

Put that under C:\Blender\lib\Win64

04

Use TortoiseSVN to check-out the Blender Windows Library

Once you have done the 3 check-out, your directory structure should look like this, make sure all the folders and files are in the proper place, otherwise you will have a hard time building Blender:

Folder structure

Folder structure

5. Now that you have all the source files, it’s time to start the building process!

We are going to use CMake to generate a “solution” file for Visual Studio.  A solution is what Visual Studio would open to build the entire Blender. It’s a collection of smaller project, each project is a collection of source files.

Now open CMake, and In the top text box, type in where you put the Blender source code. (C:\Blender\blender, in my case)

In the second text box below it, select a fresh directory where you want the output file to go. I am using C:\Blender\build

Now click on Configure, this will bring up another dialog box where it asks you which generator to pick.  We are going to use Visual Studio 9 2008, or Visual Studio 9 2008 Win64, if you want to build a 64bit Blender.

CMake

Then CMake will populate the main window with a list of options that you can disable or enable.  The default selection is good, but if you want to speed up the building process, you can deselect certain options that you are not using.

Certain options might also be unavailable or broken on 64bit.  For example, if you are building a 64bit release, make sure you uncheck FFMPEG, JACK, and QUICKTIME, since there is no 64bit library for these media features yet.

CMake Options

For first timers, I would suggest unchecking all of these boxes to build a minimalist Blender.  It will be faster, smaller, and there is less chance of running into an error at compile time.  You can come back and re-enable these settings once your first build is successful.  Once you have made your selection, click on Configure at the bottom of the screen.  Then followed by clicking on Generate. These will generate the corresponding Visual Studio solution files in the directory you specified above.  (C:\blender\build\) in our case.  Close CMake.

6. Navigate to C:\blender\build, you should see the solution file you just generated.  Open “Blender.sln” with Visual Studio 2008.

Build folder

Once Visual Studio opens the solution, make sure you change the default build target from Debug to Release.  Otherwise you will end up with a debug build of Blender that is slower, bigger, and probably not helpful unless you are debugging.

Visual Studio 2008

After that, simply select Build Solution from the build menu.  After about 10 minutes of compiling and linking, a fully functional Blender installation should be ready under C:\Blender\build\Bin\Release.

A while ago, I posted a simple demo I made in the Blender game engine that let’s 2 player interact with each other over the internet, all it is required is a really simple networking script and the IP address of the two players.  Here is as youtube video of it in action, mouse-over the video to see some caption text.

The laptop on the left is physically separated from the desktop to the right, linked only by a wireless internet connection. And as you can see, input made to the desktop computer is sent across the network to the laptop, in realtime.

And here is the script, I’ll try to explain everything as best I can:

# Simple Python UDP networking demo Created by Mike Pan
# Todo: auto-self IP detection would be nice

# the following line loads the game module used by Python
# to access the Blender Game Engine API, and assigns it the alias G
import GameLogic as G
# load the network socket python module, we'll need it later
import socket

# define own IP address, and stores it as a property under GameLogic
# essentially making it accessible as a global variable
G.ownIP = "xxx.xxx.xxx.xxx"
# define peer IP address, stores it as a property under GameLogic
# again, essentially making it accessible as a global variable
G.peerIP = "xxx.xxx.xxx.xxx"
# define the port number (arbitrary), and the socket buffer size
# (4096 is a good starting point)
G.port = 4000
G.buffer = 4096

# create an IPV4 address with the pre-defined IP and the port number
addr = (G.peerIP, G.port)

# We'll add this line to all our communication, so when debugging,
# we won't get confused as to who send the packets.
signature = "Sent from " + G.ownIP

def init():
	# create an UDP socket for **sending** datagram
	G.sender = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	# time out is 10ms, pretty short for realworld application,
	#but enough for debugging over local network
	G.sender.settimeout(0.01)
	# this is important! by making this socket object a
	# non-blocking operation, all network stuff is run on
	# a separate thread, thus any network delay will not
	# cause the game to slow down
	G.sender.setblocking(0)

	# creates UDP socket for **receiving** datagram
	G.listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	# same as above, time out is 10ms
	G.listener.settimeout(0.01)
	# same as above, we also need to make sure network operations
	# will not slow down the main application
	G.listener.setblocking(0)

	# Win32 needs the socket binded:
	try:
	 G.listener.bind((G.ownIP, G.port))
	except:
	 print "Binding Listener failed"

def comm():
	# get the object that is attached to this script
	own = G.getCurrentController().owner

 	# receive from peer
	try:
		data, port = G.listener.recvfrom(G.buffer)
		# data contains all the data that came through,
		# it's a string, and we can do whatever we want
		# like print it out
		print data.split(',')
	# if the receiving fails, print something to notify the user
	except:
		print "Receive failed"

	# send to peer
	# generate data to be sent here,
	# send the position data across the network:
	string = str(own.worldPosition)+ ',' + signature

	# going to try to send the data
	try:
		G.sender.sendto(string, addr)
		# if sending fails, notify with error message
	except:
		print "Send failed"

That’s it! To use this script, we simply need to call init() once at the start of the game, and then comm() everytime you wish to send/receive some data (perhaps every 1/30th of a second). As mentioned, here is no ‘server’ involved, the two peers connect direction to each other via a UDP socket. All the user has to do is specify the two IP addresses.

I know I will never be a great writer, so instead of doing tutorials, I have decided to release some of the personal project I’ve worked on. The result is a 300MB folder of 22 project, including a lot of the things on my portfolio and demoreel.

When I was learning Blender, I start a lot of personal mini-project that I never really finished, so instead of having them just sitting on my harddrive, perhaps others can find them useful in some way.  The pack contains animations, stills and a realtime game project.

=======================Download=================== ====

Mike’s Blender Pack v2 Zip (175MB Compressed)

Mike’s Blender Pack v2 Individual files

=======================Download=================== ====

File listing of the Blender Pack content.

File listing of the Blender Pack content.

I’ve tried my best to make sure everything is packed and ready to go. All files should work in Blender 2.49a.