Game Development Community

dev|Pro Game Development Curriculum

DotNetTorque, the epic adventure!

by Vince Gee · 03/15/2012 (6:22 am) · 8 comments

I am now almost three months into the conversion of the starter.fps to Microsoft cSharp. Currently, I have finished all of the starter.fps/scripts files, all of starter.fps/core/scripts/server and now I'm working through starter.fps/core/scripts/client. It is definitely not an easy process converting Torque Script to cSharp. The difficulty is not due to the code not translating easily, but more due to the sheer amount of scripts to translate.

To get the best performance out of the engine, I follow this methodology:

- First try to find the exact extern (Actually, I am not calling the extern directly, but instead calling a stub which puts error checking, parameter preparation, etc.). There are over 1,000 externs but since I have organized them by the object types they modify it is quite easy to find the exact one you are looking for if you know what type of object you are dealing with. The externs are also named identically to their respective Torque Script function name.

-Second, if I cannot find the extern in the externs generated by my parser which reads the Define Engine blocks, I then look through the externs which I hand wrote for commonly used Console methods. Since Console methods need to be hand generated, I do not have them all registered inside of DotNetTorque.

-Third, if I cannot find the extern in either of the above two methods, I still have a few more tricks up my sleeve. I can wire directly into Torque Object's evaluate blocks. So, you can do:

Call(simobject,function,new string[]{params});
Call(simobject,function);  no params
Call(function,new string[]{params});
Call(function); - no params

These make direct calls to evaluate so the console has minimal utilization.

-Lastly, if all of the above methods fail, I can always call an Eval(script code) which will execute the passed Torque Script Text to the console and evaluate it.

That pretty much wraps up how to call back to the Torque Engine dll. I do need to add a couple more Call functions to the library for Namespace::function calls but in general I am very satisfied with the current state and progress of the project.

Winterleaf Entertainment still anticipates having a dedicated server up and running by the end of the month with a downloadable client for people to experience firsthand the performance gains by converting the script code to cSharp. It really is amazing how much smoother the engine runs when you minimize interaction with the console.


Vince

#1
03/15/2012 (9:17 am)
Very impressive! Does this mean that DotNetTorque could be used with XNA and Xbox Indie games?
#2
03/15/2012 (9:40 am)
unfortunately no, since all I am doing is wrapping Torque with C#, instead of writing Torque in cSharp.
#3
03/15/2012 (1:26 pm)
Ok. Thanks for the quick reply and keep up the good work!
#4
03/16/2012 (9:22 am)
Why not have your team work on Torque X 3D I remember back when it was first release it had split-screen and a nice interface?

But I love what you are doing keep the great work up I just wish this could take t3d to torquex3d and allow you to add your game to XNA.

but thanks for the update :)
#5
03/19/2012 (7:33 pm)
I am wondering if this could open up a new way to create custom tools for Torque using C# code to call the new C# Torque script? Maybe this defeats the purpose...but somehow I see a new C# application running a custom Torque OpenGL rendering window control (like Unity's app builder). anyway, can't wait to see the final product!

#6
03/20/2012 (6:29 am)
You can control anything inside of torque by calls directly to the engine. So yes, I do foresee new tools being able to be built with this.

One of the things we are working on now is swapping out the Torque Gui w/ Windows Presentation Layer overlays, as well as a generic chat server for torque. This build basically allows you to hook csharp to any torque event.
#7
03/20/2012 (12:28 pm)
Have you thought about writing a C# program that will convert torque script to C#? Even if its only 90% accurate it would be much faster to run it then go in and clean up.
#8
03/22/2012 (4:18 am)
Right now I'm in the process of converting the starter.fps. I might be able to write a converter in the future but it would be a single file converter, as in you load the script and it spits out csharp.

The problem is that torque script is not a typed language, so from a converters view, it would not know what type of objects the param's are. That being said, I don't think it's impossible, but right now I'm focusing on converting the code manually so that I can catch bugs and such as I go.