Download Version 2.2b for Modo 201: jj_wrap.pl

Introduction

JJ_Wrap is a wrapping, projection and alignment script inspired by Shrinkwrap (XSi) and PointFit (Lightwave). It has now been updated for modo 201 removing the 'confirm' bug which interrupted the script's progress and utilising modo 2's excellent new user script/config structure. You still need to use Version 1.0 in modo 1. To download Version 1.0, use the link at the bottom of this page.

JJ_Wrap does the following:

  • Shifts selected vertices along x, y, z, point normals or a user determined vector and wraps or projects the geometry on to selected polys. Ideal for projecting cloth on to characters, for example.
  • Lets you specify an offset to keep the vertices 'off' the collision surface.
  • Has a point normal mode which moves vertices along their averaged normal in both directions i.e positive or negative to the normal which is perfect for wrapping.
  • Can function as an aligner to line points up with other selected geometry i.e. you can 'fire' points or polys at other polys and the projected points will 'stick' to the collision surface.
  • Can project a sphere on to a cube or a cube on to a sphere for fx morphing etc (although a little bit of cleanup is necessary).
  • Can project low resolution grids on to high resolution geometry to lower the overall poly count but give you control over the polygonal topography i.e. if you need to reorder edge loops you can create them in 2d and then project them on to a 3d surface.
  • New: Additional control over direction of projection using an edge to specify the direction or using multiple selected edges to guide individual points (see edge and multiedge below).

Notes
1. JJ_Wrap works by detecting when points collide with polygons so requires a point selection and a poly selection. The points will be projected onto the target polygons. As with all collision systems it is computationally expensive the higher the point/poly count. Polygons do not need to be tripled. If you have 1000s of points/polys calculation times can take many minutes! Polys are only visible to the projected points if they face the incoming points. To get the effect you want you may sometimes need to flip your polys.

2. For off axis projections you can currently use either point normal or user vector. If you use point normal on a planar set of points it will project along the normal of the plane upon which the points lie.

Many thanks to Neil Hayes for providing the optimised ray/triangle intersection code that massively reduced calculation times and for providing invaluable input into this script (including the idea for a user vector).

Julian Johnson
julian@exch.demon.co.uk

Basic Projection
With no arguments the selected points are projected down negative Z until they contact selected polys..

Args:
jj_wrap.pl z

Basic Projection 2
..Like this.

Args:
jj_wrap.pl z

Projection with Offset Along Z
You can specify an offset which forces the selected points to collide at a specific distance from the collision polys. You can even put in high offsets which will push the vertices away from the collision in the opposite x,y, z or point normal direction.

With the offset argument you must have an offset value in slot 1 of the argument list.

Args:
jj_wrap.pl .2 offset z


Simple Point Projection for
Alignment

It's easy to align points to the planes of other polygons for routine cleanup work or for 'flattening' non planar grids..

Args:
jj_wrap.pl z


Simple Point Projection for
Alignment

..like this.

Args:
jj_wrap.pl z


Point Normal Projection
If you use point normal projection (by using the pnorm argument) the points will move along their own normal towards the collision surface in either a positive or negative direction...(in this case a negative direction)

Args:
jj_wrap.pl .01 offset pnorm negative

Point Normal Projection 2
..in point normal mode, the selected vertices can be made to 'wrap' volumes. You can also use offset in this mode.

Args:
jj_wrap.pl .01 offset pnorm negative
Point Normal Projection 3
To illustrate the 'projection' side, if you project the points of this cylinder using negative point normal projection on to the cube inside..

Args:
jj_wrap.pl pnorm negative

Point Normal Projection 4
The polys are pressed on to the cube. It's sometimes nice to go from circular contours to square ones and jj_wrap is useful for achieving that sort of effect.

Args:
jj_wrap.pl pnorm negative

Point Normal Projection 5
..this gets interesting if you choose to project a sphere on to a cube, for example..

Args:
jj_wrap.pl pnorm

Point Normal Projection 6
..hmm, interesting, but you'd still need to clean up slightly to fully squarize. Could be useful for morph effects.

Args:
jj_wrap.pl pnorm

Point Normal Projection 7
If you project out from a heavily subdivided cube on to a sphere..

Args:
jj_wrap.pl pnorm
Point Normal Projection 8
....you can, kind of , spherize your object. I think I'll implement a proper spherize to an implicit virtual sphere in 1.1. (BTW: on my Mac dual 800 this calculation took 2 minutes!)

Args:
jj_wrap.pl pnorm


The Hull
Enabling the hull will, in many cases, speed up the calculation. It projects an imaginary outline of the geometry on to the collision surface and assesses which polygons need to be calculated for collision. It's totally cool but for one small drawback - if you have a large poly in the collision area which does not have a point in that area then it will not be assessed for collision detection so some of your points may not move. The hull can't work in point normal mode because the projection is impossible to assess.

Args:
jj_wrap.pl hull

The Hull 2
In order to visualise which polys the hull is going to assess you can preview the hull using the preview toggle. If you can tell that the selection needs to be expanded just hit expand selection and then use jj_wrap without the hull - at least you've reduced the number of polys you need to worry about.

Args:
jj_wrap.pl preview

User Vector
If you specify user vector you can select some projection points, lasso select or select some polygons and jj_wrap will work out the direction between the two and project the points on to the polygons. Thanks to Neil for this great idea.

Args:
jj_wrap.pl uservector

User Vector 2
..like this.

Args:
jj_wrap.pl uservector

User Vector 3
Offset will continue to work..

Args:
jj_wrap.pl .5 offset uservector

Edge Projection
Using the first selected edge, jj_wrap will project all points in the direction of that vector towards the target polygons. The positive and negative direction switches are disabled, along with Hull and Hull Preview functionality in this mode.

Args:
jj_wrap.pl 0 edge

MultiEdge Projection
Using only points with connected edges, the script will project each point along the direction specified by the edge its connected to.

Args:
jj_wrap.pl 0 multiedge


How to Install JJ_wrap with the Form



There are currently two components to jj_wrap - the script itself, and a configuration file to set up the form. Using the inbuilt arguments you can use the script from a key without having to install the form if you want.

jj_wrap.pl - the perl script itself
jj_wrap.cfg - the file that creates the form.

Option 1 (Modo 2 only)
On both a PC and Mac you have a default location for Application Data. Inside the application data directory there is a Luxology directory which usually hosts your config/preference files and licence data. Within that directory modo provides the ultra useful Configs and Scripts directories. Any scripts and configs you place in here will be automatically available to you. This has to be the preferred option.

On a PC they're usually located here(by default the visibility setting for the Application Data directory might be set to invisible):
C:\Documents and Settings\YourName\Application Data\Luxology

On a Mac:
/Users/YourName/Library/Application Support/Luxology

Option 2

The way the form is configured at the moment means that if you place it directly into your modo resrc folder (on OSX you'll need to open the modo package contents and place it in the Resources folder), the form will become available to you next time you launch the application. This relies on modo's default behaviour but can result in a very cluttered resrc directory. If you then place the script itself in the same directory as modo.app/modo.exe it will be available to the form without any further alterations being required.

Option 3
Alternatively, you can create your own location to store both the script and config file but will need to adjust the path locations in the jj_wrap.cfg file. The benefit of this approach is that you have control over where you keep your external files and they won't get overwritten should you update modo.

It doesn't really matter where you put them so long as you make sure you have correct paths in the relevant files.

Once you've chosen a location for both files then you need to open up the jj_wrap.cfg file in a text editor and put in the relevant path to the actual script using search and replace so that every time the script is called it has the correct path. Here's an example of how a single entry should look (but, remember, every entry for the script should be changed to the correct path using a single search and replace).

On a Mac:

<list type="Control" val="cmd @{/Users/julianjo/Desktop/current pbs/jj_wrap.pl} user">
<atom type="Label">JJ_wrap</atom>
<atom type="Hash">54409416674:control</atom>
</list>

On a PC:

<list type="Control" val="cmd @{C:\Directory with Spaces\subdirectory\jj_wrap.pl} user">
<atom type="Label">JJ_wrap</atom>
<atom type="Hash">54409416674:control</atom>
</list>


If the path has a space in it then the script needs to enclosed in curly brackets e.g.

@{/Users/julianjo/folder with spaces/jj_wrap.pl}

It's easy to mistakenly delete a quote mark or a space, so make sure you find and replace just the path.

Once you've configured the path in the config file you're nearly ready to roll. Fire up modo, go to File:Config Import and import the jj_wrap.cfg file you've just amended. This tells modo to load that file (i.e. the menu for Loop Hop), every time you launch modo.

For ease of access to the form simply assign the form to a key.

When The Script Runs I Get Bombarded With an Error Message (Modo 1 only)

The 'General Failure' message is a known issue with modo and can be easily fixed.



Luxology themselves have released a patch for this error message on Vertex Monkey:

http://www.vertexmonkey.com/scripts_bugfix.php

Alternatively, you can just set the 'In the future' drop down to let modo know you don't want to see this message again. The error sounds dramatic but isn't, it's totally inconsequential. Luxology's bugfix script does simply that - it turns off that specific error message.


Why do I, apparently randomly. get a dialogue box asking me to 'Confirm' (Modo 1 only)

There is currently a bug in modo when processing a large number of points/polys via scripts. This dialogue box prevents modo from crashing during this process. It pops up if the combined point/poly count is greater than 200. Not pretty. But works.



I Hate The Way the Form is a Popover and Vanishes if I Move My Mouse Too Much

To get a permanent window with the wrap form as above:

1. Go to Layout:New Window
2. Set the window to Form View by LMB clicking on the right hand arrow.
3. RMB on the Form View header and select JJ Wrap. Now you have a window.

Known Issues

1. When you first use the form, the values for each of the fields don't exist and the form looks corrupted. You need to run the script once so that modo is aware of the existence of the form fields etc. You can do this by using F6 to navigate to the script and firing it off once.

2. It's very easy to get confused as to which direction you're projecting into - make sure you're using the appropriate direction and positive/negative values and that the polygons are facing the projection points.

3. The hull won't work if you're in Point Normal mode.

To Do

1. Create a spherise function that uses a virtual sphere for correct smoothing.

2. Look at offsetting along the collision poly normal as well as back along the projection vector.

3. Look at options for speeding up point normal calculations.

4. Off axis projections where user can specify an edge to define the vector.

5. Option to rotate the projection object to align with the user vector.

Versions

Version 1.0:
jj_wrap.pl
- Original version 19.11.2005

Version 2.0:
jj_wrap.pl
- Update for 201

Version 2.1b: jj_wrap.pl
- Added edge and multiedge modes

Version 2.2b: jj_wrap.pl
- Added edge and multiedge modes


Julian Johnson
julian@exch.demon.co.uk