可以在一表面上連續復制物體 的 script 'Surface Duplicator

各XSI / Softimage/Face Robot 用戶可在這裡交流問題和分享制作經驗

版主: HapZungLam

可以在一表面上連續復制物體 的 script 'Surface Duplicator

文章aj » 12日 8月 2002年, 15:14

可以在一表面上連續復制物體 的 addon.. 例如可以做 球面上粘著一堆更小的球 由 Kim Aldis 制作

簡易用法
1. 安裝 File/addons/ install.. 安裝此檔
2. Run Script
3. 選取 想要"粘"上去的 surface (Polygon不行)
4. 選取欲復制的物體 調整參數 完成

細節如下: (From Kin Aldis)

OK, try this one. It's a javascript tool. Run it, select the surface then the object to be duplicated. A dialog pops up:-

uFrom, uTo. The u range for the constraint parameter u (0-1)
vFrom, vTo, as above

uDIther, vDither. A dither for randomising the positioning of objects on the surface. The percentage is the distance between the object and it's neighbouring objects.

Tangency constraint. A toggle, whether or not to direction constrain the objects on the surface.

uCount, vCount. How many objects in u and v to duplicate. Remember, 20 x 20 is 400; the object count can rise pretty quickly.

It's not really optimised and it gets a bit slow as the count numbers start to rise but otherwise, it seems to work quite well. It would probably speed up a bit if it was fully converted to the OM.


As an aside, first time you use the script in any given scene, it creates a custom parameter set which it doesn't delete when it's done. Next time it's run it looks for this parameter set and uses the values you've left in it. The idea is to keep a prefered set of parameters around for later.

Kim Aldis
Be 5D。
頭像
aj
討論區新秀
討論區新秀
 
文章: 43
註冊時間: 9日 8月 2002年, 09:55
來自: Outer Space.

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章Cyber Oxygen » 12日 8月 2002年, 19:07

aj兄:
我想問一下這個program 適合什麼ver 的Softimage?

8)
頭像
Cyber Oxygen
討論區主持
討論區主持
 
文章: 745
註冊時間: 30日 4月 2002年, 12:54

文章Truth » 12日 8月 2002年, 19:48

.addon 是 2.X 才能夠用的
還是貼成文字版本方便大家


var oSurface, oObject;

main();

function main() {
// Get the user pick his objects
if ( ! PickObjects() ) {
logmessage( "Cancelled by user" );
return;
}

// Build a PPG
ppg = DoPPG( "Dup" );

// and do the duplication and surface constraints
doDup( oSurface, oObject, ppg );

}
////////////////////////////////////////////////////////
//
// Do the object duplication and constraining.
// an option here would be to use instances instead
// especially for large duplications
//
// currently no facility for groups
// Maybe it works, I don't know, I haven't tried it.
//
///////////////////////////////////////////////////////
//{{{
function doDup( oSurface, oObject, ppg ) {
var uFrom, uTo;
var vFrom, vTo;
var uDither, vDither;
var uCount, vCount;
var doConstrain;
var u,v;


// get the user params from the Dup ppg
uFrom = getValue( ppg + ".uFrom" );
uTo = getValue( ppg + ".uTo" );

vFrom = getValue( ppg + ".vFrom" );
vTo = getValue( ppg + ".vTo" );

doConstrain = getValue( ppg + ".Tangency" );

uCount = getValue( ppg + ".uCount" ) - 1;
vCount = getValue( ppg + ".vCount" ) - 1;

// calculate the u and v step size for the dup loop
var uStep = (uTo - uFrom)/uCount;
var vStep = (vTo - vFrom)/vCount;

uDither = getValue( ppg + ".uDither" ) / 100 * uStep;
vDither = getValue( ppg + ".vDither" ) / 100 * vStep;

vSave = vFrom

// a null to parent all these new objects to
// We don't want a cluttered Explorer and Schematic, do we.
var theRoot = GetPrim("Null", "SurfDup", null);

var Row = 1; // we can name each row of dups sensibly

// The u/v build loop
while ( uFrom <= uTo ) {
vFrom = vSave

// a null to act as parent to this v Row
var theRow = GetPrim("Null", "Row_" + Row++, null);
while ( vFrom <= vTo ) {

// duplicate the object
oDup = Duplicate( oObject, null, 2, 1, 1, 0, 0, 1, 0, 1, null, null, null, null, null, null, null, null, null, null);

// and constrain it
ApplyCns( "Surface", oDup, oSurface, null);

// do the normal constraint if our user wants us to
if ( doConstrain ) {
SetValue( oDup + ".kine.surfcns.upvct_active", true, null);
}

// calculate the u/v offset param for the surface constraint
var uOff = uFrom + (Math.random()-0.5) * uDither;
var vOff = vFrom + (Math.random()-0.5) * vDither;

// clamp to 0-1 range
uOff = Clamp( uOff );
vOff = Clamp( vOff );

SetValue( oDup + ".kine.surfcns.posu", uOff, null);
SetValue( oDup + ".kine.surfcns.posv", vOff, null);
ParentObj( theRow, oDup);

vFrom += vStep;
}
// and finally, parent this row of objects to the root null
ParentObj( theRoot, theRow);

uFrom += uStep;
}


}
///}}}
/////////////////////////////////////////
// clamp a number to lie in the range 0-2
/////////////////////////////////////////
//{{{
function Clamp( t ) {

if ( t < 0 ) {
t = 0;
}
if ( t > 1 ) {
t = 1;
}

return t;
}
//}}}
/////////////////////////////////////////
//
// build a ppg so our user can give us some
// parameters
//
// We don't build a ppg if one named 'Name'
// already exists. That way, by not deleting
// the ppg when we've finished, our user
// can get to keep the parameters for this
// script in case he needs to use them
// again. Saves some typing
//
///////////////////////////////////////////
function DoPPG( Name ) {
var ppg;


try {

// try and get a param from our ppg
var i = getvalue( Name + ".uFrom" );

// it's succeeded so get it as object
// This gets a collection of kids
var oCollection = EnumElements( Application.ActiveProject.ActiveScene.Root + "." + Name,null,null )
var e = new Enumerator(oCollection);

// so enum back up to the first element's parent
// which will be our 'name' property set.
oCollection = EnumElements( e.item(), false, null );
e = new Enumerator(oCollection);
ppg = e.item();

} catch(e) { // it's failed, so build a new ppg

ppg = buildPPG( Name );

}


// show it to the user.
InspectObj( ppg,"","SurfaceDup" ,siModal );

return ppg;



}
function buildPPG( Name ) {

var Root = Application.ActiveProject.ActiveScene.Root
var ppg = Root.AddProperty("Custom_parameter_list",false, Name);


SIAddCustomParameter( ppg, "uFrom", siDouble, 0, 0, 1, null, 5, 0, 1, null, null);
SIAddCustomParameter( ppg, "uTo", siDouble, 1, 0, 1, null, 5, 0, 1, null, null);

SIAddCustomParameter( ppg, "uDither", siDouble, 0, 0, 100, null, 5, 0, 100, null, "U Dither %");


SIAddCustomParameter( ppg, "vFrom", siDouble, 0, 0, 1, null, 5, 0, 1, null, null);
SIAddCustomParameter( ppg, "vTo", siDouble, 1, 0, 1, null, 5, 0, 1, null, null);

SIAddCustomParameter( ppg, "vDither", siDouble, 0, 0, 100, null, 5, 0, 100, null, "V Dither %");

SIAddCustomParameter( ppg, "Tangency", siBool, 0, 0, 1, null, 5, 0, 1, null, "Keep Tangency Constrained" );

SIAddCustomParameter( ppg, "uCount", siInt4, 3, 0, 100, null, 5, 0, 100, null, null);
SIAddCustomParameter( ppg, "vCount", siInt4, 3, 0, 100, null, 5, 0, 100, null, null);

return ppg;


}

///////////////////////////////////////
//
// Get the user to pick our objects
// surface first, then the object we
// want to duplicate
//
// return 0 if the user middle clicks
//
//////////////////////////////////////
//{{{
function PickObjects() {

var oBuffer = PickElement( "surface_mesh", "Pick Surface", "Pick Surface", null, null );
if ( !oBuffer.value( "ButtonPressed" ) ) {
// User cancelled pick session
return( 0 );
}


oSurface = oBuffer.value( "PickedElement" );

oBuffer = PickElement( "object", "Pick Object to Duplicate", "Pick Object to Duplicate", null, null );
if ( !oBuffer.value( "ButtonPressed" ) ) {
// User cancelled pick session
return( 0 );
}


oObject = oBuffer.value( "PickedElement" );

return 1;

}
//}}}
頭像
Truth
討論區新秀
討論區新秀
 
文章: 47
註冊時間: 31日 12月 2001年, 08:00
來自: H.K.

文章aj » 12日 8月 2002年, 20:17

hi
我目前的版本是2.0. 你的是1.5嗎 ? 至於1.5 就用 Truth兄 貼的 script 吧.
Be 5D。
頭像
aj
討論區新秀
討論區新秀
 
文章: 43
註冊時間: 9日 8月 2002年, 09:55
來自: Outer Space.

文章HapZungLam » 12日 8月 2002年, 22:04

what is surface duplicate? what does that do?
頭像
HapZungLam
討論區主持
討論區主持
 
文章: 1143
註冊時間: 30日 8月 2001年, 08:00
來自: Vancouver

文章aj » 12日 8月 2002年, 23:06

It can "glue" multiple objects on a surface with a uv/repetition/random options. You can duplicate your polygon hairs on your head skin(surface) for example.
Be 5D。
頭像
aj
討論區新秀
討論區新秀
 
文章: 43
註冊時間: 9日 8月 2002年, 09:55
來自: Outer Space.

文章Cyber Oxygen » 12日 8月 2002年, 23:14

softimage 3d 不可能ma?
頭像
Cyber Oxygen
討論區主持
討論區主持
 
文章: 745
註冊時間: 30日 4月 2002年, 12:54

文章aj » 12日 8月 2002年, 23:44

no.. 這是 for XSI的
softimage 3d 有類似的 duplicate on tag points..
Be 5D。
頭像
aj
討論區新秀
討論區新秀
 
文章: 43
註冊時間: 9日 8月 2002年, 09:55
來自: Outer Space.


回到 Autodesk Softimage

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 2 位訪客

cron