/*
*/
//
scene=window.getScene();
sel=scene.getSelection();
if (sel.length==0)
{
new MessageDialog(window, "Please select one Triangle Mesh");
return;
}
selObj=scene.getObject(sel[0]);
if (selObj.object instanceof TriangleMesh ==false)
{
new MessageDialog(window, "Object must be a Triangle Mesh");
return;
}
//
wantDirt=false;
wantScratches=false;
wantDust=false;
//
// create dialogue to get user to select the type of effect(s)
//
dirtChoice=new BCheckBox();
scratchChoice=new BCheckBox();
dustChoice=new BCheckBox();
widgets=new Widget[]{dirtChoice,scratchChoice,dustChoice};
names=new String[]{"Dirt","Scratches","Dust"};
dial=new ComponentsDialog(window,"Select Effects Required:",widgets,names);
//
if (!dial.clickedOk()) return;
if (dirtChoice.getState()) wantDirt=true;
if (scratchChoice.getState()) wantScratches=true;
if (dustChoice.getState()) wantDust=true;
//
//
//*****DIRT in creases******
if (wantDirt)
{
// get textures in scene for dialogue
numT=scene.getNumTextures();
texList=new BComboBox();
tolField=new ValueField(120,ValueField.POSITIVE);
probField=new ValueField(100,ValueField.POSITIVE+ValueField.INTEGER);
for (i=0;i","Probability(%)"};
dial=new ComponentsDialog(window,"Select Parameters for Scratches",widgets,names);
tolerance=360-tolField.getValue();
prob=probField.getValue();
//
if (!dial.clickedOk()) return;
selTexIndx=texList.getSelectedIndex();
selTex=scene.getTexture(selTexIndx);
//
object=selObj.object;
// get the object's current texture and create a layered texture
// retaining existing mapping
//
objTex=object.getTexture();
texMap=object.getTextureMapping();
layer=false;
if (texMap instanceof LayeredMapping) layer=true;
//
if (layer)
{
texMap.addLayer(selTex);
texMap.setLayerMapping(0,selTex.getDefaultMapping());
texMap.setLayerMode(0,2); // set top layer to Overlay with Bumps
}
if (!layer)
{
layTex=new LayeredTexture();
layTexMap=layTex.getDefaultMapping();
layTexMap.addLayer(objTex);
layTexMap.setLayerMapping(0,texMap);
layTexMap.addLayer(selTex);
layTexMap.setLayerMapping(0,selTex.getDefaultMapping());
layTexMap.setLayerMode(0,2); // set top layer to Overlay with Bumps
}
//
vert=object.getVertices();
numVert=vert.length;
tpVal=new double[numVert];
//
// determine texture parameters for mapping dirt texture
paramVal=new VertexParameterValue(tpVal);
normals=object.getNormals();
edges=object.getEdges(); //get the edges
faces=object.getFaces(); //get the faces
numEdge=edges.length;
//
for (i=0;i0)&&(rand.nextDouble()