Move an object to the ground
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
Which version of XSI do you have?
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- wireframex
- Posts: 399
- Joined: 08 Jun 2009, 23:02
- Location: France
Re: Move an object to the ground
2012 SP1 and 2015 SP2
"without mastery, power is nothing" - Softimage Addict User
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
I am not in front of XSI at the moment. I'll see what I can whip up tonight.
Cheers!
Cheers!
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Re: Move an object to the ground
Martin Yara's M|Aligner seems to do very smilar things to the the tool you referenced, except also works with point + edges..
http://skymill.co.jp/tools/Softimage/mA ... gnerEN.htm
Perhaps you could then map some of those functions to keys? (copying commands from log)
http://skymill.co.jp/tools/Softimage/mA ... gnerEN.htm
Perhaps you could then map some of those functions to keys? (copying commands from log)
- wireframex
- Posts: 399
- Joined: 08 Jun 2009, 23:02
- Location: France
Re: Move an object to the ground
Ok Thanks DanielDaniel Brassard wrote:I am not in front of XSI at the moment. I'll see what I can whip up tonight.
Cheers!
Thanks Dude I know it it is a good tool but it is not what I am looking forFXDude wrote:Martin Yara's M|Aligner seems to do very smilar things to the the tool you referenced, except also works with point + edges..
"without mastery, power is nothing" - Softimage Addict User
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
Re: Move an object to the ground
Hum, indeed it seems to do everything except aligning objects by their bounding boxes.
Which I thought was say Y-Min, Y-Max, X-Min etc... ,
but those align the selected objects at their *centers* to... say the bottom-most object's center (Y-Min)
or at '0' (or other specified distance from world center)
It weird because the 'Equidistance between objects' considers object bounding boxes, so I would have though it wouldnt be a big stretch for alignments to also consider object boundaries...
So perhaps checking-out how selected objects boundaries are determined in the equidisytance bit, to perhaps allow aligning these objects as if their centers were at their bottoms, tops, or sides ?
It would make that tool even more awesome and complete! (and useful)
Perhaps also bringing it up to Martin as he is still around?
(Unlike Origin (Piotrek) who is quite unfortunately not)
Which I thought was say Y-Min, Y-Max, X-Min etc... ,
but those align the selected objects at their *centers* to... say the bottom-most object's center (Y-Min)
or at '0' (or other specified distance from world center)
It weird because the 'Equidistance between objects' considers object bounding boxes, so I would have though it wouldnt be a big stretch for alignments to also consider object boundaries...
So perhaps checking-out how selected objects boundaries are determined in the equidisytance bit, to perhaps allow aligning these objects as if their centers were at their bottoms, tops, or sides ?
It would make that tool even more awesome and complete! (and useful)
Perhaps also bringing it up to Martin as he is still around?
(Unlike Origin (Piotrek) who is quite unfortunately not)
- AceMastermind
- Posts: 160
- Joined: 15 Jun 2009, 00:57
- Contact:
Re: Move an object to the ground
I am not a programmer but I managed to make this work. Here is a simple script based on what I was posting about earlier that will bring the bottom of an object's bounding box to Y=0, or the "ground".
You can drag this into a toolbar and make a script button, then select one object and run the script.
You can drag this into a toolbar and make a script button, then select one object and run the script.
Code: Select all
sel = Application.Selection(0)
Application.CreatePrim("Grid", "MeshSurface", "", "")
Application.SetValue("grid.Name", "tempGrid", "")
Application.SelectObj("tempGrid", "", True)
Application.AddToSelection(sel, "", True)
Application.Align("", "siY", "siAlignGMIDDLE", "siAlignGMIN", "siAlignGMIDDLE", "siAlignGMIDDLE", "siAlignFMIN", "siAlignGMIDDLE", False)
Application.DeleteObj("tempGrid")
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
Hi all,
So I had a crack at it yesterday (designed the interface and some test code to check behaviour). The JScript test code below works for one object selected and takes into account the rotation or scaling of the object but it will not work for multiple objects selected. Somehow the bounding box average all selected objects and none of them goes to ground.
Maybe someone will see where I made a mistake in the code and correct me.
Here what I have so far (I have a bunch of LogMessage to check behaviour, that will ultimately be removed and the code cleaned up in the final code):
And the code without the logmessage and tests
So I had a crack at it yesterday (designed the interface and some test code to check behaviour). The JScript test code below works for one object selected and takes into account the rotation or scaling of the object but it will not work for multiple objects selected. Somehow the bounding box average all selected objects and none of them goes to ground.
Maybe someone will see where I made a mistake in the code and correct me.
Here what I have so far (I have a bunch of LogMessage to check behaviour, that will ultimately be removed and the code cleaned up in the final code):
Code: Select all
// Example using an input transform to preserve scaling and rotation
// Works in XSI v10.0 and up
var oSelection = Application.Selection;
for (var oItem = 0; oItem < oSelection.Count; oItem++ ) {
LogMessage (oSelection(oItem).Name) ;
oTransform = oSelection(oItem).Kinematics.Local.Transform ;
// find the bounding box
var vba = new VBArray( oSelection(oItem).GetBoundingBox(oTransform) );
var jsa = vba.toArray();
// Report the min and max
var minX = jsa[0];
var minY = jsa[1];
var minZ = jsa[2];
var maxX = jsa[3];
var maxY = jsa[4];
var maxZ = jsa[5];
var centerX = (minX + maxX)/2 ;
var centerY = (minY + maxY)/2 ;
var centerZ = (minZ + maxZ)/2 ;
var toGroundY = - minY;
LogMessage( "min:" + minX + ", " + minY + ", " + minZ ) ;
LogMessage( "max:" + maxX + ", " + maxY + ", " + maxZ ) ;
LogMessage( "center:" + centerX + ", " + centerY + ", " + centerZ ) ;
LogMessage( "toGroundY:" + toGroundY ) ;
Translate(oSelection(oItem), 0, toGroundY, 0, siAbsolute, siLocal, siObj, siY, null, null, null, null, null, null, null, null, null, 0, null);
}
Code: Select all
// Example using an input transform to preserve scaling and rotation
//
var oSelection = Application.Selection;
for (var oItem = 0; oItem < oSelection.Count; oItem++ ) {
// Calculate the local transform of the object to take into account the rotation and scaling
oTransform = oSelection(oItem).Kinematics.Local.Transform ;
// find the bounding box using X3DObject.GetBoundingBox
var vba = new VBArray( oSelection(oItem).GetBoundingBox(oTransform) );
var jsa = vba.toArray();
// calculate the ground translation to translate the object to ground
var toGroundY = - jsa[1];
// Translate the object to ground
Translate(oSelection(oItem), 0, toGroundY, 0, siAbsolute, siLocal, siObj, siY, null, null, null, null, null, null, null, null, null, 0, null);
}
Last edited by Daniel Brassard on 13 May 2016, 20:19, edited 5 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
And the designs of the UI (if you are curious). It's a mokup that do nothing right now but will be modified with the correct code when I am satisfy with the code to execute after I solved the behaviour.
Cheers!
P.S. Does anybody know how to force the radio button in the AddEnumControl to be on the same row?
Cheers!
Code: Select all
/* Script created by Daniel Brassard (2015)
This script is a mimic of the Rest On Ground tool in LW
Modify to your liking if you wish. Cheers!
This script should work with Softimage v10.0 (2012) and up
*/
// Rest On Ground
// Create a temporary custom property that will hold the user's choices
var oPPG = XSIFactory.CreateObject("CustomProperty")
oPPG.Name = "RestOnGround" ;
oPPG.AddParameter3( "RestAxis", siString, 1 );
oPPG.AddParameter3( "CenterX", siBool, true ) ;
oPPG.AddParameter3( "CenterY", siBool, true );
oPPG.AddParameter3( "CenterZ", siBool, true );
oPPG.AddParameter3( "Sense", siString, 1.0 );
oLayout = oPPG.PPGLayout
oLayout.AddGroup();
oLayout.AddRow();
aRestAxis = new Array ("X", 0, "Y", 1, "Z", 2 );
oLayout.AddEnumControl( "RestAxis", aRestAxis, "Rest Axis:", siControlRadio ) ;
oLayout.EndRow();
oLayout.AddItem( "CenterX", "Center: X Axis" ) ;
oLayout.AddItem( "CenterY", "Center: Y Axis" ) ;
oLayout.AddItem( "CenterZ", "Center: Z Axis" ) ;
oLayout.AddRow();
aSense = new Array ("Above +", 1.0 , "Below -", -1.0 );
oLayout.AddEnumControl( "Sense", aSense, "Sense:", siControlRadio );
oLayout.EndRow();
oLayout.EndGroup();
oLayout.AddRow();
oLayout.AddButton( "OK", "OK") ;
oLayout.AddButton( "Cancel", "Cancel");
oLayout.EndRow();
oLayout.Logic = OK_OnClicked.toString() + Cancel_OnClicked.toString() ;
oLayout.Language = "JScript" ;
InspectObj( oPPG,null,"Rest On Ground" );
function OK_OnClicked()
{
Logmessage ( RestAxis.value );
// Here a real plug-in would actually
// do the calculation
// Destroy the Custom Property (optional)
DeleteObj( PPG.Inspected ) ;
PPG.Close() ;
return;
}
function Cancel_OnClicked()
{
Logmessage ( "Cancelled by User" );
// Destroy the Custom Property (optional)
DeleteObj( PPG.Inspected ) ;
PPG.Close() ;
return;
}
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
OK, something to try ...
In the translate command, I put "null" in the inputObjs field. The translate default value is "selected objects" which would make sense to translate all the objects selected at once. I need to change that to oSelection(oItem) to forced it to only execute on the selected object that I want inside the loop.
To Test tonight.
In the translate command, I put "null" in the inputObjs field. The translate default value is "selected objects" which would make sense to translate all the objects selected at once. I need to change that to oSelection(oItem) to forced it to only execute on the selected object that I want inside the loop.
To Test tonight.
Code: Select all
// Example using an input transform to preserve scaling and rotation
//
var oSelection = Application.Selection;
for (var oItem = 0; oItem < oSelection.Count; oItem++ ) {
// Calculate the local transform of the object to take into account the rotation and scaling
oTransform = oSelection(oItem).Kinematics.Local.Transform ;
// find the bounding box using X3DObject.GetBoundingBox
var vba = new VBArray( oSelection(oItem).GetBoundingBox(oTransform) );
var jsa = vba.toArray();
// calculate the ground translation to translate the object to ground
var toGroundY = - jsa[1];
// Translate the object to ground
Translate(oSelected(oItem), 0, toGroundY, 0, siAbsolute, siLocal, siObj, siXYZ, null, null, null, null, null, null, null, null, null, 0, null);
}
Last edited by Daniel Brassard on 13 May 2016, 19:56, edited 2 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Re: Move an object to the ground
Awesome stuff Daniel! first script works fine! Keep it up!
Only one question does Rest on axis X, Y , Z means rest on YZ,XZ,XY planes?
Only one question does Rest on axis X, Y , Z means rest on YZ,XZ,XY planes?
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: Move an object to the ground
Hi mc_axe,
Yes, this is the LW mimic version of rest on ground. Y being rest on XZ plane (the ground). Myself I would re-label it so we understood which plane the object would rest (the ground would therefore be plane XZ) but in the translate scenario you go up or down on Y to bring your object on the ground so most of the time you would translate in Y, that is why it is coded that way (for now).
The other concept is "sense" which I don't get, I will probably re-label this "rest" .. above ground (+) or below ground (-).
I am open to suggestions to make it more intuitive to SI users.
Yes, this is the LW mimic version of rest on ground. Y being rest on XZ plane (the ground). Myself I would re-label it so we understood which plane the object would rest (the ground would therefore be plane XZ) but in the translate scenario you go up or down on Y to bring your object on the ground so most of the time you would translate in Y, that is why it is coded that way (for now).
The other concept is "sense" which I don't get, I will probably re-label this "rest" .. above ground (+) or below ground (-).
I am open to suggestions to make it more intuitive to SI users.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Re: Move an object to the ground
Pretty cool
but perhaps with a more or less elaborate way, IconList controls (bmps with pressed states) work .
(SI radio buttons can easily be screenshot/cropped to 16x16 bitmaps)
http://softimage.wiki.softimage.com/sdk ... olIconList
http://softimage.wiki.softimage.com/sdk ... ttons.htm#
I don't think so for radiobuttons,Daniel Brassard wrote:P.S. Does anybody know how to force the radio button in the AddEnumControl to be on the same row?
but perhaps with a more or less elaborate way, IconList controls (bmps with pressed states) work .
(SI radio buttons can easily be screenshot/cropped to 16x16 bitmaps)
http://softimage.wiki.softimage.com/sdk ... olIconList
siControlIconList - IconList
Similar to a siControlRadio, except each item is represented by a bitmap on the screen rather than by a text label. Only .bmp files are supported, and the filenames of these files are specified in the PPGItem.UIItems list.
Supported attributes are siUIColumnCnt, siUILineCnt, siUIColumnGap, siUILineGap, siUISelectionColor, and siUIUseSelectionIcon.
http://softimage.wiki.softimage.com/sdk ... ttons.htm#
Icon Buttons
Icon button controls display a group of bitmap icons that the user can select along with an optional animation divot and an optional label. They are associated to an underlying parameter of any numeric type.
You create them using the PPGLayout.AddEnumControl method with the siControlIconList control type enum.Code: Select all
// 1D array of iconpath,value pairs var path = XSIUtils.BuildPath( Application.InstallationPath(siFactoryPath), "Application", "layouts", "bitmaps" ); var aListItems = new Array( path+"\\hairpanel.bmp", 0, path+"\\toolbar_highlight.bmp", 1, path+"\\weightpanel.bmp", 2 ); oLayout.AddEnumControl( "PanelPicker", aListItems, "Panel Picker", siControlIconList );
- wireframex
- Posts: 399
- Joined: 08 Jun 2009, 23:02
- Location: France
Re: Move an object to the ground
Good job Daniel
Phil
Good idea to change the sense label to above and below groundDaniel Brassard wrote:Hi mc_axe,
Yes, this is the LW mimic version of rest on ground. Y being rest on XZ plane (the ground). Myself I would re-label it so we understood which plane the object would rest (the ground would therefore be plane XZ) but in the translate scenario you go up or down on Y to bring your object on the ground so most of the time you would translate in Y, that is why it is coded that way (for now).
The other concept is "sense" which I don't get, I will probably re-label this "rest" .. above ground (+) or below ground (-).
I am open to suggestions to make it more intuitive to SI users.
Phil
Last edited by wireframex on 12 May 2016, 21:34, edited 1 time in total.
"without mastery, power is nothing" - Softimage Addict User
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
- wireframex
- Posts: 399
- Joined: 08 Jun 2009, 23:02
- Location: France
Re: Move an object to the ground
Yesmc_axe wrote:Awesome stuff Daniel! first script works fine! Keep it up!
I'm very happy with it --> I put it already on a button
"without mastery, power is nothing" - Softimage Addict User
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
CPU 3990x 128 Threads / 2 x 3090 RTX - 24 Go / 96 Go memory
- AceMastermind
- Posts: 160
- Joined: 15 Jun 2009, 00:57
- Contact:
Re: Move an object to the ground
Not working in Softimage Mod Tool 7.5, throwing this error:
If Daniel doesn't fix this error in his, my "ground object" script works in 7.5 if anyone needs it:
http://www.si-community.com/community/v ... 819#p54819
on this line:Object doesn't support this property or method
Code: Select all
var vba = new VBArray( oSelection(oItem).GetBoundingBox(oTransform) );
If Daniel doesn't fix this error in his, my "ground object" script works in 7.5 if anyone needs it:
http://www.si-community.com/community/v ... 819#p54819
Who is online
Users browsing this forum: No registered users and 39 guests