align to surface on the fly (like 3dmax tool)


#1

I was watching a gnomon gears of war concept guy do his concept art and he used some align tool which on the fly could let him grab a cone for example snap to the face of a sphere and it would align the cone to the spheres normals on the fly. this has gotta be one of the most useful tools i could ever imagine. please tell me xsi can somehow do this or there is a tool out there that will do this.


#2

yes, it’s a really handy tool that XSI is missing. Hell, XSI can’t even take on object and align it to the normal of a surface in one click (without a script), though I imagine that something like this could be created in ICE if someone had the motivation to do so. Unfortunately it seems like there are only a handful of ICE developers that are active, and most of them seem focused on fluid sims and whatnot


#3

I hardly think you need to rely on a developer to do something like that. Anyone with enough time and competence (or curiosity) to string a few nodes together could probably come up with something close - and there are plenty of people to fall into those categories.

But yes, it would be a nice function to have. :wink:


#4

only a script…



[size=2][font=Courier new]'   ____________________________________________________________
'  /															\
' | VB script for appending a floating object,				   |
' | to a root object polygon									 |
' |							  Made by Blight on 13 may 2008   |
' |								 For [http://www.xsibase.com](http://www.xsibase.com/)	|
' | Inspired by Jasonio movement script from February 21, 2008   |
'  \____________________________________________________________/


'   ______________
'  /	Script	\ 

 LogMessage "--Start of Script--"
Clear()

 LogMessage "!!! Pick the floating geometry you want to move."

set objectselection = GetValue("SelectionList")
if objectselection.count = 0 then
   PickObject "Select the floating object to append",, floater, button
   selectobj floater
end if

set objectselection2 = GetValue("SelectionList")
Clear()
ActivateRaycastPolySelTool 

 LogMessage "!!! Good now pick the root geometry, and then the polygon(s) you want your previously selected object to be appended to."

PickElement "polygon", "Select the root object and its polygon(s)",, root, button
SetTransientReferencePlane root


Movement()
Clear()
 LogMessage "--END of Script--"


'   ______________
'  /  Functions   \ 

function Clear()
   ActivateObjectSelTool
   DeselectAll 
end function

function Movement()
'tells which object to perform the translation and rotation on
SelectObj objectselection2, , True
   Rotate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , 0
   Rotate , 0, 0, 0, siAbsolute,  siObjCtr, siObj, siY, , , , , , , , 0
   Rotate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , 0
   Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , , , 0
   Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siY, , , , , , , , , , 0
   Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , , , 0
end function
[/size][/font]


#5

That align to normal script is useful PiotrekM, it looks a fair bit more straightforward than the one I wrote actually :smiley:

The beauty of the tool in Max though- is that it’s interactive. You apply it to the floating geometry you have, and from then forward it literally slides along the surface reorienting itself to the nearest polygon normal. It’s really handy for placing rivets, panel details, etc… especially if you have tons of them to do. I imagine something like this would be simple enough to do in ICE, since they pretty much hand you a slide-on-surface node right out of the box among other things… perhaps I will give it a crack this weekend.

CiaranM: for some reason i doubt it is going to be as easy as stringing a few nodes together… ICE is certainly easier than some of the alternatives, but a lot of the higher level functionality is not really all that accessible to the average user. For example- the slide on surface node sounds like it should be able to do the trick all by itself, though when you consider the fact that it is designed to work in a simulated tree, with particles and not geometry it opens a new can of worms :slight_smile:


#6

It would be nice to have something like this that also works with proximity. That way you can kind of “stick” and un stick things? I guess you could just use one of the other mouse keys to do it as well.

Left= slide/move on current selected faces /objects

middle = slide/move on nearest face with proximity

Maybe this should really be part of the tweak tool? Or the snap tools since slide on surface is already there?

Its nice that the basics of modeling in SI are solid, but there are a few “exotic” tools that are now standard in most packages that are not there in SI. Maybe it’s time for another organized, more formal set of request emails to SI/AD?


#7

eldee: I know max tool, unfortunately I work with max everyday at work…

Is is possible to script such interactive tool in softimage ? just wondering…

because align is more like ‘fire & forget’ tool, where ICE is an operator


#8

i’d like to think that it’s possible, but maybe not. You’d need a way to initially align the object to the target normal, and from there constrain it to the surface. Perhaps through a combination of traditional scripting, you can flag the constraint as on or off, and while it’s on and being transformed, it’s repeatedly polling another script or ICE compound that realigns it to the surface.


#9

Well here’s a quick ICE implementation. Lot’s of room for improvement (should probably use quaternions) and uses unsupported ICE kinematics, so don’t blame me if your system blows up. Might be better off as a deformer. Around 20 nodes :wavey:


#10

And you expected Joe Average to go and enable experimental kinematics flags to string together a few nodes? :slight_smile:

Looks cool though, I’ll definitely be playing around with it!


#11

@PiotrekM

your script just became my most used tool i think. thanks SO much for that, before if i wanted to align something to a surface i had to go into plane mode, alt+lmb my pivot on a component i wanted and get the coordinates from the plane options from there and then slowly copy and paste into each transform…your tool saves me SO much work. is there a way that i can select any component when selecting the component i want to align with? some times i need to align to a point, or other times an edge and that would be really really nice if the script could do whatever i select. thanks again regardless.


#12

What about the “Object to Cluster constraint”?

  1. Select the points at the edges of the target polygon.
  2. Make a cluster. Hit enter or a browser to have the cluster name handy to select.
  3. Select object to align then use “object to cluster constraint”.
  4. On constraint ppg go to Normal Tab and turn it on.
  5. Remove constraint if you don’t want it.

It is not a single click, but pretty quick. You can also use this object to make reference planes or whatever for laying out other stuff.

P.S. PiotrekM- Nice script, thanks for sharing.

Ohmanoggin


#13

script is not mine, the author is “Blight”, I only found it on xsibase :wink:


#14

I don’t have proper knowledge to modifiy this script.

Meanwhile you can always do align by using old REF mode trick.
right click on ref, pick your target edge/point/poly. now in ref mode pick your source object and type 0,0,0,0,0,0 in your rotates and transforms boxes.


#15

var oSel = selection(0);
SetTransientReferencePlane(oSel);
var rtn = PickElement("object", "Pick Object to align", "Pick Object to align", oObj, button, 0);

var element = rtn.Value("PickedElement");
var button = rtn.Value("ButtonPressed");
var modifier = rtn.Value("ModifierPressed");

if ( button != 0 ) {
	var oObj = element;
	transx=getvalue ("RefPlanes.Transform.posx");
	transy=getvalue ("RefPlanes.Transform.posy");
	transz=getvalue ("RefPlanes.Transform.posz");
	rotx=getvalue ("RefPlanes.Transform.rotx");
	roty=getvalue ("RefPlanes.Transform.roty");
	rotz=getvalue ("RefPlanes.Transform.rotz");
	var oObjTrans = oObj.Kinematics.Global.Transform;
	var newTrans = XSIMath.CreateVector3();
	newTrans.Set(transx, transy, transz);
	oObjTrans.SetTranslation(newTrans);
	var newRot = XSIMath.CreateVector3();
	newRot.set(XSIMath.DegreesToRadians(rotx),
	 XSIMath.DegreesToRadians(roty),
	 XSIMath.DegreesToRadians(rotz));
	oObjTrans.SetRotationFromXYZAngles(newRot);
	oObj.Kinematics.Global.Transform = oObjTrans;
}

With this script you start with the element that you want to align TO selected, run the script, and then pick the object you want to align. It works with all components and subcomponents.

Also- I wrote a script that also reorients the center to a selected subcomponent’s normal, kindof a similar process… that script is floating around in this forum somewhere.


#16

@PiotrekM

that trick is so cool…i had no idea i could do that…wow…

eldee, i tried your script and i get this error.

ERROR : Expected end of statement - [line 1]


#17

make sure you set your script to JScript. also make sure if you copy/paste it out of your browser that all of the quotes are still “quotes”, sometimes windows likes to change quotes to smart-quotes, which aren’t syntactically correct.


#18

@eldee

Thats a great time saver script. Thank you very much.

cheers


#19

EDIT: Code was replaced at 16:38 GMT due to being the wrong code. Doh!

Just stuck this up on XSIbase and thought I’d stick it here, just in case.

Note that the copypaste command will muck your scene up if the model you are aligning is already in a hierachy. Unfortunately, I don’t know the “unparent” command!

  1. Pick object. 2.run script. 3. Pick objects polygon to align with. 4. Pick destination polygon.
    (remember to select a poly using this script you still have to switch to polygon selection mode to pick one)

rem rotate object polygon to polygon (normal align)
rem written by J Wells aka redmotion
rem 17-08-09

set list = GetValue( "SelectionList" )
if list.count = 0 then
   PickObject "Select object to align", "Select object to align", picked, button
   selectobj picked
   set list = GetValue( "SelectionList" )
end if

PickElement "polygon", "Select object polygon", "Select object polygon", child, button
PickElement "polygon", "Select destination polygon", "Select destination polygon", master, button

set commander = GetPrim ("Null")

SetTransientReferencePlane child
Rotate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , 0
Rotate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siY, , , , , , , , 0
Rotate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , 0
Translate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , , , 0
Translate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siY, , , , , , , , , , 0
Translate commander, 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , , , 0

ParentObj commander, list

SetTransientReferencePlane master

SelectObj commander, , True

Rotate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , 0
Rotate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siY, , , , , , , , 0
Rotate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , 0
Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siX, , , , , , , , , , 0
Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siY, , , , , , , , , , 0
Translate , 0, 0, 0, siAbsolute, siObjCtr, siObj, siZ, , , , , , , , , , 0
Rotate , 180, 0, 0, siRelative, siObjCtr, siObj, siX, , , , , , , , 0

CopyPaste list, , "Scene_Root", 1

DeleteObj commander

DeselectAll

#20

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.