Resourcedump

Plugins linking to this thread: (hide)

Get Closest Filtered pointsAuthor: Paul Smith
Disclaimer: This is from the resourcedump thread on si-community.com so »some restrictions may apply« (but usually don't)

A compound that gets ONLY the closest points in the current pointcloud/geometry that have a »true« boolean. It's much much faster than rifling through arrays. Hopefully someone will find this useful. It works by temporarily moving the filtered points up and away on the Y axis, then the remaining points look in the area where the filtered ones got moved to. Then filtered ones are moved back to their original location. The temporary moving of them is nothing to be concerned about because you wont see it and it doesnt affect simulation.

local backup: Get closest filtered points.xsicompound

Matic
Posts: 70
Joined: 18 Jun 2009, 19:58

Re: Resourcedump

Post by Matic » 24 Jan 2013, 17:58

I liked mucking about with Tekano's very cool whirlpool deformer. For comparison/fun I made a similar deformer using the log spiral in the "display shapes" scene I made a while back. Here it is in case anyone is interested in two scenes which do the same thing, both based on log spirals, but with two different approaches to the ICE part (Tekano's is cleaner lol.)

Image

Of (likely) more interest is that I've included a "ridged turbulence" compound in there for fun.

Image
Image

mirrored on my site http://andy.moonbase.net

Cheers
Attachments
alt_whirlpool.zip
Alternate take on log spiral whirlpool deformer.
(158.69 KiB) Downloaded 703 times

Bullit
Moderator
Posts: 2621
Joined: 24 May 2012, 09:44

Re: Resourcedump

Post by Bullit » 24 Jan 2013, 18:10

That looks very nice.

Matic
Posts: 70
Joined: 18 Jun 2009, 19:58

Re: Resourcedump

Post by Matic » 06 Feb 2013, 02:43

Update: I've added to the taper deformer example a few posts back to support any arbitrary axis etc... Makes a good basis for creating more complex deformers, as the internal deformation "formula" can easily be swapped out with different maths. The scene/compound is posted on my blog http://andy.moonbase.net Cheers - AM

Image

Matic
Posts: 70
Joined: 18 Jun 2009, 19:58

Re: Resourcedump

Post by Matic » 07 Feb 2013, 18:22

On another thread there was a question about using ICE to add random movement to a spotlight interest. Here's a scene which should help, it animates a camera interest to have random but smooth motion.
Attachments
example_ICE_AnimateCamInterest.zip
(165.88 KiB) Downloaded 324 times

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Resourcedump

Post by rray » 07 Feb 2013, 18:49

Thanks for all these goodies Andy!
This is a script that spreads the envelope weights from 1 bone over several bones.. Select source bone, target bones in that order then run :)

File: *** DefoRemap.js ***
Hidden content: [ Show ]

Code: Select all

DefoRemap();
function DefoRemap()
{
    var SrcDefo = Selection(0);   
	
    var TgtDefos = new ActiveXObject("XSI.Collection") ;   
    for(i=1; i<Selection.Count; i++)
        TgtDefos.Add(Selection(i));
    
	var SrcDefoIx;	
	var TgtDefoIx = new Array;	
	var oEnv = getEnvelopeFromDeformer(SrcDefo);
    var aDefos = oEnv.Deformers;
    var nbDefos =  aDefos.count;
    for(i=0; i<nbDefos; i++) {
        for(j=0; j<TgtDefos.Count; j++)
            if(aDefos(i).Name == TgtDefos(j).Name)
                TgtDefoIx[j] = i;
		if(SrcDefo.Name == aDefos(i).Name)
			SrcDefoIx = i;	
	}
	
    var aVBWeights = new VBArray( oEnv.Weights.Array );
    var aWeights = aVBWeights.toArray();   
	var nbPoints = oEnv.Owners(0).Geometry.Points.Count;
	
	logmessage("from "+SrcDefo.Name+" (ix="+SrcDefoIx+") to:");
	for(i=0;i<TgtDefos.Count;i++)
		logmessage(TgtDefos(i).Name+" (ix="+TgtDefoIx[i]+")");

    var max_base_wt = 0;
    for( i=0; i<nbPoints; i++) {
        var wt = aWeights[nbDefos*i + SrcDefoIx]; // base
        if(wt > max_base_wt)
            max_base_wt = wt;
    }
    logmessage("max_base_wt of source deformer="+max_base_wt);

    for( i=0; i<nbPoints; i++) {
        var wt = aWeights[nbDefos*i + SrcDefoIx]; // source weight of this point
		aWeights[nbDefos*i + SrcDefoIx] = 0;
       
		var x = wt/max_base_wt; // [0..1]% of max base weight
        var delta_x = 1/TgtDefos.Count;

        for(j=0; j<TgtDefos.Count; j++) {  		
            var result_pct;
            var ideal_x = j/TgtDefos.Count;
            var diff = (x-ideal_x)/delta_x;
			
			if(j==0) {
				if(diff > 1.0)
					result_pct = 0.0;
				else if(diff < 0.0)
					result_pct = 1.0;
				else
					result_pct = 1.0-Math.abs(diff);
			} else if(j==TgtDefos.Count-1) {
				if(diff < -1.0)
					result_pct =  0.0;
				else if(diff > 0.0)
					result_pct = 1.0;
				else
					result_pct = 1.0-Math.abs(diff);
			} else {				
				if(diff > 1.0 || diff < -1.0)
					result_pct = 0.0;
				else					
					result_pct = 1.0-Math.abs(diff);
			}		
            aWeights[nbDefos*i + TgtDefoIx[j]] = max_base_wt * result_pct;
        }
    }

	//normalize
    for( i=0; i<nbPoints; i++) {
        for(j=0; j<nbDefos.Count; j++)  
			total = total + aWeights[nbDefos*i + j];
		for(j=0; j<nbDefos.Count; j++) 
			if(total)
				aWeights[nbDefos*i + j] = aWeights[nbDefos*i + j] * (100/total);
	}

   oEnv.Weights.Array = aWeights
}

function getEnvelopeFromDeformer(inObj)
{
    var aEnvs = FindObjects(null, "{470CF890-D3AA-11d0-996C-00A0243F0E60}");
    var eEnvs = new Enumerator( aEnvs );
    eEnvs.moveFirst();
    for (; !eEnvs.atEnd(); eEnvs.moveNext() )
    {
        var oEnv = eEnvs.item();
        var aDefs = oEnv.Deformers;
        var eDefs = new Enumerator( aDefs )
        for(;!eDefs.atEnd(); eDefs.moveNext())       
            if(eDefs.item().Name == inObj.Name)
                return oEnv;       
    }
    return null;
}
edit [rr]: wrapped all long scripts of this thread in hideme tags

(not much tested and doesn't seem to work with only 2 bones)
softimage resources section updated Jan 5th 2024

Bullit
Moderator
Posts: 2621
Joined: 24 May 2012, 09:44

Re: Resourcedump

Post by Bullit » 28 Feb 2013, 20:00

Camera Sequencer .Js. It was done by Dan Lane while XSIbase was alive.

File: *** Camera_Sequencer_v0_03.js ***
Hidden content: [ Show ]

Code: Select all

Camera Sequencer v0.03

History:
v0.01  03-02-2012
v0.02 (24-05-2012) now works with cameras which are children of a Model null.
v0.03 (30-05-2012) Works with cameras without interest nulls.

Creates a new camera which matches a list of cameras.
work in progress needs lots of error checking/trapping including!

Dan Lane 03-02-2012
*/
	if ( findObj( "Camera_Sequencer" ) != false){
	deleteObj("Camera_Sequencer");
	}
	
	//--------------------------------------
	// UI Layout
	//--------------------------------------
	var oCustomProperty = ActiveSceneRoot.AddCustomProperty( 
					"Camera_Sequencer", 
					false ) ;
	oCustomProperty.AddParameter( "camQueue", siString ) ;
	oCustomProperty.AddParameter3( "Start", siDouble, 0,0,2000,false) ;
	oCustomProperty.AddParameter3( "End", siDouble, 0,0,2000,false) ;
	
	var oPPGLayout = oCustomProperty.PPGLayout ;
	oPPGLayout.AddTab( "Chars" );
	
	var updateButton = oPPGLayout.AddButton( "ADD_TO_LIST" , "Add Selected" ) ;
	updateButton.SetAttribute( siUICX , 260 );
	
	oPPGLayout.AddRow() ;
		
	var removeButton = oPPGLayout.AddButton( "REMOVE_FROM_LIST" , "Remove Item" ) ;
	removeButton.SetAttribute( siUICX , 130 );

	var clearButton = oPPGLayout.AddButton( "CLEAR_LIST" , "Clear list" ) ;
	clearButton.SetAttribute( siUICX , 130 );
		
	oPPGLayout.EndRow() ;
	  
	oPPGLayout.AddGroup( "Camera Queue" , true , 1 ) ;
	   
		AddListBox( oPPGLayout, "camQueue" , 260 , false ) ;
	    
		oPPGLayout.EndGroup() ;
	 
	oPPGLayout.AddGroup( "Time Range", true, 1 ) ;
	oPPGLayout.AddRow() ;
		
			var startSlider = oPPGLayout.AddItem( "Start" ,  "Start:" ) ;
			startSlider.SetAttribute( siUICX , 65 );
			
			var endSlider = oPPGLayout.AddItem( "End" ,  "End:" ) ;
			endSlider.SetAttribute( siUICX , 65 );
		
	oPPGLayout.EndRow() ;
	oPPGLayout.EndGroup() ;
	
	var processButton = oPPGLayout.AddButton( "process" , "Process Queue" ) ;
	processButton.SetAttribute( siUICX , 260 );
	processButton.SetAttribute( siUICY , 35 );

	oPPGLayout.Language = "JScript" ;
	
	oPPGLayout.Logic =	 ADD_TO_LIST_OnClicked.toString() +
						 camQueue_OnChanged.toString() +
						 getItemIndex.toString() +
						 Start_OnChanged.toString() +
						 End_OnChanged.toString() +
						 process_OnClicked.toString() +
						 CLEAR_LIST_OnClicked.toString() +
						 REMOVE_FROM_LIST_OnClicked.toString() +
						 findObj.toString();
					
	InspectObj( oCustomProperty, "", "Camera_Sequencer" , siLock  );




	//--------------------------------------
	// Button Functions
	//--------------------------------------
	function REMOVE_FROM_LIST_OnClicked()
	{
		var itemIndex = getItemIndex();
		
		logmessage("item index = " + itemIndex);
		// get the entire list of items
		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();

		var newList = new Array();
		
		for ( var i = 0 ; i < aItems.length  ; i++ )
			{
				if(i != itemIndex && i != (itemIndex - 1)){
				newList[newList.length] = aItems[i];
				}
			}// end i loop
			
		oItem.UIItems = newList ;
		PPG.Refresh() ;
	}

	function CLEAR_LIST_OnClicked()
	{

		// get current list

		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var aItems = new Array();
		oItem.UIItems = aItems ;
		PPG.Refresh() ;

	}

	function ADD_TO_LIST_OnClicked()
	{
		// get current list

		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();
		
		//var aItems = oItem.UIItems;
		var notInList = true;
		

		inName = selection(0).fullname;
	
		if(notInList){
		logmessage("Name not in list");
			// add to the end of the list
			
			var startTimeStr = "0";
			var endTimeStr = "100";
			
			// if this is not the first item
			if(aItems.length != 0){
			
				var lastString = aItems[aItems.length - 2];
			
				var dashIndex = ( lastString.indexOf("-", 0  ));
				
				startTimeStr =  (   parseFloat(lastString.slice(dashIndex + 2 ,lastString.length)) + 1 );
				endTimeStr = (parseFloat( lastString.slice(dashIndex + 2 ,lastString.length) ) + 100) ;
			}
			
			
			//20 chars
			var blankString = "                     ";
			var inLength = inName.length
			
			if(blankString.length > inName.length){
			
			}else{
			
			}
			var gapString = blankString.slice(inName.length ,blankString.length);
			
			aItems[aItems.length] = (inName + gapString + "@ "+startTimeStr+" - " + endTimeStr) ;
			aItems[aItems.length] = inName ;
			
		}// end if notInList
		
		oItem.UIItems = aItems ;
		PPG.Refresh() ;
		
	}// end function

	function camQueue_OnChanged()
	{
		var itemIndex = getItemIndex();
		
		//logmessage("item index = " + itemIndex);
		// get the entire list of items
		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();
			
			var timesString = aItems[itemIndex - 1];
			var atIndex =   timesString.indexOf("@", 0  );
			var useString = timesString.slice(atIndex , timesString.length);
			
			// extract the times from the timeString
			var spaceIndex = ( useString.indexOf(" ", 0  ));
			
			//logmessage("space index " + spaceIndex);
			var dashIndex = ( useString.indexOf("-", 0  ));
			//logmessage("dash Index " + dashIndex);
			
			var startTimeFloat =     parseFloat(useString.slice(spaceIndex + 1 , dashIndex - 1))  ;
			var endTimeFloat = parseFloat( useString.slice(dashIndex + 2 ,timesString.length) )  ;

			//logmessage("startTimeFloat = " + startTimeFloat);
			
			// set the sliders to these times
			var startSlider = oLayout.Item("Start");
			var endSlider = oLayout.Item("End");
			PPG.Start.Value = startTimeFloat;
			//startSlider.value = startTimeFloat;
			PPG.End.Value = endTimeFloat;
	}// end function

	function Start_OnChanged(){

		if(PPG.Start.Value > PPG.End.Value){
		PPG.End.Value = PPG.Start.Value;
		
		}
		var itemIndex = getItemIndex();
		logmessage( "itemIndex = "+ itemIndex);

		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();
		
		var timeString = aItems[itemIndex - 1];
		logmessage("aItems[itemIndex - 1] = "+ aItems[itemIndex - 1]);
		
		var atIndex =   timeString.indexOf("@", 0  );
		var useString = timeString.slice(0, atIndex + 1);
		
		aItems[itemIndex - 1] = ( useString + " " + PPG.Start.Value +" - " + PPG.End.Value) ;
		
		oItem.UIItems = aItems ;
		PPG.Refresh() ;
		
	}

	function End_OnChanged(){

		if(PPG.Start.Value > PPG.End.Value){
		PPG.Start.Value = PPG.End.Value;
		
		}
		var itemIndex = getItemIndex();
		//logmessage( "itemIndex = "+ itemIndex);

		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();
		
		
		var timeString = aItems[itemIndex - 1];
		//logmessage("aItems[itemIndex - 1] = "+ aItems[itemIndex - 1]);
		
		var atIndex =   timeString.indexOf("@", 0  );
		var useString = timeString.slice(0, atIndex + 1);
		
		aItems[itemIndex - 1] = ( useString + " " + PPG.Start.Value +" - " + PPG.End.Value) ;
		//aItems[aItems.length] = inName ;
		oItem.UIItems = aItems ;
		PPG.Refresh() ;
		
	}

	function getItemIndex(){

		// find out which item is clicked
		var clickedStr =  PPG.Inspected(0).Parameters("camQueue").Value;

		// get the entire list of items
		var oLayout =  PPG.PPGLayout ;
		var oItem = oLayout.Item("camQueue");
		var vbItems = new VBArray(oItem.UIItems);
		var aItems = vbItems.toArray();

		// find the clicked item in the entire list
		var itemIndex = -1;
		var counter =  0;
		while(counter < aItems.length){
		
			if( clickedStr == aItems[counter]){
			itemIndex = counter;
			counter =  (aItems.length + 1);
			}
		
		counter ++ ;
		}// end while loop

	return(itemIndex);
	}

function process_OnClicked()
{
	var matchCam = findObj( "matchCam" ) ;
	
	if (matchCam == false){
	}else{
		// use the camera
		var o3DObjCamera = Dictionary.GetObject("matchCam");
		var oPrimObjCameraInterest = o3DObjCamera.Interest;
		deleteObj(o3DObjCamera.fullname);
		//deleteObj(oPrimObjCameraInterest.fullname);
	}
		// create camera
		rtn = SIGetPrimCamera( "Camera", "matchCam", "matchCamInterest" );
		var o3DObjCamera = rtn.Value("3DObjCamera" );
		var o3DObjCameraInterest = rtn.Value("3DObjCameraInterest" );
		var oPrimObjCamera = rtn.Value( "PrimObjCamera" );
		var oPrimObjCameraInterest = rtn.Value(" PrimObjCameraInterest" );
		deleteObj(o3DObjCameraInterest.fullname);
		
	var oLayout =  PPG.PPGLayout ;
	var oItem = oLayout.Item("camQueue");
	var vbItems = new VBArray(oItem.UIItems);
   	var aItems = vbItems.toArray();

	// generate the pose constraints
	for ( var i = 0 ; i < aItems.length  ; i += 2 )
	{
		//Use i
		var timesString = aItems[i];
		var nameValue = aItems[i + 1];
		//logmessage("timeString " + timesString);
		var atIndex =   timesString.indexOf("@", 0  );
		var useString = timesString.slice(atIndex , timesString.length);
		
		// extract the times from the timeString
		var spaceIndex = ( useString.indexOf(" ", 0  ));
		
		//logmessage("space index " + spaceIndex);
		var dashIndex = ( useString.indexOf("-", 0  ));
		//logmessage("dash Index " + dashIndex);
		
		var startTimeFloat =     parseFloat(useString.slice(spaceIndex + 1 , dashIndex - 1))  ;
		var endTimeFloat = parseFloat( useString.slice(dashIndex + 2 ,timesString.length) )  ;
		
		// get the camera to match to
		logmessage(nameValue);
		var matchCamera = Dictionary.GetObject(nameValue);
		
		// get some settings off the camerea
		if(i == 0){
		var camFormat = matchCamera.Parameters("std").Value;
		o3DObjCamera.Parameters("std").Value = camFormat;
		}
		if( matchInt == null){
		
			


				logmessage("Undefined");
		}else{
		
				logmessage("OK");
		}
		
		// get the interest to match to
		var matchInt = matchCamera.Interest;
		
		// add the constraints
		var oConstaintCam = o3DObjCamera.Kinematics.AddConstraint( "Pose", matchCamera , false );
		//var oConstaintInt = o3DObjCameraInterest.Kinematics.AddConstraint( "Pose", matchInt , false );
		
		// key the active parameters
		var activeParam = oConstaintCam.Parameters("active");
		//var activeParamInt = oConstaintInt.Parameters("active");
		
		if ( ClassName(activeParam.source) != "FCurve" ) {
					activeParam.AddFCurve2();
			}
		//if ( ClassName(activeParamInt.source) != "FCurve" ) {
		//			activeParamInt.AddFCurve2();
		//	}
		
		var activeCurveCamera = activeParam.Source;
		//var activeCurveInt = activeParamInt.Source;
		
		activeCurveCamera.AddKey( startTimeFloat - 1 , 0  ) ;
		activeCurveCamera.AddKey( startTimeFloat , 1  ) ;
		activeCurveCamera.AddKey( endTimeFloat + 1 , 0  ) ;
		activeCurveCamera.AddKey( endTimeFloat , 1  ) ;
		
		
		//activeCurveInt.AddKey( startTimeFloat - 1 , 0  ) ;
		//activeCurveInt.AddKey( startTimeFloat , 1  ) ;
		//activeCurveInt.AddKey(  endTimeFloat + 1 , 0  ) ;
		//activeCurveInt.AddKey(  endTimeFloat , 1  ) ;
		
	}// end i loop

	// create the script op for the fov
	var inFovParam = o3DObjCamera.Parameters( "fov" );
	var code = " function myCns_Update( In_UpdateContext, Out ," ; 

			//InTimeWarp , InpreviewSpeed 
			var camNamesArray = new Array();
			var counter = 0;
			for ( var i = 0 ; i < aItems.length  ; i += 2 )
				{
					if(i > 0){
							
							camNamesArray[camNamesArray.length] = "Infov" + counter;
						
						}else{
							
							camNamesArray[camNamesArray.length] = "Infov";
						}
					counter ++;
				};
				
		var camNameString = camNamesArray.join(",");
			
		code += camNameString ; 
		code += " ) \n" ;
		code += " { \n";
		code += "	var current_frame = In_UpdateContext.operator.current_frame.value; \n " ;
		var counter = 0;
		for ( var i = 0 ; i < aItems.length  ; i += 2 )
				{
				
				var timesString = aItems[i];
				var nameValue = aItems[i + 1];
				//logmessage("timeString " + timesString);
				var atIndex =   timesString.indexOf("@", 0  );
				var useString = timesString.slice(atIndex , timesString.length);
				
				// extract the times from the timeString
				var spaceIndex = ( useString.indexOf(" ", 0  ));
				
				//logmessage("space index " + spaceIndex);
				var dashIndex = ( useString.indexOf("-", 0  ));
				//logmessage("dash Index " + dashIndex);
				
				var startTimeFloat =     parseFloat(useString.slice(spaceIndex + 1 , dashIndex - 1))  ;
				var endTimeFloat = parseFloat( useString.slice(dashIndex + 2 ,timesString.length) )  ;
				
				if(i == 0){
						code += "if(current_frame >= " + startTimeFloat + " && current_frame <= " + endTimeFloat + "){ \n" ;
						
					}else{
					
						code += "else if(current_frame >= " + startTimeFloat + " && current_frame <= " + endTimeFloat + "){ \n" ;
					}
					code += " var outValue = " + camNamesArray[counter] + ".Value ; \n";
					code += " } " ;
					
					
				counter ++ ;
				}// end i loop
		
		
		code += "\n  Out.Value = outValue ; \n";
		code += " } \n";
		
		var op = XSIFactory.CreateScriptedOp( "myCns", code , "JScript" );
		op.AddOutputPort( inFovParam , "");
		
		for ( var i = 0 ; i < aItems.length  ; i += 2 )
				{
				op.AddInputPort(  aItems[i + 1] + ".camera.fov" );
				}
				
		
		
		var pdef = XSIFactory.CreateParamDef("current_Frame", siInt4, 0, siAnimatable, "", "", 1, -100000, 100000,0,1);
		var current_Frame_param = op.AddParameter(pdef);
		op.Connect();
		SetExpr(op + ".current_frame","fc");
	

	}// end function

	function AddListBox( in_oLayout, in_Name , width , multi)
	{
		// Insert a ListBox into the layout
		var oItem = in_oLayout.AddItem( in_Name, "", "ListBox" ) ;
		oItem.SetAttribute( "CY", 175 ) ;
		oItem.SetAttribute( "CX", width ) ;
		oItem.SetAttribute( "NoLabel", true ) ;
		//Note: Multi-selection list box control only applies to string parameter.
		oItem.SetAttribute( siUIMultiSelectionListBox, multi ) ;
	}

	function findObj( inObj ) {
		var oColl = new ActiveXObject("XSI.Collection"); 
		oColl.items = inObj;
		
		if (oColl.count > 0) {
			return(oColl(0));
		} else {
			return(false);
		}
		
	}
edit [rr]: wrapped all long scripts of this thread in hideme tags

I have taken off the email from Dan Lane to not get into search engines. PM me if needed.

gfxman
Posts: 92
Joined: 28 Mar 2011, 15:14

Re: Resourcedump

Post by gfxman » 14 Mar 2013, 12:28

Up! This topic can't fade away, too usefull!

User avatar
SamHowell
Posts: 364
Joined: 09 Jun 2009, 14:09
Location: Birmingham
Contact:

Re: Resourcedump

Post by SamHowell » 14 Mar 2013, 12:58

gfxman wrote:Up! This topic can't fade away, too usefull!
I agree! Add it to the banner.

User avatar
Tekano
Posts: 488
Joined: 09 Jun 2009, 14:49
Location: London, UK

Re: Resourcedump

Post by Tekano » 19 Mar 2013, 22:37



was getting to low down in the stack, bringing it back up again. no freebies just a picture of ICE tree this time. could not be simpler. emitting 200k particles a second and simulating at 4 fps, cant be bad!

enjoy!
Attachments
Capture_twister_nodes.JPG
Gossip is what no one claims to like, but everybody enjoys.

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Resourcedump

Post by rray » 19 Mar 2013, 23:30

Nice ones! Thanks for the continued reanimation of the resource dump!

I have a few scripts on stock which are based on/modified factory scripts, so I can't publish/post them here in their completeness. I'll try and extract the bits that i wrote, hoping they're somehow operational.

This one imports ZBrush polypaint/weights from a previously imported mesh. Import then call this function with the same object/filename.

Parameters = object name, filename, bool import zbrush polypaint, bool import zbrush weight map

File: *** ImportPolyPaint.vbs ***
Hidden content: [ Show ]

Code: Select all

sub ImportPolyPaint( theObject, Filename, bPP, bWeights)
	if not (bWeights or bPP) then exit sub
	
	if bWeights then
		set oWm  = CreateWeightMap ( "WeightMap", theObject, "ZBrushWeights", "Weight Map Property")(0)
		ElArrayWm = oWm.Elements.Array
	end if
	
	if bPP then	
		set oVc = theObject.ActivePrimitive.Geometry.AddVertexColor
		ElArrayVc = oVc.Elements.Array
	end if
	
	set verts = theObject.ActivePrimitive.Geometry.Points
	
	Dim fso, objFile
	Const ForReading = 1, ForWriting = 2, ForAppending = 8
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set objFile = fso.OpenTextFile(Filename, ForReading)
	
	dim oProgressBar
	set oProgressBar = XSIUIToolkit.ProgressBar

	oProgressBar.Maximum = verts.Count
	oProgressBar.Step = 100
	oProgressBar.CancelEnabled = true
	oProgressBar.Caption = "Importing PolyPaint/Weights"
	oProgressBar.Visible= true
 
	ix = 0
	maxix = verts.Count
	Do Until objFile.AtEndOfStream 
		aVar = objFile.ReadLine
		pInLine = 7
		if left(aVar,5) = "#MRGB" then
			mrgb = mid(aVar, pInLine, 8)	
			while mrgb <> "" and ix < maxix	
				weight = CLng("&h"&left(mrgb,2))
				if ix < maxix then
					if bWeights then ElArrayWm(0,ix) = 1 - weight/255
					
					set smpls = verts(ix).Samples
					smplc = smpls.Count
					for j=0 to smplc-1
						if bPP then 
							ElArrayVc(0, smpls(j).Index) = CLng("&h"&mid(mrgb,3,2))/255
							ElArrayVc(1, smpls(j).Index) = CLng("&h"&mid(mrgb,5,2))/255
							ElArrayVc(2, smpls(j).Index) = CLng("&h"&mid(mrgb,7,2))/255
						end if
					next				
					pInLine = pInLine + 8
					mrgb = mid(aVar, pInLine, 8)			
				end if
				ix = ix + 1
				if ix mod 100 = 0 then
					oProgressBar.Increment
					if oProgressBar.CancelPressed then exit sub
					logmessage(ix & " of " & maxix)
				end if
			wend 		
		end if
	loop 
	oProgressBar.Visible= false
	if bWeights then oWm.Elements.Array = ElArrayWm
	if bPP then oVc.Elements.Array = ElArrayVc
	
	objFile.Close
end sub
edit [rr]: wrapped all long scripts of this thread in hideme tags
softimage resources section updated Jan 5th 2024

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Resourcedump

Post by rray » 20 Mar 2013, 01:01

from another thread:
... this assigns a random color (color at vertex property) for each UV island.

It's [strike]quite[/strike] very slow, so anytips on how to speed it up are quite welcome

(quick usage .. connect compound, pick "UVs" attribute from tproj, create color at vertices map, pick "Colors" attribute from that map, wait............................................, use color map lookup node in render tree to read from that map)

Image
file: RandomColorByUVIsland.xsicompound
softimage resources section updated Jan 5th 2024

Falam

Re: Resourcedump

Post by Falam » 20 Mar 2013, 02:17

Did you update it ? This is a nice tool, I passed the idea to RRay :)

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Resourcedump

Post by rray » 20 Mar 2013, 02:37

No update there, didn't have the time. Yes credits for this idea go to you :)
[removed your fullquote]
softimage resources section updated Jan 5th 2024

Haimund
Posts: 29
Joined: 29 Mar 2013, 01:24

Re: Resourcedump

Post by Haimund » 10 May 2013, 18:44

Hi, thank you all for the sharing. :-bd

I have a question.
for the"whirlpool ", does anyone knows how to move the origin of the whirlpool? instead of move the mesh but keep the center in the <<0, 0, 0>>?
i mean when i try Tekano san's compound, there is a origin port, but when i move the null, instead move the center, it move the mesh... and for Matic's one, i just simply add a kine.global.pos to the pointposition, and got the same result.

is there a right way to do this?
or i can only move my camera to match it......> <

thank you.

Matic
Posts: 70
Joined: 18 Jun 2009, 19:58

Re: Resourcedump

Post by Matic » 10 May 2013, 23:38

Here you go Haimund, this is a v2 scene of the whirlpool deform with an exceedingly useful compound in it which can be used to apply deformations in a space local to the host geometry. The whirlpool and ridged turbulence nodes have been cleaned up and turned into proper compounds, too. In this image I've "tilted" the deformation a bit to illustrate this. The sphere shows the ridged turbulence applied as a deformer and that it is respecting the sphere's surface normals.

Image

Basically when you deform geometry as Rob and I did in our earlier examples, the deformation is calculated relative to the global origin. But as you note, in practical use you really need those deformations to be in the space of the deformed object. The solution to this is to take all the points in your geometry and superimpose them with the origin (by multiplying the point positions with the inverse matrix of the objects center). You then calculate your deformations, and move them back to their relative positions (multiply the deformed points by the object's matrix.) It's a simple operation but can be a little tough to visualize at first...

The compound I mentioned simply performs the inverse matrix operation (ie moves all points as if the object was at the origin), then has an execute node (so you can plug in your deformation operations), and then reverses the matrix transformation to put the points back to be relative to the object's center. You can use it "after the fact" to perform this technique- if you try it on Tekano's scene it should work, too.

Here is a zip containing the revised scene plus the compounds:
Attachments
example_whirlpoolDeformer2.zip
example scene, softimage 2013, plus compounds
(247.53 KiB) Downloaded 483 times

Haimund
Posts: 29
Joined: 29 Mar 2013, 01:24

Re: Resourcedump

Post by Haimund » 11 May 2013, 02:21

thank you! THIS IS AWESOME! :D
i'm pretty bad at the kinematics and matrix things. :-B
and i'm trying to combine the wave-curl (http://www.si-community.com/community/v ... f=19&t=109)and this one to make a effect, but the funny thing is for wave-curl, you cannot move the mesh, otherwise you will get a mess. but u can move the null anywhere you want. and for this one before, you can only move the mesh to locate it......well, i better just keep everything in the world center and move my camera......

thank you, this is cool. :ympray:

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests