MaxScript: Converting between FFD Space and World Space

This code snippit will only be useful to a very small amount of people out there. In 3DS Max if you’re working with a Free Form Deformation (FFD) modifier, it operates in its own modifier space which is a pain in the butt to work with. This code will convert to and from the different spaces.

(
-- This script converts from FFD space to world space and back again.
-- Neil Marshall 12/31/2011
-- If you use this code, give me credit.

fn FFDSpaceToWorldSpace obj ffd controlPoint =
(
if classOf controlPoint != Point3 then
(
print "Error: You need to pass in a point 3 to properly convert a FFD to world space"
return undefined
)

objTM = obj.objecttransform
modTM = (getModContextTM obj ffd) * ffd.lattice_transform.value
modBBMin = getModContextBBoxMin obj ffd
modBBMax = getModContextBBoxMax obj ffd
size = modBBMax - modBBMin
thePoint = modBBMin * inverse ffd.lattice_transform.rotation + (controlPoint * size) * modTM * objTM
return thePoint
)

fn WorldSpaceToFFDSpace obj ffd worldSpace =
(
objTM = obj.objecttransform
modTM = (getModContextTM obj ffd) * ffd.lattice_transform.value
modBBMin = getModContextBBoxMin obj ffd
modBBMax = getModContextBBoxMax obj ffd
size = modBBMax - modBBMin
thePoint = (worldSpace * (inverse objTM) * (inverse modTM) - modBBMin) / size
return thePoint
)

while $tester != undefined do
(
delete $tester
)

obj = $Box01
animateAll obj.modifiers[1]

print ("Before FFD Space: " + obj.modifiers[1].control_point_3 as string)
thePoint = FFDSpaceToWorldSpace obj obj.modifiers[1] obj.modifiers[1].control_point_3

if thePoint != undefined then
(
print ("WorldSpace: " + thePoint as string)
point name:"tester" pos:thePoint
obj.modifiers[1].control_point_3 = WorldSpaceToFFDSpace obj obj.modifiers[1] thePoint
print ("After FFD Space: " + obj.modifiers[1].control_point_3 as string)
)

""
)

Comments off

Creating Stretchy Bones in 3DS Max

I’ve recently become interested in trying to emulate the Elastigirl rig in 3DS Max as a personal challenge and my first hurdling block was to create stretchy bones. I figured out method two by reading the help files and I was told about method one by someone at work. I’m not sure yet if there is much of a difference but I’ve listed both here. Hopefully it will be helpful because I was searching Google for way too long to find these.

Method 1 – Dummy Object
- Create a bone with a stub.
- Create a helper Dummy object.
- Align the Helper Dummy to the stub with both its position and orientation.
- Select the Nub.
- Animation -> Constraints -> Position Constraint
If you move the Dummy now you’ll notice it breaking off of the nub.
- Select the main bone.
- Animation -> Constraints -> Orientation LookAt Constraint and click on the Dummy object.
Selecting the Dummy now should result in the main bone stretching.

Method 2 – Plain Bones

- Draw a bone with a stub.
- Animations -> Bone Tools…
- Select the main bone.
- In the Bone Tools dialog at the bottom un-check the Freeze Length button.

IK Stretchy Bones
As I’m trying to recreate stretchy arms, I went ahead and threw an IK Solver on it. It appears that all paths end up in the same place. The IK works if you grab the IK handle, and the stretching works exactly the same in all three depending on what you move. It doesn’t look like I can get Max to create a stretchy IK arm in the way that I want without Max Script becoming involved in some way. Unless perhaps someone has a suggestion relating to wiring specific parameters together, I’m not sure. For now it looks like I’ll have to keep experimenting.

Comments off

The Kinect in Unity 3

Screenshot of the Kinect running in Unity 3.0

I finally managed to get the Kinect working in Unity 3.0. It took quite a few days of uninstalling drivers and reinstalling them but I managed it. I think my main problem was the OpenNI drivers weren’t installing properly because I had previously installed the Freenect ones. Once I uninstalled those and got the latest unstable Kinect drivers it started working.

This is how you can get it to run. Some of my steps might be unnecessary but it’s what worked for me.

  1. Install the latest unstable version of OpenNI
  2. Install the latest unstable version of NITE and use the PrimeSense license key
  3. I’m a little fuzzy on this step and I lost the instructions, I copied some XML files out of a sample folder into the actual folders. Not sure if it was needed.
  4. Install the latest unstable version of the Kinect Drivers (The PrimeSense drivers install by default with OpenNI and a Kinect is a beefier PrimeSense camera that needs different drivers)
  5. Opened up all the .xml files I could find and pasted the PrimeSense license key in all of them.
  6. Extracted the Unity 3.0 OpenNI Kinect project and hit play

It works fairly well. The legs in the screenshot are messed up because my apartment just isn’t big enough for the Kinect. It tracks the arms fairly well, the hands don’t seem to respond that accurately and if you move too quickly it will throw it off as well. Perhaps as the drivers get better and I hack around with the source code I can get it to work a little better, we’ll have to see. At least now I can finally start using it.

Comments off

DJ Hero 2

DJ Hero 2 Screenshot We recently got DJ Hero 2 for the PS3 and I have been playing it off and on over the past few weeks. It’s not bad. Some of the songs repeat a lot but other than that I can’t fault it for much else. It’s fairly bug free, and the graphics aren’t bad. They’re very stylized which sometimes works, but sometimes the characters just look plain weird. I was able to complete the game on the Medium difficulty level with little trouble. I’ve tried a little of the game at the two higher difficulty levels, but I have an inkling that the expert level is probably harder to do than the actual thing. The game is worth playing if you don’t mind having yet another peripheral hanging around, but it’s not really that much of a party game like Guitar Hero or RockBand. Overall I’d say it’s an above average game and it has a lot of replay value.

Comments off

The Kinect

Kinect Hacking from Neil Marshall on Vimeo.

I received a Kinect for Christmas specifically for hacking (I currently only have a PS3 and Wii) and I managed to get it up and running within a couple hours. I’m in the process of trying to get it to run in the Unity game engine, as that is the engine I work with at my day job, but so far I haven’t been too successful. The video shows off the sample apps that come with Freenect from OpenKinect, which is what you need to use to get it to work on a Windows machine. As for Unity, I’ve got it loading and capturing data. The problem is the data refuses to transfer from the Byte arrays into Texture2D objects. As soon as it copies the data, the events sending the data immediately stop transmitting. I think what other people have done to get it working is they have created a C++ plugin for the game engine that handles all of the data instead of trying to handle it in C#. I think I’m going to investigate their methods now as I don’t seem to be getting anywhere with what I have tried so far.

If you have any suggestions with regards to getting it operational in Unity3D please drop me a line.

Comments off

Enslaved for the PS3

Enslaved wallpaper I received Enslaved: Odyssey to the West for Christmas and I would say it’s worth playing. It has its issues, but overall it has a decent story and the game play is pretty good with a few exceptions.

Brief tutorials were supposed to trigger during the game but a couple of times it took me wandering around for about twenty minutes to get them to trigger. I couldn’t go anywhere new and it wanted me to walk over a specific spot on the ground just so before it would trigger. I think I also missed some tutorials at the start as it never taught me some of the controls. I only figured them out on the second last level, which was frustrating. Even with upgrading my equipment I was still having a really hard time defeating enemies until I realized that holding down the square button disabled enemies without needing bullets. Once I figured that out the last two levels of the game were simple. I think I would put that blame on the Level designer. It shouldn’t matter which ramp I glide up, it should still trigger the tutorial or at least have a visible marker as to which one I should be on.

On the flip side, it also hand holds you with lots of things. You can’t fall off an edge of a platform that you aren’t supposed to. While it stops you from constantly dieing it felt like there was little challenge to the jumping puzzles. And there was very little question to where you should jump; anywhere you needed to go glowed. Wander around until you saw the pulsating white and press X. It eliminated a lot of the challenge. I think they could have masked it a bit better but kept the ease of knowing where to jump by adjusting the art in the levels. If there is only one pipe you can climb, don’t have 40 in the vicinity and then make one of them glow. Perhaps only have one that you can reach.

As for the story it’s very similar to a movie that you’ve probably seen but I don’t want to give it away and it is only revealed in the Epilogue. I was actually hoping that there would be more to the story towards the end, but it seems that they just cut it off. It ended very abruptly story wise and left me feeling like they cut something out.

As for the length, it only took me three play sessions of a couple hours each over the weekend to complete. I don’t know if that’s because it was a game I liked and I finished quickly or because it was short. It was over 10 levels and I remember being surprised by that, so I have a feeling that it was because I liked it. Now all I need to do is find a new game like this to play.

Comments off

Drawings

Over the Christmas break I started sketching again. It’s the first time in months that I’ve picked up a pencil as I have been concentrating so much on my programming lately. I’m trying to design a character for an adventure game and this I’ve come up with so far.

Character Designs

Some quick sketches of a character.

Comments off

Tron Digital Painting

Girl leaning on a Tron bike.

This is a Photoshop painting I just finished. It was meant to be a quick one, but I wound up working on it most nights for about two weeks. Since “finishing” it I’ve found that some image applications don’t display colour properly (Like the Windows 7 image preview) and you pretty much have to view it with a black background (which this blog doesn’t have).

Comments off

Sculptris Model

I’ve been working on this image for the past few days.  It’s just a simple export out of sculptris and into 3DS Max.  I’m still trying to figure out how to get rid of the lines in the low res version of the head though.  If anyone knows, please let me know.

Comments off

Sculptris

I’ve been learning MudBox lately but for some reason I just find it difficult to use quickly. I’m not sure why, but I just don’t seem to like it much. The other day I read about a free piece of software which works very similar called Sculptris.  After using it for about 10 minutes I had most of the keyboard shortcuts down and was able to create something that looked half decent.

A cartoon duck:

A cartoon duck drawn in SculptrisAfter that I spent a little more time and created a female body.  I’m still not the greatest at drawing photo realistic characters, but it was easy to achieve for the most part.  It’s still a 1.0 release but what I found a little lacking was there was no real way to delete parts of the mesh I screwed up on.  I had issues with the fingers on the hand and quite a few with the head of the character.  In both cases I wanted to revert it to a stump and recreate it but I couldn’t.  What I wound up doing is reducing the polygon count and using a combination of smooth and the inverted draw tool to push it back.

I also had issues with the masking features.  It could have been my fault being new with the software but I couldn’t figure out how to mask things and them move them around.  My characters face was too far out and I wanted to push it back, but every time I did something unexpected happened to it.

Besides those minor issues I had with it, it’s an awesome piece of software and being available for free makes it even better.  I suggest everyone try it out.

Female model drawn in sculptris

Comments off