//
//	highlight.js
//
//	Softimage XSI Script
//
//	Author: Guy Rabiller - grabiller@storkcom.fr
//
//	Copyright: @2000, Guy Rabiller. This script is free and is a
//			   gift to the Softimage community.
//
//	Scenario: Select a surface object, then apply the script.
//			  Select the null constrained on the surface, adjust its
//			  U & V Location to postion precisely the Specular impact 
//			  point of the Spot Light created.
//

objList = GetValue( "SelectionList" ) ;

if( objList.Count == 1 )
{
	if( objList.Items(0).Type == "surfmsh" )
	{
		objName = objList.Items(0).Name ;
		//
		hl = objName + "_highlight" ;
		hl = GetPrim("Null", hl, null) ;
		//
		hlcam = hl + "_camCNS" ;
		hlcam = GetPrim("Null", hlcam, null) ;
		//
		hllight = hl + "_lightCNS" ;
		hllight = GetPrim("Null", hllight, null) ;
		//
		CopyPaste( hlcam, null, hl, 1) ;
		CopyPaste( hllight, null, hl, 1) ;
		//
		hlspot     = hl + "_spot" ;
		hlspotRoot = GetPrimLight("Spot.Preset",hlspot) ;
		//
		CopyPaste( hlspotRoot, null, hl, 1) ;
		//
		CopyPaste( hl, null, objName, 1)
		//
		ApplyCns("Surface", hl, objName, null)
		SetValue(hl+".kine.surfcns.tangent", true, null)
		SetValue(hl+".kine.surfcns.upvct_active", true, null)
		//
		ApplyCns("Position", hlcam, "Camera", null)
		AddExpr(hllight+".kine.local.posx", "- "+hlcam+".kine.local.posx")
		AddExpr(hllight+".kine.local.posy",      hlcam+".kine.local.posy")
		AddExpr(hllight+".kine.local.posz", "- "+hlcam+".kine.local.posz")
		//
		ApplyCns("Position", hlspot+"_Interest", hl, null)
		ApplyCns("Position", hlspot, hllight, null)
		//
		SelectObj(hl, null, null) ;
		//
		LogMessage( objName + " Highlighted :-)") ;
		//
	} else {
		LogMessage( "Select a Surface Mesh ( Nurbs )", siError ) ;
	}
} else if( objList.Count == 0 ) {
	LogMessage( "Select 1 Surface Mesh ( Nurbs )", siError ) ;
} else {
	LogMessage( "Select only 1 Surface Mesh ( Nurbs )", siError ) ;
}


