Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
Scripting : how to move samples from a polygon selection ?

Scripting : how to move samples from a polygon selection ?

2005-05-08       - By Guillaume Laforge

 Back
Reply:     1     2     3  

Hi,

I'm writing a little script to create a matte pass based on clusters.
Here is a first try :

/-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
/*Cluster_matte_01.js
Guillaume Laforge 05-2005

Put the selected object with a cluster named "matte" in a partition
with a material. It render the "matte" cluster in white and all the
other poly in black
*/
var oSel = Selection.Item(0)
var oGeo = oSel.ActivePrimitive.Geometry;
var oClusters = oGeo.clusters;

// Check if object has clusters named "matte"
if(oClusters.count!=0)
{
  for(var i=0;i<oClusters.count;i++)
  {
  if (oClusters(i).Name == "matte" )
    {
    SelectObj ( oClusters );
    //create the cluster matte UV proj.
    CreateProjection(oSel+".polymsh.cls.matte", null,
siTxtDefaultPlanarXY, "", "Texture_Proj_Matte", null, null, null);
    //Create the cluster matte partition
    SelectObj (oSel )
    CreatePartition(null,"cluster_matte", null, null);

    //create the cluster matte material
    SICreateMaterial(null,"cluster_matte","Sources.Materials.DefaultLib",
"", null, null);

    CopyPaste(null, "Shaders\\Texture\\Image.Preset",
"TransientObjectContainer", null);
    SIConnectShaderToCnxPoint("TransientObjectContainer.Image",
"Sources.Materials.DefaultLib.cluster_matte.surface", false);
    CopyPaste(null, "Shaders\\Texture\\Share\\Color_share.Preset",
"TransientObjectContainer", null);
    SIConnectShaderToCnxPoint("TransientObjectContainer.Color_share",
"Sources.Materials.DefaultLib.cluster_matte.Image.tex", false);

    //matte color
    SetValue("Sources.Materials.DefaultLib.cluster_matte.Image.Color_share.input
.red",
1, null);
    SetValue("Sources.Materials.DefaultLib.cluster_matte.Image.Color_share.input
.green",
1, null);
    SetValue("Sources.Materials.DefaultLib.cluster_matte.Image.Color_share.input
.blue",
1, null);
    SetValue("Sources.Materials.DefaultLib.cluster_matte.Image.Color_share.input
.alpha",
1, null);

    RemoveShaderFromCnxPoint("Sources.Materials.DefaultLib.cluster_matte.Phong",
"Sources.Materials.DefaultLib.cluster_matte.shadow", false);
    RemoveShaderFromCnxPoint("Sources.Materials.DefaultLib.cluster_matte.Phong",
"Sources.Materials.DefaultLib.cluster_matte.Photon", false);
    }
  }
}
/-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
-- ---- ---- ---- ---- -----

My pb is that for objects like a sphere for exemple, the texture projection
see the poly from behind too and  they also render in white :-(  (even
if they are not belong to the cluster ).
I need to select all the poly who aren't in the matte cluster and
remove them from UV space.

I try this :
/-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
-- ---- ---- ----
//There is a polygon cluster named "matte" in the selected object.
var oSel = Selection(0)

//Select all the poly who are not in the "matte" cluster
SelectMembers(oSel+".polymsh.cls.matte", null, null);
var oPoly = InvertSelection("Polygon", null, null);
//move the samples outside UV space for poly who are not in the "matte" cluster.
for(var i=0;i<oPoly.count;i++)
  {
  var oSamples = oPoly(i).Samples
  TranslateUVW(oSamples,
oSel+".polymsh.cls.Texture_Coordinates_AUTO.Texture_Proj_Matte", -1,
-1, 0, siAbsolute, siU, true);
  }
/-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
-- ---- ---- ---- -----
But I've got : //ERROR : 'oPoly.count' a la valeur Null ou n'est pas
un objet. - [line 8]

Any idea on how to access all the polygons who are not in the "matte"
cluster is welcome :-)

Cheers,

Guillaume Laforge
CG artist
www.vol2nuit.fr

PS : you can download scripts here :
http://www.vol2nuit.fr/scripting/cluster_matte.zip

---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi