View Full Version : Orient center to polygon normal?
05-04-2009, 04:50 AM
Is there an easy way to orient the center of an object to a reference polygon's normal? The problem I'm having is that I keep extracting geometry to build more objects, but they default to a global 0,0 center. This is fine, and expected- but I'd like to be able to re-orient the center to match a polygon of my choosing in a quick and efficient manner. Is this something that can be done in XSI without much of a headache? Any script or plugin that does this?
The only way I know to do it right now is manually changing the translation mode to reference, selecting the polygon, switching to center modification, and then zero out the translation and rotation values. This is okay, and if it's the only way to do it I'll live.. but I extract->build a LOT, and this workflow is really wearing me out
05-04-2009, 08:05 AM
The programming forums are for who's trying to program something, be it hacking a log into a script or writing an uber shader in C++ :)
If you're asking for help on how to write something like that I'll be happy to help. It's not really that hard, but it does take a couple notions of linear algebra to do it.
If you're asking if somebody has a script or tool to do it already, then the parent forum is better suited to that. Lemme know and I'll move the thread for you in that case.
05-04-2009, 09:03 AM
Well, I've checked XSI base, Highend3D, and the softimage community site- but I didn't find anything already made, so I assumed I would have to write something myself (unless somebody has something tucked away that is heh). I asked if it was something simple, because a lot of my previous attempts to work on scripts in XSI have always been met with various roadblocks.. ie) limited and extremely outdated API reference, and of course the biggie- small userbase when SDK questions pop up.
On that note- are you aware of any books or reliable up to date reference or startup guides for XSI's SDK? everything I find on the net is a hodgepodge of 1.0 -> 6.5, and the built in sdk help is an alphabetized list of things that have limited use to me unless I already know exactly what I'm looking for. I've got experience writing scripts in MEL and MaxScript, and I've got a ton of experience w/ JS and VBS, but custom scripting for XSI has always been some arcane craft to me due to the lack of useful learning material I've found.
05-04-2009, 11:00 AM
I disagree about the documentation of the api being outdated. It's actually one of the best maintained I deal with everyday (don't know about max, but if you want outdated you only need to look as far as Maya's).
Other than that, sadly there's little courseware worth reading, and the docs while good are
and remain a reference, nothing tutoring.
There's an old training video by Helge, and one more recent by 3dtutorial, both in JS though, which I find a bit of a shame since JS isn't a patch on Python (which is pretty much the standard everybody is trying to comply to). Language aside they both get good feedback/reviews from who bought them.
Books wise, it's the desert at midnight I'm afraid.
In general though a decent book like learning python, published by O'Reilly, and giving oneself realistic objectives and doggedly trying to hit them still is one of the best ways to go about it.
There is some stuff to come soon-ish afaik, but not sure I'm at liberty to talk about it yet.
As for what you want to do, try to whip something together, post when you get stuck, and people here WILL help, I'm pretty certain of that. Like many things the learning curve for programming in XSI is stepped, once you get past a particular roadblock you normally cruise at decent speed for a while... until the next one :)
05-04-2009, 09:10 PM
sounds like a plan, I'll do taht :thumbsup:
05-07-2009, 04:11 AM
I would start by grabbing a few things from the command line. Such as, constrain an object to a cluster, enable tangency on the +Y, and see what comes up in the command line. Then delete the constraint and delete the cluster, assuming you don't need it anymore. Again, copy elements from the command line. Then start the journey of convert to object model, but if it's just a personal tool, leave it as command model.
05-07-2009, 07:14 AM
well, I haven't had much time to work on it yet, but what I'm doing so far is getting the selection (the target normal, edge/poly/point), and setting a transient reference plane to it.. From there I'm starting a pick session where I can pick the object that needs re-orienting.
After that I know I need to transform the center to the reference plane, but I have no idea how to move the center..
05-07-2009, 07:54 AM
Moving the centre is backwards but intuitive.
What happens in reality is that the whole geometry is moved around the centre. In mathematical terms you would have to transform the geometry by the inverse of the offset and then move the object where you want it to be.
05-07-2009, 09:44 AM
How does that work exactly though? I thought by transforming an object you are effectively transforming the center and the geometry just follows it around. What you're saying makes sense, it just doesn't make any practical sense to me- is there an efficient way to move all of the geometry around without affecting the center? Moving the object is easy enough via SetTranslation, but that moves the center and the geometry follows right? I haven't found an API method to do it, but with native XSI script you can move the center without affecting the geometry- Translate(siCtr)
At this point I'm just wishing XSI had a way to record macros so all i had to do was do my reference plane->center->0,0,0 song and dance one time and then hit a button thereafter. All of this coding is taking me away from doing any actual modeling heheh
05-07-2009, 06:32 PM
Okay, well this probably isn't the right way to do it, but for now it works for me and I'm tired of messing with it. Here's the script (in JS) for those who want it:
var oSel = selection(0);
var rtn = PickElement( "polygon", "Pick reference plane", "Pick reference plane", modifier, button, 0 )
var element = rtn.Value( "PickedElement" );
var button = rtn.Value( "ButtonPressed" );
var modifier = rtn.Value( "ModifierPressed" );
if ( button != 0 )
Translate(oSel, px, py, pz, siAbsolute, siGlobal, siCtr, siXYZ, null, null, null, null, null, null, null, null, null, 0, null);
Rotate(oSel, rx, ry, rz, siAbsolute, siGlobal, siCtr, siXYZ, null, null, null, null, null, null, null, 0, null);
Also, I made an icon (http://www.ldsmith.info/temp/tool_centernormal.bmp) for my custom toolbar that you can have as well (hastily modified 3Dsmax icon, but it gets the job done). There is no error checking whatsoever, and currently I have the picking backwards from what I'd like it to be- right now you select the object with the bad center, hit the button, and then pick an object and then a face. In the future I'll reverse this where you start with any element selected and then pick the object afterward. But for now, I've run out of time w/ this little project- need to get back to work on real stuff :)
05-07-2009, 06:32 PM
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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.