Contents
Integrating MaxScript and .NET Systems
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [12]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Trion Redwood City
Sr. Evnironment Modeler
 
Trion Redwood City
Sr. Environment Artist
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
Texture Artist
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
 
Sony Online Entertainment
Brand Manager
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [7]
 
arrow iPhone Piracy: The Inside Story [48]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Time Fcuk
 
Accepting the Inherent Value of Games
 
Planckogenesis, Part II: Song Structure & Gravy Train [1]
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Integrating MaxScript and .NET Systems
by Shea McCombs, Kevin Rabun
7 comments
Share RSS
 
 
September 9, 2008 Article Start Previous Page 5 of 5
 

Conclusions

We have been using this solution at Vicarious Visions for one year. We have shipped one Nintendo DS project, Kung Fu Panda, and are currently supporting three ongoing Nintendo DS projects and one Xbox 360 / PlayStation 3 project.

Advertisement

Overall, we have had great success using this solution. We have been able to leverage the various systems that 3DS Max provides to alleviate redundant work, which we would have needed to do if we had built a system from scratch. There are factors to consider before integrating existing toolchains with 3DS Max, but they are no different from any other large-scale integration project. Integrating 3DS Max with .NET allows for two distinct disciplines, namely technical art and engineering, to work together cooperatively in developing programs, rather than working in isolation.

In the end, integrating .NET applications with 3DS Max through MaxScript consolidates a great deal of functionality from different applications within a single user interface that artists and designers are already comfortable using.

Downloads and Documentation

MaxScript Help File Sections
- DotNet in MaxScript
- Registering Windows SystemEvents Callbacks Using DotNet
- Loading Assemblies

MSDN .NET Framework
- http://msdn2.microsoft.com/en-us/netframework/default.aspx

Microsoft Visual C# 2005 Express Edition
- http://msdn2.microsoft.com/en-us/express/aa975050.aspx

Appendix I: Benchmark Source Code

MaxScript Code

function maxscript_test_fn input_array =
(
accum = 0;

for val in input_array do
(
accum += val;
)

accum;
)

DotNet.LoadAssembly "Benchmark.dll";

function benchmarkDotNet samplesize:10000 testlength:10 verbose:false =
(
dot_net_object = DotNetObject "Benchmark.BenchmarkClass";

[Get a reference directly to the method, avoid name lookup; matches native MaxScript behavior more closely.]
dot_net_object_test_fn = dot_net_object.Test;

sample_data = #();

for i = 1 to samplesize do
(
sample_data[i] = (random 0 10) as Integer;
)

[Make a result buffer to avoid any 'lazy evaluation' optimizations MaxScript might do because nothing is using the return value of the function. Also pre-allocate the array to prevent any runtime allocation which may affect one of the loops.]
result_buffer = #();

for i = 1 to testlength do
(
result_buffer[i] = 0;
)



timer1 = timeStamp();

for i = 1 to testlength do
(
result_buffer[i] = maxscript_test_fn sample_data;
)


timer2 = timeStamp();


for i = 1 to testlength do
(
result_buffer[i] = dot_net_object_test_fn sample_data;
)

timer3 = timeStamp();


maxscript_time = timer2 - timer1;
dot_net_time = timer3 - timer2;


if (verbose == true) then
(
format "Results:\n";
format "\tMaxScript : %ms\n" maxscript_time;
format "\tDotNetObject : %ms\n" dot_net_time;
)

#(maxscript_time, dot_net_time);
)

function runFullBenchmark =
(
sample_sizes = #(16, 1024, 131072);
test_lengths = #(10, 100, 1000);

for test_length in test_lengths do
(
for sample_size in sample_sizes do
(
time_results = benchmarkDotNet samplesize:sample_size \
testlength:test_length;

format "[size=%, length=%]\tMS:%\tDN:%\n" sample_size \
test_length time_results[1] time_results[2];
)
)
)

C# Code

using System;

namespace Benchmark
{
public class BenchmarkClass
{
public int Test(int[] buffer)
{
int accum = 0;

for (int i = 0; i < buffer.Length; i++)
{
accum += buffer[i];
}

return accum;
}
}
}

 
Article Start Previous Page 5 of 5
 
Comments

Klaus Drobec
profile image
As usual, I appreciate the quality of your feature articles very much. As a small point of critique: For articles with long code sections, could you please make an effort at formatting those to a more readable form. As I've seen blog software do this automatically, my guess is a large online offering such as yours has appropriate solutions at hand.
Much obliged.

Simon Carless
profile image
Klaus - looks to me that the main issue is the in-code comments overflowing lines on the code excerpt on Page 3, correct? Going to see if we can fix that, thanks.

Joel Martinez
profile image
"One of the key features of C# is that it is a reference-based language, and pointers do not exist."

This is actually not quite right :-)
http://msdn.microsoft.com/en-us/library/y31yhkeb(VS.80).aspx

Rune Braathen
profile image
Thank you very much for an informative article.

The .NET integration-features that have been introduced into MAX is a step in the right direction, but there are some shortcomings that may benefit from the act of being brought to the surface, in case someone out there were dancing a mazurka of joy, thinking they could throw out the MAX sdk come blue morning.

The ability to interface with MAX datatypes from the .NET assembly is practically nonexistant. As a result, shuffling large portions of data to the .NET-side therefore requires iterating the data. This e.g. hardens the possibilities of quickly performing a very common plugin task: munching geometry.

Hopefully, integration will become a bit tighter in the future, although I would rather prefer they put their weight on making MAXscript run faster.

Chaitanya Munjuluri
profile image
I made a level editor in 3DS Max 5/6 back in 2003/2004. We were using Renderware as middleware. There were two main components to the editor I had made. Level building and ai/gameplay related data. I used 3DS Max purely as a user interface and a nice render interface. Artists would export the models from 3DS Max to Renderware specific format and put all of these into a library. Levels were built by placing an art asset from the library. I would save the level to Rendeware's level format by refering only to the asset id (name). The ai/game play artists would build the path nodes and place gameplay data using 3ds Max nodes that I had built after deriving from the 3DS Max Dummy objects. All of the ai and gameplay data was stored in XML files (used Xerces to parse the data). Come to think of it the most difficult part of it was to import Renderware 3D mesh data into 3DS Max and displaying it as 3DS Max geometry.
I had such a bad time with making the UI for the tool. I could never make it as good as I would have liked.
IIRC Maxscript cannot access everything that's visible in the UI. For example I had issues with using the "loft" tool in Maxscript. Not sure if anything's changed now. I used Maxscript essentially for raising events and for the UI. The majority of the work was done in the 3DS Max Plugins.
Could you tell us something about the formats in which you had exported the data from 3DS Max?

Luke Rymarz
profile image
From the article:
"For some developers, integration with 3DS Max may mean rewriting thousands of lines of code within .NET, and each developer will need to assess how reasonable that would be to achieve."

I've been in positions where I needed to get a lot of old C code into C#. Lucky for me, it was in a DLL, and C# makes running DLL functions relatively easy with platform invoke. Microsoft has a tutorial at http://msdn.microsoft.com/en-us/library/aa288468.aspx.

You'll have to marshal data between the DLL and your C# code, but there ends up being about 10 basic types of marshals (string, array, pointers, etc etc), and once you've got a handle on them, building a class that will run all your DLL functions for you becomes pretty easy.

Anyways, just my two cents. With platform invoke, you'll still have to write a good bit of C# code, but you don't have to rewrite (and re-debug) the code that does most of the work.

Erwin Abdulrahman
profile image
thanks for sharing


none
 
Comment:
 


Submit Comment