Game Development Community

Minigolf Mania: Porting to Torque X

by Liam Ryan · 09/16/2009 (10:47 am) · 10 comments

I've been working for the past few months on porting Minigolf Mania to the XBox using Torque X. For those who have not heard of Minigolf Mania, it is a minigolf game produced by Top Meadow. My Dad (Kevin Ryan) did most of the programming, and Alex Swanson and Brian Hahn did the artwork. We used TGE and built it off the sphere physics from Marble Blast.

The official site is here: www.topm.com/minigolf/index.php

Here's a screen shot. This hole is called "Firefall" from the "Snowy Fields" course:

i852.photobucket.com/albums/ab85/Newbot2F7/Firefall.jpg

So, I've been porting Minigolf to Torque X. Not easy! It's really convenient that a lot of the design and structure of Torque X is similar to TGE, so I could often find the corresponding functions or methodology fairly easy, but there were roadblocks as well. For instance:

1. TorqueScript. Since TorqueScript was altogether taken out from Torque X, I basically had to rewrite all the scripts from scratch. Given how strict C# is, while TorqueScript is about as loose as it gets, and how strongly OO C# as opposed to TorqueScript, it wasn't always easy, to put it lightly.
2. Interiors. In the TGE version of Minigolf the hole geometry (including moving platforms) were all in .DIF format, compile from .MAPs. I had to write a tool that converted the .MAP format into an easily-readable format, then write a Max Script to import that format into 3ds Max (more about these later). Then I exported them as .DTSs. Conversion of assets in general was a pain, but interiors were by far the hardest.
3. Documentation/Resources. Speaking of which, I really have to thank John Kanalakis for all the help he gives to poor confused people who don't know how Torque X works (e.g. myself). I can't even recall the number of times his posts have narrowed down a problem or helped me get through a difficulty. Even with his help, though, it was sometimes difficult to figure out how to do this or that, when the documentation wasn't quite there and I didn't have the Torque X source code. This is especially true of parts specific of Torque X 3D -- TX2D tends to get more attention and hence be more documented. It took me a long time to find the (for my purposes) absolutely vital T3DStaticTSRenderComponent.GetCollisionData, for instance.
4. C#. I've never worked with C# before so it took a little getting used to. Especially the value-type vs. reference distinction (which is a little counter-intuitive for a C/C++ programmer) and the garbage collection. But I'm really liking it as I get used to it. I find it easier to write clean code.

But enough complaining! Now that I'm beginning to understand how it works, I'm also beginning to enjoy working with Torque X. The components, in particular, are fantastic. And I am amazed that I could port nearly the whole of a fairly large and complex game (for an indie game, that is) like Minigolf Mania without needing the Torque X source code at all, except for some minor tweaks near the end. (Of course with the source code I might have gotten stumped less often, but still.) Shows how powerful the system is, I guess.

(I still wonder why interiors were taken out, since after all, even though the XBox 360 is pretty powerful, it's not so powerful that no optimization is needed. Though it is true that the optimization will vary quite a bit depending on what the game is like. Ah well.)

While porting Minigolf I wrote quite a few components that are of more general use, such as a reskinning component, a billboard component, a path component, and others. If I get a chance I may polish some of them up and post them here since they tend to illustrate things about Torque X 3D that I had to figure out more or less by trial and error -- might help others work it out more easily. Not to mention some of them are actually quite useful.

I mentioned earlier that I wrote some tools to convert the Quake .MAPs that Torque uses into .DTS format through 3ds Max. For anyone interested/curious/dying to get a hold of them, here they are:

Map Converter Tool - Binary
Map Converter Tool - Binary & Source

Documentation included. Even if you don't use Max, you may find it useful because it converts the .MAP into an easier format. From there it shouldn't be too hard to import directly into whatever program you do use. And of course, use at your own risk, there may be slight errors or occasional missing geometry, the code is a mess, feel free to redistribute and modify as you please, etc...

So there it is! There are still a few little things to clean up, but we're aiming to submit the game by the end of the week, though we'll spend more time if needed. Once submitted, it will be scrutinized by the other developers on the XBox Creators' Club, (hopefully) be approved, and be available for purchase!

(As a final ramble, let me just mention how amazing profilers are. With the help of the EQUATEC profiler and the CLR profiler, after little more than an hour or two of work, I got my memory allocation rate from about 8.8mb/sec to 7kb/sec, and I increased the efficiency of the sphere physics code by more than fivefold (i.e. it took less than 1/5th the time per call). Literally and without exaggeration.)

A few more screenshots (these are all from the Torque X version running on Windows):

Half Pipe Beach -- note how the text is shifted in from the edges so it doesn't get cropped by the TV.
i852.photobucket.com/albums/ab85/Newbot2F7/Hole14.jpg

Merri-Go-Round
i852.photobucket.com/albums/ab85/Newbot2F7/Putting.jpg

Vortex
i852.photobucket.com/albums/ab85/Newbot2F7/Spiral.jpg

About the author

Recent Blogs


#1
09/16/2009 (3:37 pm)
Neat! Does that mean were going to see this in the XNA games channel soon?
#2
09/16/2009 (6:51 pm)
Wow! I think there is a C++ to C# converter somewhere around google... Expensive, but there is a trial.

Does everyone on the GG community get a free copy? ;)
#3
09/17/2009 (8:55 am)
@Brett: Yes, that's the plan :)

@Matt: Interestingly enough, the C++ to C# part was fairly straightforward. I could basically cut and paste the C++ to some component and change methods/types as needed (e.g. mDot to Vector3.Dot). There were occasional snags but nothing too serious.

The part that confused me was what was going on behind the scenes as far as memory was concerned. I'd write "x = new Vector3()" but then I couldn't write "delete x" and that bothered me. I'd be done with a menu and want to get rid of it, but I couldn't delete it, just set all references to null -- who knows when the memory would actually be cleaned up. Then I'd write "y = z; y.w++;" and z would change too. Took a while to figure out what was going on.
#4
09/17/2009 (11:42 pm)
It sounds like it may be too late for your purposes but I do have to recommend using the "Export Interiors to Collada" feature of Torque 3D for people who need to get their DIF's into a 3d modeling application.

farm4.static.flickr.com/3308/3638056486_ecf7fc6eae.jpg


It'll convert the DIF into directly into Collada which means that it has the hidden surfaces removed (makes for a much more optimal mesh). Import into 3ds Max and add a basic DTS rig and you should be on your way in a matter of minutes (may need to add collision meshes). It'll also export a scene full of Interior's with their transforms baked in so that you don't have to reposition everything when you are importing them into Max or into your Torque scene.
#5
09/18/2009 (4:55 am)
Yeah, I Really Love That Feature In Torque3D.

Theres also an exporter From 3dsMax to constructor, also useful.

#6
10/13/2009 (10:14 pm)
@Matt - Seems like a pretty expensive tool you got there to just get a dif into a TX3D game LOL. Any chance we'll see this in a smaller tool or a really locked down binary of T3D available to people who have a TX3D license but not a T3D license? Something along the lines of John K's Sprite Works 2.0 would be awesome (locked down version of T3D).

Brian
#7
10/13/2009 (10:24 pm)
Brian,
Well...there *is* the free converter listed in this very blog =)

At this point we do not have any plans to offer a stand-alone "DIF to Collada" converter.
#8
10/14/2009 (12:21 am)
Matt,
Okay, that's cool. Was just a thought. I'm a big fan of interiors myself and wish they were available in TX3D. Even had a feature request before TX3D was out.

Brian
#9
10/19/2009 (12:45 am)
Liam's port of Minigolf Mania was approved and is now available for sale on the Xbox Live Marketplace:

marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d80258550333/
#10
10/19/2009 (3:18 am)
Wow that's great! Nice job :) Let us know how it does. There's far too little info out there about how games do on the XNA channel.