Performance: XSI vs. Max vs. Maya
A really interesting article, benchmarking the three major 3D programs in a variety of activities.
http://www.3dspeedmachine.com/?idna=33
Overall, XSI had a very strong showing, with Maya second, and Max a distant third in most tests. Unfortunately, these tests were rigged, as spacefrog points out here:
http://www.tech-artists.org/forum/showthread.php?t=222
No commentsMax Bug: Looping through collections
Looping through a collection, such as lights, geometry, etc., will hang up Max into an infinite loop if you change the hierarchy of the member you are iterating on directly (for g in geometry do, for example). It only does this when you iterate directly on the collection.
Iterating through the collection with an index iterator (for i = 1 to geometry.count, for example), the behaviour is different- the object you parent moves to the end of the collection, so you process some members more than once and some not at all.
The workaround is simple- just cast the collection as an array and loop through that instead.
No commentsMax Bug: Recursion/Stack Limit
As a followup to the previous bug about recursion, Neil Blevins recently made a post at CGTalk about a similar issue. This is from Bobo:
MAXScript has a hard-coded (in Max 9 and higher) stackLimit of 2048000 bytes. The return addresses of function calls are put on the stack, so you might be overflowing the stack. If the limit is exceeded, a Runtime error should be displayed, but Max should not crash.
Prior to Max 9, the size was 1024000 and you could increase the stackLimit value. Now it is twice that but you cannot effectively change it.
This followup post from Neil:
So apparently this is a known issue, and is basically a problem that can affect any software written in C++. The only way to avoid it is to not use recursion, so you’ll never blow your stack.
This problem really sucks; any sort of deep recursion is not doable in MaxScript (though simple ones like traversing hierarchies are probably OK). What I find most upsetting is there is not way to increase the stack limit, there is no information given by Max about exceeding the stack limit, and with Max’s terrible and bloated memory handling, any deep recursions are impossible. Even Neil’s simple test case crashed after only 1300 recursions (just adding one to a counter and printing the value). Quite a shame.
No commentsMax Bug: CTD on endless recursion
Something I had planned to do eventually was a blog dedicated to Max bugs. Since this blog doesn’t seem to be used for much else at the moment, I figured I’d get this started.
First bug is, Max will CTD if it gets caught in an endless recursive loop. For example:
fn something = ( 1 + 1 something() )
Will crash max, much faster than a normal exit. So instead of hanging in an endless loop (like an endless While loop does), or realizing the loop is endless and throwing an error, Max just CTD’s.
No commentsConvert Hex to Float
Here at Volition, we store all of our transform and mesh data in our intermediary format as Hex. This is primarily done to address floating point precision issues, nothing new there. However, when you are data-mining or looking for other crap in those files, it sure would be helpful to use that Hex data!
Well, in Python, here is a handy little function that will take a Hexadecimal number and return you an IEEE float.
def hexToFloat(hexstr):
intval = int(hexstr, 16)
bits = struct.pack(’L', intval)
return struct.unpack(’f', bits)[0]
- Jason
1 commentPython Operator Overloading
If you aren’t familiar with the phrase ‘Operator Overloading’, it is basically the giving of a different meaning to a program’s operators like + or ==. Programming languages such as C, C++, Java, Python and many others offer this ability.
So when and why would you ever want to do this? Well, for myself, I actually ran across this need today with a tool I’m working on. I didn’t actually think Python had the ability to do this until I did some Googling on the Internets.
I wrote a Vector class in Python that had members for the X, Y and Z components. So, to see if two vectors are the same, I would have needed to do this:
if vec_a.x == vec_b.x and vec_a.y == vec_b.y and vec_a.z == vec_b.z:
…do something here…
Well, thats just messy to look at and is a pain to write out. Wouldn’t it be nicer if you could just say:
if vec_a == vec_b:
…do something here…
You can do this as long as you overload the operator. To overload the operator, you need to implement the overload function(s) within your class object. To overload the equality == and non-equality != operators, you use __eq__ and __ne__.
Below is some Python code that shows how to do this:

The one problem with overloading an operator is that it can sometimes become confusing when something is or isn’t overloaded. But I can’t offer and suggestions that would make it easier. I think that is a risk you take when doing something this.
Well, I hope this short post gave you some insight into what operator overloading is and how to use it. For more information, I recommend these sites:
http://en.wikipedia.org/wiki/Operator_overloading
http://docs.python.org/ref/specialnames.html
Thanks.
- Jason
2 commentsWelcome to the Tech Artists Blog
The Tech Artists Blog is a place where TA’s can share their thoughts with everyone else. To visit a blog, simply click on a name under Categories on the sidebar.
No comments