Showing posts with label Torque. Show all posts
Showing posts with label Torque. Show all posts

Thursday, May 23, 2013

Learning Unity


Yeah, just what I need is another technology to learn. After a few years of teaching XNA (before that Torque, before that Java, before that J2ME and somewhere in there a quick detour for Second Life/LSL)  it seems like the world is shifting around me again. I did some quick Android apps last year, but still wanted another layer above me to allow me to release on multiple platforms. Unity keeps coming up in conversation and after a few quick tutorials and calls with a good friend who already climbed the learning curve I seem to be picking it up quickly. I had to drop it again for a few months as I got busy, but found some time recently to dig in again. So far pure joy. I've found a tool that was programmed by someone who understands.

A couple of really small things have made me really appreciate the person who created Unity. Meaning it's really well designed.

This guy gets it.
http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Deg2Rad.html
This guy was an intern (as was most of the DirectX/XNA code base in my opinion).
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.mathhelper.toradians.aspx

This will cause some arguments, but why create a function/method (XNA),

float deg = MathHelper.ToRadians((float) 1.0);

and I don't know for sure that C# does create a stack frame or not for this call, but why even chance it.  I know it's only a few extra instructions and one extra push onto the stack (if that's what it does), but if I run that a lot it's bound to do a little extra processing that I might not want to have on a slower/older device. I grew up with limited memory and CPU so I still know that every instruction is still a percentage of your maximum throughput. The less you use, the more you can do. For short, every single instruction still counts.

When this most definitely doesn't have any extra over head. (there might be an offset instruction for the Mathf. part, but not a (possibly) full stack frame creation).

float deg = 1.0 * Mathf.DegToRad;

This and a couple of other small things, like the ability to create/change a model in Blender (free) and have it automatically be updated in my game is a huge bonus. I love Blender and have struggled to use it with every game engine and with unity it's automatic. That's huge.  I can use 3ds max fairly well, but that expensive license every year for the simple stuff I build just isn't affordable.

Anyway, loving Unity after a few weeks of working with it.  Have a fun little game mechanic coming along.

Friday, April 10, 2009

Testing some shading options

As I've been testing lately, you can purchase all the source code for this sample for $5
(http://store.payloadz.com/go?id=254377).

I’ve been testing some shading options and working on the 3D aspects of XNA that I have been needing to learn. One of the problems is that I have 3DStudioMax, but it is only on a machine I don’t use as much. I’ve been contemplating moving the license, but that has issues. I’ve used Blender in the past and have enough knowledge to be dangerous to myself, but went back to it as I have not been able to use Max when I need it. So, this was as much a Blender session as an XNA lighting session.

I’m using Reimer Grootjan’s book XNA 2.0 Game Programming Recipesand found it very helpful in the shading and rendering aspects. I know it’s for XNA 2.0 and I’m using XNA 3.0, but the stuff I’m looking at has not changed (as is most of the book) so it is still highly relevant to learning XNA 3.0.

The section I used was on directional lighting on page 514. It shows how to get the BasicEffect to work with a directional light.

My code looked like this when I was done.

effect.LightingEnabled = true;
effect.DirectionalLight0.Direction = light0Pos;
effect.DirectionalLight0.DiffuseColor = Color.White.ToVector3();
effect.DirectionalLight0.Enabled = true;
effect.PreferPerPixelLighting = false;
effect.DirectionalLight0.SpecularColor = Color.White.ToVector3();
effect.SpecularPower = specPower;
With, specPower and light0Pos set at the top of the class definition.


Vector3 light0Pos = new Vector3(-0.5f, -1.0f, 0.0f);
float specPower = 64;
After weeks of procrastination and thinking I was going to have to create a custom shader it was nice to find out that adding a directional light was very simple. One of the games I was going to do requires a spotlight and I do think that will require a custom shader so it's off the list until I get some extra time.

So, first up with Blender. I’m trying to display a gemstone. I created a isosphere then scaled and stretched it to look like a gem stone. Then I added a red texture. You can see that I set the Col (Color), Spe (Specular Color) and the Mir (Mirror Color) for the gem.


This was fine, except that the gem came out all smooth.


I know from experience that this is caused by the rendering system using vertex normals to draw the individual triangles of the gem as smoothly as possible. This is almost always the case. But for a gemstone, you want it to have facets. I spent a ton of time trying to figure out how to get blender to remove the vertex normals and only use surface normals.

This ended up being easy inside of blender, but took a while to figure out how to get this information into the direct X file. To do this in blender, you select the object in edit mode, then click the Set Smooth button to use vertex normals for rendering and Set Solid to use surface normals for rendering.


Easy and you can see the two rendered versions here.


That’s all well and good in Blender rendering, but XNA kept displaying the gem as a smooth surface. After tons of fiddling, I noticed one of the options on the Blender DirectX exporter was “no smooth”. The tool tip says exactly what I wanted to hear “Every vertex has the face normal, no smoothing”.



Once I exported with that setting everything worked.



Getting back to Blender, I found it really hard to learn, and hard to relearn, but for the price (Free) it really is an amazing tool. I have a book on it that I've barely touched called Introducing Character Animation with Blender by Tony Mullen. I've had it for a few years and only touched the surface on it and every time I pick it up I'm always impressed. It really does look like a great book. As I write this he has a new version due out soon and another book on Blender that was just released. See below.

My real problem with Blender came in the classes I was teaching on Torque last year and the fact that we could never get the bone systems to work properly. It seemed that 3DSMax was the only real way to do modeling for Torque. Maybe that has changed?

I did find this great reference image on the Blender hotkeys (http://en.wikibooks.org/wiki/File:BlenderHotkeysObjectMode.png. If you are going to use Blender, you are going to want to learn as many as possible. It really is a fast fast tool once you get to know the UI. Mostly I only use Space Bar, B (box select), A (select/deselect all), S (scale), R (rotate X,Y,Z).




As I've been testing lately, you can purchase all the source code for this sample for $5.
(http://store.payloadz.com/go?id=254377).

Thursday, January 24, 2008

Torque Closer To Browser Based Games

Torque is a popular game engine in the indie 3d game development community. Lately there has been a lot of buzz about a new browser based plugin that will allow people to play fps (or walk-through virtual world) style Torque games directly from the browser. The site is still not live, but it did open recently for signups and looks to be much closer to a final launch.

http://www.instantaction.com/

There still isn't a lot of information on how this works, the business model or if independent developers will be able to launch titles on the site. At least I have not found much. It is looking more like it might be the equivalent to the next generation gaming console right in your browser so it looks like something interesting to watch. Stay tuned.

Wednesday, May 2, 2007

Torque Development Process

I find that I like the workflow in developing games in Torque. As long as you are just using the base engine without any c++ changes to the engine itself it is as simple as keeping the engine exe file in the same directory tree as your script code and just running the engine for each test pass. The engine will automatically compile your scripts to bytecode if the source has changes since the last compile. Once you are ready to release you simply copy everything to a release directory and remove all the source.

I'm betting you could do 99% of your game this way unless you really chose to do something that was out of scope for the actual engine. In that case you would either need to choose a different engine, or make a lot of mods to the C++. In any case, I do like the workflow in developing for Torque. Even those mods are pretty simple.

It is a little strange since I remember at first thinking it was crazy that I had to re-run the engine after every change. It just seemed to go against the grain of what I'm used to, but now that I think back on it, I do tend to re-run everything no matter what platform I'm developing for. Maybe it was just that I wasn't used to the engine actually doing the compile and expected a traditional environment of having to compile before running? In any case, it is a good system.

Tuesday, May 1, 2007

Torque Introductory Tutorial

I missed class last week because I've been sick. I'm feeling better now and I've been working on this week's lecture. I found that when I got stuck on one of the examples I was building I immediately went back to the introductory tutorial that comes with the engine. It's file name is GettingStarted.pdf and it is in the examples directory. This really is a great place to start and I find myself returning to it for quick refreshers. I found one online here, but I don't think it is supposed to be there.

Anyway, if you are going to use Torque, keep this tutorial handy.

The student's marketing materials are due tonight. Just a simple screen shot and 1 page of html. Just enough for me to get something out to the judges so they can get a preview of the games they will be judging.

Wednesday, April 18, 2007

Is Torque the best game engine for my project?

I was asked in an e-mail if Torque would be the best engine for a specific project. I wasn't given much information on the project, but this is my opinion on the matter.

For commercial games Unreal is the king and owns about 90% of the market. It is in the $100-200k range to license so it is out of reach for anyone that isn't very very serious. I'm not completely sure on the pricing because it's something that isn't advertised. They price it on a case by case basis and we tried to get a license for Chapman University and that was the range we were given.

The next most popular engine for commercial games is a tie between Quake and Half Life. Both have similar licensing expenses, but rumor has it that the Half Life engine is very hard to understand. I don't know first hand. Of the three I think Unreal is probably the easiest to learn having spent some time with it. Torque has a very strong following, but is mostly seen as a hobbyist engine. That doesn't make it bad by any means, but that is the view. It is well supported and while there is a steep learning curve, it isn't any steeper than the other engines out there. There are a number of commercial games available on it and the company just released a next gen version of the renderer so it is still growing and doing well.

The next thing to keep in mind is the game itself and if the engine supports the type of interface you are designing. Each engine has different specialities and one engine may be best for one design and wrong for another. Torque is best at FPS or third person multiplayer games. There is also a 2D version of the engine which I would also highly recommend.

Torque Game Engine (3D) does not have a good physics engine. I think the others are better, but there are a lot of threads out there on the Torque forums that talk about integrating other physics libraries. The 2D version has a great physics library.

Friday, April 13, 2007

Torque - Torsion IDE or Eclipse

I've been trying the Torsion IDE for Torque Game Engine this week. Before I was using TextPad or CodeWright and just managing the projects by hand. It wasn't a big deal before, but I did have to find the error lines by hand.

The biggest difference is that the error output has a clickable interface and keeping the errors red makes it much easier to find the errors in the log. My only gripe so far is that the log window is not searchable which is annoying, but it has really sped up my workflow in so many other ways that I think I'll probably buy it when the 20 day trial is over.

I've seen some mention a that there is an eclipse plugin for Torque. I've been a long time user of NetBeans. I typically find an environment that I like and stick with it until it's either irrelevant or something very compelling gets me to switch. I'm doubting the Eclipse plugin is as closely tied to the Torque engine (it has a built-in debugger I have not yet tried) as the Torsion IDE and wonder if the error logs are hot linked to the source lines?

Has anyone tried the Torque plugin for Eclipse and have any insight? It might save me some time and frustration of learning yet another IDE although that will probably start some sort of flame war with people pitching one IDE against another. My view is that the tool that works for you/me is the best tool and it's just not worth arguing over.

Thursday, April 12, 2007

Torque Script - datablocks - very confusing

It took me quite a while to really understand datablocks in Torque. All the books say exactly the same thing.


Of all the features in TorqueScript, Datablocks are probably the most confusing. To make things worse, they are central to the creation of most objects, which means you need to understand them relatively early.

I think all the books plagiarized this from the official documentation on datablocks.

Datablocks are just shared objects that contain static data that doesn't change from one object to the next. So the engine can send it once over the network and reference it by id from then on. I get this and I think every explanation made this perfectly clear. The problem is that all the callbacks from the engine into the script code comes through these datablocks. For instance:

datablock StaticShapeData(SomethingData)
{
// Basic Item properties
shapeFile = "./mymodel.dts";
};
function SomethingData::onCollision(%this, %obj, %col)
{
// your code here
}
This really confused me and I was trying to create my own object types to no avail. The code above creates a type SomethingData which will show the 3d model contained in the file mymodel.dts. This is fine, but the call to onCollision is done on the datablock object (SomethingData) versus the object itself which in this case ends up being a StaticShape. Since the datablock is static and shared across all instances I couldn't figure out why or how you kept data in individual objects.

I finally had an epiphany when I noted that %obj is always passed into the callbacks and is the actual object instance. Individual changes and values can be made in this object. Seems simple enough now, but this killed some brain cells for me.

So I placed this comment in one of my pieces of sample code for class.

function SomethingData::onCollision(%this, %obj, %col)
{
/* * MANTRA - REPEAT OVER AND OVER UNTIL DATABLOCK UNDERSTANDING SETS IN
* 1. %this is the datablock * 2. %obj is the object instance
*
* of much less importance
* 3. %col is the object colliding

Here is the lecture where I tried to explaing this. I think the notes are still a little jumpy, but the in person version seemed to clear things up for students. Your fuel economy may vary.

Wednesday, April 11, 2007

Torque Script - Behind The Scenes

Torque script is the scripting language behind all of the Torque Engines is a simple, but robust scripting language that is very easy to learn. All game engines include a scripting engine and Torque is no different. For non-game developers, the idea of a scripting language may seem like a negative, but there aren't any commercial games that don't use a scripting language.

Most non-game developers may at first think that this means the source to parts of your game are shipped with the game, but this is not the case. Torque script is compiled into a bytecode format and saved to a separate file (.dso extension). Everytime the game engine runs it does a date comparison between the source (.cs) and the compiled files. If the source is newer, it re-creates the bytecode file. If the source file does not exist, it simply uses the bytecode file. You simply ship your final version without the source files.

This is transparent and very fast. When you are developing games using this system you never see the compile taking place. One drawback of this system with Torque is that it isn't blatent when compile errors happen and you have to go back and look in the logs when you've made a bunch of changes. In most cases I've seen it will simply use the older .dso file and you'll be caught wondering why that echo/printf you just put in the code isn't appearing. As with most tools, once you get used to it, it is not really a problem. There is an editor called Torsion that will check/monitor your syntax, but I have not tried it. Everything I've read says it is highly recommended.

Tuesday, April 10, 2007

Torque Game Builder - TGB

Torque Game Builder (TGB) is another product I used in my game development class. It is a 2D version of the game engine that uses the same scripting language as the Torqe Game Engine (TGE) which is 3D.

Torque Game Builder was much more polished as a product, but it doesn't include source with the indie or edu license which is a disappointment, but not a good reason not to use it. This class was supposed to be a 3D class, but I did use the TGB for two weeks at the beginnning of class to give students an easier introduction to the scripting language. It was a lot easier to deal with the scripting language without the added third dimension. Once you add that third dimension everything gets more complicated.

Another big difference between the two is that TGB has a much better physics enginee. The physics engine in TGE is not as robust, but it does work for most FPS style games. The TGB physics engine has all the bells and whistles you would expect. As with TGE, TGB includes a multiplayer networking engine at it's core. Even single player games would have the networking code attached at the core. It's not a lot of over head, just the design for multiplayer at it's core. If you are going to develop a multiplayer game I do suggest buying the full license ($495) so you have the source and can run multiple clients on the same machine during development.

I think the TGB is very easy to learn and a great platform for building 2D games. For $100 there is no comparison.

Tuesday, April 3, 2007

3d game development tools and Torque

The tools we chose for the game development class were driven mostly by the choice of books, but many of them are cheap/free and industrial strength as well and I would use most of them on my own projects even if I had some sort of budget. The engine we are using is Torque, but all these tools would be useful no matter which engine you use.

PaintShopPro is a great paint program. The first edition of the book used this tool, while the second edition uses Gimp. Since I already had a number of students in an earlier class that had used PSP I chose to stick with it. Also, it is my favorite paint program and in my opinion better than Photoshop for everything except CMYK. I've done a ton of image and print work over the years and PSP is an amazing value. Corel bought it from an independent developer a few years ago and I've been expecting a $400 price increase. I'm sure I'll grudgingly switch to Gimp if that happeens.

Milkshape is the tool used in the book and we made sure it was available for the students. It's not the best 3D tool by a long shot. It is missing a lot of features which also makes it a lot easier to learn. A double edged sword, but still a great value for $25.

For texture mapping you have to used a second tool called UVMapper. It's free and easy to use.

QuArk (Quake Army Knife) (free) is the tool we used to create interiors. Interriors are BSP trees that have a lot of properties that speed up rendering and collision detection. The cost is that the tools that do BSP are all very confusing and QuArk is no different. If you use QuArk for Torque, make sure you read the PDF tutorial that comes on the Game Programming All In One CDROM (it's not printed in the book any longer). It is a great tutorial that will take a lot of the guess work out of a confusing UI. Also, make sure you download QuArk from the Garage Games site and not the one main site as it's already configured for Torque. The Unreal editor is a BSP editor and it is just as confusing. Just because you pay more you are not going to find a good BSP editor.

Audacity (free) is not my first choice of audio tools, but my first choice (CoolEdit by Syntrillium) was purchased by Adobe and the price raised by $400. I'm not one to pay hefty fees for software and have found that I can live with Audacity. I'm going to be really mad if Corel does the same thing with PaintShopPro.

Blender (replacement for Milkshape) is my last tool of choice and it is a controversial one. You either love it or hate it. Blender was a commercial 3D editing tool that moved into the open source community driven world and is well updated and supported. It is absolutely free. That's not the controversial part. You either love it or you hate it as the UI takes a little getting used to, but once you have it down it is extremely fast. The commercial equivalent is 3D Studio Max and is used by 98% of the game studios. My only problem with it is the $3500 price tag. I'll do another blog entry just on Blender.

That's my list of (cheap/free) software to use in 3D game development.

Monday, April 2, 2007

Books to use with Torque

In choosing books for the game development class I am teaching we really only had three choices for the class. I don't belive I made the best choice with the limited time I had to choose and would choose differently now.These are the two books I would choose for the class if I had to choose again.

3D Game Programming All In One and Advanced 3D Game Programming All In One.

These two books compliment each other very well. The first book is more oriented towards a general overview and the tools to use and the second one has a much better focus on Torque Script and programming.

The other book that I would leave off the list is:The Game Programmers Guide To Torque

I thought this book would serve as a better reference, but it seems to be a wiki that was turned into a book and isn't detailed enough as a reference, or descriptive enough as a book. It jumps around too much and doesn't help give a clear understanding.

Friday, March 30, 2007

Why use Torque as a game engine?

As I said in my previous blog entry I've been teaching a game development class using the Torque Game Engine. There were a number of factors that lead to the choice of Torque.

The early meetings with the curriculum board lead to the adoption of Unreal as the engine of choice. As the fall arrived and I had been spending months working with Unreal, reality began to sink in. Since this was a programming class there would have to be more to it than just level editing. While Unreal script is programming I also wanted to be able to have the students understand the actual C code behind the engine. Without access to the engine source this would mostly be a level editing class. The Computer Science department wanted to make sure this was more of a programming class than a level editing class.

In general, there are always C code tweaks to an engine to make any game so anything short of source code would not be a realistic environment for the students. Workable, but not realistic.

When the department attempted to license the Unreal engine it was out of the budget. Rumor had it that it was in the 100s of thousands which was way outside the budget for an edu setting! Another factor was the majority of the official documentation for Unreal requires that same license. While there is a lot of independent documentation on Unreal and this may not be a problem it was a factor in our decision.

Torque had come up in earlier discussions and a review showed it was actually perfect for the educational setting. At around $100 a seat, it included the source. That decision was made in December and I've spent the past few months trying to stay ahead of the students while I learned the ins and outs of Torque. Stressfull, but I think the results I am seeing from the students are amazing.

Thursday, March 29, 2007

Torque Game Engine

This semester I've been teaching a class on game development at Chapman University. The class website is http://www.gamedev360.com/. It is the biggest reason I have not blogged in a while. Secondary was my last post on procrastination which sort of helped me see blogging as a distraction. We are using the Torque Game Engine for the class and so far I am impressed. There are some things I really like about it and some things I don't and I'll come up with some posts along those lines in the future.

My previous gig was called GameWorld.com developing mobile games. During that time I was teaching some other classes (Assembly Language, Computer Architecture) and lobbied the head of the department to teach a game development class. After five years, that finally came through last year and I taught the first class. Last summer the department created a curriculum board of industry professionals to come up with a minor and certificate program. This semester is the first class as part of the minor. Very exciting.

The website for the current class is http://www.gamedev360.com/. Please feel free to comment or contact me about Torque. I'll be writing more about Torque and game development in the future.

Friday, December 1, 2006

All Things Software Development

I've decided to create a blog on some of the fun development stuff I'm always working on. This will be an on again off again blog as I go through cycles of development. Most of my fun code writing is for Gaming so this will probably have a strong gaming tilt. I've been working a little with Flash, Linden Scripting Language (lsl/Second Life), and Torque on the fun side. On the business side, it's all about Java, C and C++. Hopefully this is useful for more than just me. I'm planning on using this as a sort of notebook so I can come back here and find code samples and reminders when I'm working on projects that have become a little stale in my mind, which takes about 30 seconds.