Archive for the ‘Technical Art’ Category

Grapple – Rope Generator Script

Posted on: April 25th, 2013 by Adam No Comments

Class:
Tech Art

Assignment:
Create a piece in the field of tech art that can be used in your Capstone game.  This will be your first tech art portfolio piece.

Backstory:

One of the problems I’ve been worried about in my Capstone game, Grapple, is that we plan on having a ton of ropes/wires crisscrossing from building to building.  These ropes/wires will be strewn throughout the level.  Ideally, they will be different sizes depending on the gaps they are traversing.  Needless to say, that’s a lot of individual assets to make and place in the level.

Originally, before Vertical Slice, we had just one wire that we would duplicate and place around the level.  That quickly grew tiresome and inefficient.  Not only could we not resize the wire non-uniformly (if we wanted it longer, it also had to become thicker…) without breaking, but it also took forever to duplicate the wire once, place it (translate, and harder, rotate it), then repeat over and over.

When one of the producers informed me of this hassle, I made a script that was able create differently sized ropes in Maya at the push of a button.  The script allows the user to specify the size (length, width, and depth) of the wire as well as the number of flags that would hang from the wire.  It also assured that the wires’ pivots were on their very edge, so placing the wires in the correct rotation in the level became much easier.

This solution worked well enough for Vertical Slice, but the whole process was still dreadfully inefficient.  While UDK does have a measurement tool that we could use to determine the lengths of wire needed, placement of the wires in the level as well as the process needed to turn the meshes into cloth once in UDK still took way too long.

 Idea:

When we were told to create a tech art piece that could be used for our Capstones, this was the first thing that came to mind.  I had a good starting point with what I had done pre-Vertical Slice, but it still needed some serious work to make it be really useful!

The project I proposed would be an extension of my original rope generator script.  The main idea was that it would allow users (most likely level designers) to “draw” wires directly in the level from point A to point B.  It would also set up the ropes to be seen as cloth (or some kind of physics-driven asset) in UDK.  Essentially, it would pipeline the wire process to be able to create and place the wires as quickly and efficiently as possible.

Troubles:

Unfortunately, after doing a tremendous amount of research, I concluded that making a plugin for UDK would not be possible, so I decided to do the bulk of the pipelining process in Maya.  The creation and placement would be done in Maya while setting the skeletal meshes up to work as cloth would be done in UDK.

During the development of the tool, I was introduced to Apex cloth.  I thought that perhaps this could be an option to set up the wires in Maya to automatically work as physics assets once imported into UDK (rather than having to manually go through each asset individually and enable cloth physics).  I’m not completely convinced this still isn’t an option, but the programmer who’s working on the wires and I tried many different methods to get Apex cloth to work for what we need, but we haven’t been able to get it quite right yet…

The trouble is that we need the wires to stretch when Amina, our game’s main character, grapples to them.  When her grapple attaches to the wire, it needs to be pulled toward her, and then as she swings off of it, the wire needs to bounce back to its original position (imagine pulling on a rubber band then letting go).  In order to move the wire while Amina’s attached to it, we’ve been manually moving the wire’s joints to simulate it reacting to her weight.  After she’s let go of it, we let the physics take back over the wire’s movement.  However, when we try to move the joints of an Apex cloth asset, the mesh either becomes distorted or not distorted enough.  What I mean by the latter is that the mesh doesn’t follow the joints’ positions exactly; it seems to average their positions and make a smooth curve between them.  So if one joint is say, 1000 units (which is a lot) away from all of the rest of the joints, you’re hardly going to notice.

Another method we tried was to create physics assets from the skeletal meshes once they were imported into UDK.  The trouble we ran into there is that the collision boxes that are automatically created when you make the physics assets were never the right size.  Unfortunately, the only way we could find to resize the collision boxes to fit the mesh was to resize each one by hand.  Meaning, we had to click on the collision box and use the scale gizmo (which, in the PhAT editor, is even skinnier and harder to click than normal) in order to size it properly.  While there are numbers that display the size of the collision boxes, they are, for some ungodly reason, uneditable.  They change when you scale the box with the gizmo, but they’re read-only.  We did eventually find an option to copy and paste the properties (i.e. the scale) of one box to another, but we still had to manually resize one box, then click on each other box and paste the properties.  If that wasn’t enough, we had to follow this process for each and every individual wire asset.

Tool Description:

So with that all said, here’s how the pipeline works as of now.  We export portions of the level from UDK and import them into Maya (exporting the entire level at once would make Maya explode!) and then import those chunks into Maya.  Once in Maya, we create linear NURBS curves that will be used as wires.  Only two points are needed for each rope–the beginning and the end.  Once the curves have been placed, the script is run.  It gives the user several options for the wires such as their thickness, and the number of subdivisions per wire.  The user can choose to apply these settings to all curves in the scene or just those selected.  The user can also choose to use these settings to overwrite wires that have already been created (by default, the script only affects curves that have no wire applied to them).  Lastly, the user can enter an indefinite number of “length ranges” for certain settings to be applied to. For example, wires between a length of 5 and 10 units could have 3 joints while wires between a length of 15 and 27 units could have 16 joints.  There is a “Calculate Length” button to help determine these ranges.  When pressed, the button will print out both the names and lengths of all/selected curves (depending on the “Use all curves”/”Use selected curves” radio buttons up top).  Lastly, the “Export” button will export all or  only selected (again dependent on the radio buttons) wires as an .fbx.  This .fbx can then be imported back into UDK.

In terms of positioning, all that’s needed inside UDK is to set the wires’ positions to (0,0,0); they’re correct positioning is carried over from Maya.

In terms of importing them to be automatically seen as physics assets, there’s still a bit more work.  However, this work will be determined by the direction we choose to follow in UDK.  All of our options require skeletal meshes with specific weighting which has already been done.  So regardless of the choice, the wires are set up and ready to go!

Credits:

Building models and textures by Karen McCarthy