Archive

Posts Tagged ‘game’

Blender Export Scripts

July 13th, 2010 Colin No comments

Inspired by the idea behind iDevBlogADay I have decided to continue to blog more, as I enjoy writing and sharing useful (and not so useful) information.

Today I’m going to talk about adapting Blender for use in game development, specifically for exporting textured 3D models from Blender for use in our games.

I am assuming you know how to make Blender work and have created a mesh with a UV texture map. The problem you’re having specifically is getting that mesh out of Blender. You could of course use one of the built in exporters, but this way is more educational, also sometimes it is good to have control over the format your mesh data is stored in. The file described here is pretty basic, but hopefully this gives you enough working knowledge of Blender’s guts to use this as a springboard to create awesomer things. Another thing to take into consideration is that Blender and OpenGL use slightly different coordinate spaces, but it is not hard to work around.

Anyway, the language of choice for Blender is Python. If you like tabs, you will like Python. Much like how LISP was invented by parenthesis fetishists, I suspect that Guido van Rossum has a thing for tabs.

So, let’s get crackin’! Fire up your favorite text editor and do the following:

#!BPY
"""
Name: 'MyMeshExport'
Blender: 248
Group: 'Export'
Tooltip: 'Export a MyMesh File'
"""
 
import Blender
import bpy

What this does is tells Blender that it’s a Blender Python script named “MyMeshExport”, runs on at least Blender 2.48 (you can change this as you see fit), and goes in the “Export” group. The imports hook into a bunch of Blender specific stuff including the scene.

Next, we’re going to specify the “write” function for the script. This is what is run automatically when you choose this script to export it.

def write(filename):
	out = file(filename, "w")
	sce = bpy.data.scenes.active
	ob = sce.objects.active
	mesh = ob.getData(mesh=1)

What this does is opens a file for writing, and hooks it to out, takes the currently active scene assigning it to sce, the currently active object and assigns it to ob, and then assigns the first mesh in ob to mesh. This assumes you have selected your object before you exported, and that object only has one mesh.

Next we’ll put in how many vertexes and faces there are in our mesh into the file. This will make life easier for our file loader:

	out.write('%i Vertexes\n' % (len(mesh.verts)))
	out.write('%i Faces\n' % (len(mesh.faces)))

Next we insert vertex co-ordinates:

	for vert in mesh.verts:
		out.write('v %f %f %f\n' % (vert.co.x, vert.co.y, vert.co.z))

This goes through each vertex in the mesh and inserts “v x y z” where x, y, and z represent the co-ordinates of the vertex.

Finally we write in information for each face in the mesh, including what vertexes make up the face, the vertex normals for that face, and the UV coordinates.

	for face in mesh.faces:
		out.write('f')
		for vert in face.v:
			out.write(' %i' % (vert.index))
		out.write('\n')
		out.write('n %f %f %f\n' %(face.no[0], face.no[1], face.no[2])
		out.write('n %f %f %f\n' %(face.no[0], face.no[1], face.no[2])
		out.write('n %f %f %f\n' %(face.no[0], face.no[1], face.no[2])
		for uv in face.uv:
			out.write('uv %f %f\n' % (uv[0], uv[1])
	out.close()
Blender.Window.FileSelector(write, "Export")

This is where the per-polygon information is spat out into your file. For each face it outputs “f v1 v2 v3” where v1, v2, and v3 are the indexes of the vertexes we exported previously.

Next we output the normals. In this simple example we’re going to assign the face normals to each of the vertex normals. This is because whatever Blender thinks the “smooth” per-vertex normals are has no basis in reality what-so-ever. If you want to get smooth normals, you will have to compute them yourselves. The normals are encoded as “n fn1 fn2 fn3” on 3-separate lines (one per vertex) where fn1, fn2, and fn3 is the face normal.

Finally we output the UV coordinates of the texture map. For each vertex in the face we get “uv uv1 uv2” where uv1 and uv2 are the UV coordinates of that vertex.

The last line in the file tells Blender to open it’s File Selector window and call ‘write’.

Once you save your file with an imaginative name like ‘myfileexport.py’ you can copy it to wherever Python keeps its scripts. This is different under different platforms obviously, though you can get that information here, which incidentally I discovered after writing all this is practically identical to my post, except I cover exporting UV coordinates. Possibly because this is where I learned this over a year ago and subsequently forgot. Mea Culpa.

Anyway, let’s finish this up. So you’ve put your script into your scripts folder. Now you need to update the menus in Blender to tell it that it’s there. So you go to the Python pane and go to Scripts > Update Menus. Then you can go to your scene, select your object then go to File > Export > MyMeshExport to save your new mesh for inclusion in your game.

GameFontMaker

July 7th, 2010 Colin 2 comments
GameFontMaker Icon

GameFontMaker

July 9th Update: GamefontMaker is now at 1.0.0 beta 2 and it’s also been released under the GPLv2. You can find the latest version and source over here!

It’s been a while since I’ve posted anything to the blog, so I figured I’d do something a bit special to try and get into the swing of things. So, I present to you what I think may be the first native Cocoa bitmap font creation tool for games, GameFontMaker!

At least, I think it is… Maybe… I didn’t do a lot of research, but I have seen a lot of fellow iOS devs wishing something like this existed for OS X, as the only other alternative runs under Windows.

Even if it isn’t, I was getting sick and tired of my really awful bitmap font creation tool that used FTGL, SDL and duct tape and generally produced hideous bitmaps without a lot of fudging of numbers. This is much, much better than that.

Anyway, GameFontMaker is currently in “beta” so don’t come crying to me if your computer explodes or anything. Though in my defense it hasn’t caused my MacBook to explode, and it was way less stable when I started it about 12 hours ago!

This is also my first Cocoa app, so forgive me if it’s a bit rough around the edges.

That being said, if you do find a bug or have a suggestion you could always drop me an email at: colin[at]celsiusgs[dot]com.

So, you’re itching to create some decent bitmap fonts for your game? Well, GameFontMaker is pretty easy to use. From the main window:

GameFontMaker Main Window

GameFontMaker Main Window

You can select the font by clicking on the “Fonts” toolbar button, doing so updates the preview. Once you’re satisfied with your selection, click “Export Font” which opens a file dialog. Choose the file name here, it will automatically choose a .png extension. Once you make sure you’re not overwriting an important system file or your taxes or what have you, click “Save”. This will invoke an ancient spell designed to end the world (and generate fonts) and will cause GFM to spit out a PNG file with all the printable ASCII characters in a line, also it will produce <filename>.png.xml which is an XML file that describes all the character dimensions. It has the following format:

<?xml version="1.0"?>
<fontdata>
	<glyph>
		<character> </character>
		<width>7</width>
		<height>25</height>
		<offset>0</offset>
	</glyph>
...
</fontdata>

Right now the output isn’t ideal for using directly as a texture atlas, but hopefully the PNG plus the XML file can be put to some good use. Once I get some more time I will add support for defining the PNG size and altering the XML output.

Anyway, GameFontMaker is free to use for all sorts of purposes, however if you do find it useful you could always have a look at my games or maybe follow me on The Twitters. Enjoy!

Chromodyne Lite

April 30th, 2010 Colin No comments

Chromodyne Lite Icon

In an effort to try and increase the visibility of Chromodyne, I’ve done gone and created a Lite version! As it is FREE, I ask you kindly to check it out, as maybe you’ll like what you see :)

You can get Chromodyne Lite on the App Store here: itms://itunes.apple.com/us/app/chromodyne-lite/id369298294?mt=8

The Chromodyne Lite Press Release Follows:

Celsius Game Studios is proud to present Chromodyne Lite, the free version of its unique and exciting match-3 puzzle game, Chromodyne! Chromodyne Lite is available for the iPhone and iPod Touch, on the Apple App Store.

Chromodyne Lite features a brand new 5 chapter story introducing the player to the Chromodyne as they work their way through the Chromodynamic Academy’s accredited Accelerated Chromodyne Operator’s Course. Through this program, you too can learn the skills necessary to save the world from impending doom from outer space!

“Course?” You say.

“That sounds like it might be expensive…” You say.

You would say that, wouldn’t you?

Well, you might expect to pay tens of thousands of dollars and rack up years of crushing student debt at some “university” to learn how to save the world. Not so at the Chromodynamic Academy. No, you too can learn all this today for the low, low price of FREE!

Not only do you get this valuable training, but you’ll also find that Chromodyne Lite offers fun and challenging 3D match-3 gameplay, colourful and striking visual effects, and an awesome soundtrack by Kevin MacLeod.

If you’re saying: “Well, I can’t possibly go wrong with that! Plus I can’t argue with free… Especially when you put it in all caps like that!” I’d suggest you follow this link and give it a try: itms://itunes.apple.com/us/app/chromodyne-lite/id369298294?mt=8

Also Sprach Zarathustra

April 23rd, 2010 Colin No comments

For shits and giggles I decided to try and emulate the opening of 2001: A Space Odyssey in Blender. I present to you Chromodyne: A Match-3 Odyssey. I think I did a pretty good job, don’t you?

With (many) apologies to Mr. Kubrick.

In other, more serious news not related to me cocking about making movies, I submitted Chromodyne Lite to Apple for approval in the wee hours of the morning. Here’s hoping it won’t be stuck there for long!

Did Not Finish

April 8th, 2010 Colin No comments

They call it the “Race to the Bottom” on the App store, where everyone tends to price their app towards 99 cents because they feel that will compel people to buy their app because it’s so cheap. Well, I’m not so sure that is working anymore. Also with the new finish line apparently being set at $0, I think I’m going to pull out of this race.

Put a big “Did Not Finish” next to Celsius Game Studios in the Great Race to the Bottom as even if we reached the finish line, nobody is winning.

Partially inspired by this Gamasutra article “The 0.99 Problem” by Canabalt Co-creator Adam Saltsman, the huge amount of noise at the 99 cent level, and by the fact that if people want to play my games they’ll also more than likely pay a reasonable price for it, CGS games going forward will not be priced permanently at $0.99. To prevent future cries of hypocrisy I’ll state now that you may see a sale at $0.99, but at the very least that’s the new Free for a Day as far as I’m concerned.

On my part I promise I’ll continue to deliver games that are worth more than 99 cents to you, my wonderful audience.

To that end, the $0.99 “introductory sale” on Chromodyne for the iPhone and iPod Touch will be ending this weekend and as of Monday, April 12th, it will be priced at the still inexpensive $1.99.

Mark it in your calendar. Or not.

Mark it in your calendar. Or not.

Thank you for your continued support :)

Too Good to be True (So Far)

April 4th, 2010 Colin No comments

So yesterday I started using a beta version of MajicRank by the most excellent David Frampton of Majic Jungle Software. MajicRank is a tool that scours the App Store for your apps and checks to see if they’re in the Top 100 in any of the categories on the App Store. It’s pretty awesome.

Yesterday being the launch of the iPad in the US, and I having Chromodyne HD available along with the launch of said iPad.

However, whereas the iPad launch was hugely successful, Chromodyne HD? Not so much.

Now from my frantic Twittering, you probably wouldn’t be able to tell… as for most of yesterday evening Chromodyne broke into the Top 100 in Arcade and Puzzle for iPad games. That felt great let me tell you!

Great right up until I got the daily sales summary this morning, that is! Apparently that slight surfacing into the top 100 amounted to 1 sale. Kinda sucks, hey?

I suspect the reason I’m ranking so high in those categories is that there aren’t that many games in those categories (yet) and that Chromodyne is near the bottom of the pile, but the bottom of the pile is so close to the 100 point that a single sale will do something like this. This is quite possibly also why Apple is hiding category views for iPad apps in iTunes and only showing the Top 50 on the device itself.

What sucks for me, with my currently lousy non-existent advertising budget and lack of coverage due to bigger titles getting the spotlight yesterday, is that I can’t actually take advantage of that placement in those categories. Nobody can actually see that my cool little game is in the Top 100!

I'm at the top, of the bottom!This is what excitement looks like.

It’s still early days yet and my porting of Chromodyne to the iPad was a fun experience, which effectively didn’t cost me anything except a few days of time. So I’m not upset or anything, and I wasn’t expecting miracles. There are a few pending reviews of Chromodyne so I hope they come out eventually, and that should help :)

In the meantime, I do want to thank everyone who shared my (misplaced) excitement last night, at least I can say that Chromodyne made it into a Top 100 list!

Thoughts on the iPad

January 27th, 2010 Colin No comments

Well, Apple finally released their oft-speculated-upon tablet, the iPad, today. The response I’ve been seeing across the interwebs has ranged from comments reminding me of the hubris inducing pessimism surrounding the launch of the iPod, to the completely ridiculous sort of grandstanding that comes about whenever the press catches hold of something that’s “going to change the world!”; like, how it’s going to kill the mouse and keyboard or something. That’s like saying the computer will kill paper and pens, or the Segway will kill walking, or… ingesting pop rocks and soda killed Mikey. See what I’m saying?

What about me? Small game designer/developer guy you probably haven’t even heard of until now? I think the truth lies somewhere in the middle, and the iPad is balancing on a knife-edge between success and failure.

Stick with me here.

I think where the iPad’s potential lies is as a beefed up PDA/planner with the capabilities of an eBook reader and some of the power of a laptop, like editing documents and viewing large videos, while still being in a small form factor with an amazing battery life.

The problem with the iPad, at least as far as I can tell, is that Apple has actually created the iPad’s worst competitor. By placing the iPad as a device in between PDAs and laptops, Apple believes that they are competing with inexpensive netbooks, but in reality, I think that the iPad’s biggest barrier for growth will be it’s older, yet shorter brother, the iPhone!

Look at it this way: the iPad instead of being a small laptop without a physical keyboard, ports, etc., is more like a large iPod Touch or iPhone without the phone and camera parts. People are going to look at their iPhone and think “why would I want an iPad? My iPhone does practically everything I need it to do and more, and it’s more portable to boot.” It’s an even worse value proposition if these people have laptops already. The problem is that by making the iPad behave more like an iPhone and less like a laptop, many people, I think at least, will view this as an iPad vs. iPhone question rather than an iPad vs. netbook or laptop question.

Don’t take this as me completely writing off the iPad. I don’t think it’s going to be a Segway, but I’m not really sure if it will end up being an iPhone or iPod. I do think it will find it’s place in the market, but I think that iPhone OS and the hardware may need to go through a few revisions before it can really get a proper foothold.

I suppose I should talk about gaming and the iPad while I have you here, seeing as that’s kinda my thing.

First off, I think that we’re probably going to see a divide between gaming on the iPad and the iPhone/iPod Touch. Nothing huge but because of the iPhone’s phenomenal success, I think that there will still be a massive demand for small form-factor games that specifically target the iPhone. On the other side of that coin I think that the iPad, by being larger with more power and having a higher resolution will allow more freedom of expression for game developers. But this is good! More choice is never a bad thing when it becomes trivially easy to port your software between these devices, you just have to make sure you design your software with an eye towards running on many devices (this was a good idea before the iPad, in case you didn’t get that memo).

Earlier today I read an article suggesting that the iPad was going to be end of the sort of small developer that found success on the iPhone because it allowed for small teams to produce small games but reach a large audience. I definitely don’t see that as an lesson to take away from the iPad. I do agree 100% that developing games on the iPad, specifically to take advantage of the iPad hardware, will be more time and money intense, however it’s not like the iPad is going to kill the iPhone. Hell, I’d even go so far as make the rash and wildly assumptive statement that most small iPhone devs can blissfully ignore the existence of the iPad and still be able to make a comfortable living selling their wares to iPhone owners (as they are legion).

My personal goal is to see Celsius Game Studios games on the PS3 and 360, so I’m not dreading the iPad. Quite the contrary, I view it as yet another exciting platform with a potential audience for my games.

Also, much like “Wii” humanity will somehow come to terms with “iPad.” You can quote me on that.

The Game Is Afoot!

January 19th, 2010 Colin No comments

Just wanted to drop you all a note saying that I am forging ahead with my plans to turn Celsius Game Studios into something more than a hobby in my spare time. I really do love creating video games and I’ve been thinking about making my own company to do this for over 12 years now, it’s unfortunate it took me this long to stop being afraid about “what if it doesn’t work” and just realize it’s more important to get out there and kick some ass and do awesome things. I’ll be spending the next few months easing out of my current job before I can fully spin up the turbines at Celsius. However I have started pre-planning my next title, which you will find out about soon enough ;)

I still have a lot of hard work ahead of me, business plans, and funding and all that crazy scary stuff, but rest assured this is the real deal. I just wanted to let everyone know that awesome things are in the pipes, but that I have a lot on my plate right now so I hope you’re understanding while I work on them all at the same time.

To that effect I wanted to say that I’m still working on the 1.1.0 update for Chromodyne, and it will be out Real Soon Now.

Things that will definitely be in the update:

  • Improved game timing, reducing the time between a match being made and the play field being active again
  • 3D lighting has been improved
  • Cutscenes are now skippable
  • Improved load times slightly and added spinner when loading

Things that I’m currently working on for the update, which will hopefully make it in:

  • Alternate control style, currently testing a few final candidates
  • Online leaderboards, working on securely transmitting scores

Until next time!

148Apps.com Review

October 21st, 2009 Colin No comments

Woohoo! “Our Rating: ★★★½☆ :: WORTH A LOOK”

Another review from another iPhone site, this time it’s 148Apps.com. Some very positive comments about the game, graphics and sounds. A respectable 3.5/5 stars, and they basically say that the game can only get better. Which is true, and I’m making it better right now! :O

The 1.1 update should be ready in the next week or two, I hope. The primary focus is to bring Leaderboards and some social networking integration into the mix, plus some other fun things that will hopefully make it in for 1.1, if not 1.2.

Merchandising!

October 19th, 2009 Colin No comments

A discussion with some friends about marketing Chromodyne lead to the following madness. With many, many apologies to Mr. Brooks.

Zarlax: “Merchandising, merchandising, where the real money from the game is made. Chromodyne-the T-shirt, Chromodyne-the Coloring Book, Chromodyne-the Lunch box, Chromodyne-the Breakfast Cereal, Chromodyne-the Flame Thrower.”

*FWOOOOOOOOOOSH*

Gary: “Ooooh!”

Zarlax: “The kids love this one.”

Zarlax: “And last but not least, Chromodyne the doll, me.”

*pulls string*

Doll: “Go die in a fire!”

Zarlax: *throws the doll behind him* “Adorable.”