Point3 Splat::EvalNormalPerturb(ShadeContext& sc) { float del, d, f; Point3 p, dp, np; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); d = splatter(p); del = 0.1f; // float strength = (abs((int)col[1].r-(int)col[0].r)+ // abs((int)col[1].g-(int)col[0].g)+ // abs((int)col[1].b-(int)col[0].b)); ///100.0f; // 756.0f // f = strength/del; f = 1.0f/del; Point3 M[3]; xyzGen->GetBumpDP(sc,M); np.x = f*(splatter(p+del*M[0]) - d); np.y = f*(splatter(p+del*M[1]) - d); np.z = f*(splatter(p+del*M[2]) - d); np = sc.VectorFromNoScale(np,REF_OBJECT); Texmap *sub0 = mapOn[0]?subTex[0]:NULL; Texmap *sub1 = mapOn[1]?subTex[1]:NULL; if (sub0||sub1) { // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da float a,b; Point3 da,db; if (sub0) { a = sub0->EvalMono(sc); da = sub0->EvalNormalPerturb(sc); } else { a = Intens(col[0]); da = Point3(0.0f,0.0f,0.0f); } if (sub1) { b = sub1->EvalMono(sc); db = sub1->EvalNormalPerturb(sc); } else { b = Intens(col[1]); db= Point3(0.0f,0.0f,0.0f); } np = (b-a)*np + d*(db-da) + da; } else np *= Intens(col[1])-Intens(col[0]); return np; }
Point3 Water::EvalNormalPerturb(ShadeContext& sc) { if (gbufID) sc.SetGBufferID(gbufID); Point3 p, dp, np; xyzGen->GetXYZ(sc, p, dp); VectorWave(p, np); Point3 M[3]; xyzGen->GetBumpDP(sc,M); np = Point3( DotProd(np,M[0]),DotProd(np,M[1]),DotProd(np,M[2])); return sc.VectorFromNoScale(np,REF_OBJECT); }
Point3 Speckle::EvalNormalPerturb(ShadeContext& sc) { float del, d; Point3 p, dp; Point3 np; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 0.0001f; p *= SCALE_FACTOR/size; del = 0.1f; d = SpeckleFunc(p); Point3 M[3]; xyzGen->GetBumpDP(sc,M); np.x = (SpeckleFunc(p+del*M[0]) - d)/del; np.y = (SpeckleFunc(p+del*M[1]) - d)/del; np.z = (SpeckleFunc(p+del*M[2]) - d)/del; np = sc.VectorFromNoScale(np,REF_OBJECT); Texmap *sub0 = mapOn[0]?subTex[0]:NULL; Texmap *sub1 = mapOn[1]?subTex[1]:NULL; if (sub0||sub1) { // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da float a,b; Point3 da,db; if (sub0) { a = sub0->EvalMono(sc); da = sub0->EvalNormalPerturb(sc); } else { a = Intens(col[0]); da = Point3(0.0f,0.0f,0.0f); } if (sub1) { b = sub1->EvalMono(sc); db = sub1->EvalNormalPerturb(sc); } else { b = Intens(col[1]); db= Point3(0.0f,0.0f,0.0f); } np = (b-a)*np + d*(db-da) + da; } else np *= Intens(col[1])-Intens(col[0]); return np; }
Point3 Stucco::EvalNormalPerturb(ShadeContext& sc) { float d,k; Point3 p, dp, np; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); float scl = compscl(dp, size); p /= size; d = Func(p, scl); k = 0.25f/del; Point3 M[3]; xyzGen->GetBumpDP(sc,M); np.x = (Func(p + del*M[0], scl) - d)*k; np.y = (Func(p + del*M[1], scl) - d)*k; np.z = (Func(p + del*M[2], scl) - d)*k; np = sc.VectorFromNoScale(np,REF_OBJECT); Texmap *sub0 = mapOn[0]?subTex[0]:NULL; Texmap *sub1 = mapOn[1]?subTex[1]:NULL; if (sub0||sub1) { // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da float a,b; Point3 da,db; if (sub0) { a = sub0->EvalMono(sc); da = sub0->EvalNormalPerturb(sc); } else { a = Intens(col[0]); da = Point3(0.0f,0.0f,0.0f); } if (sub1) { b = sub1->EvalMono(sc); db = sub1->EvalNormalPerturb(sc); } else { b = Intens(col[1]); db= Point3(0.0f,0.0f,0.0f); } np = (b-a)*np + d*(db-da) + da; } else np *= Intens(col[1])-Intens(col[0]); return np; }
// --- Methods inherited from Texmap --- RGBA Stucco::EvalColor(ShadeContext& sc) { float f; Point3 p, dp; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 0.0001f; p /= size; float scl = compscl(dp, size); f = Func(p, scl); // If we have sub-texmaps and they are enabled, get the colors from // the sub-texmaps, otherwise get them from the color swatch RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0]; RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1]; Col24 c; Col24 col1 = Col24FromColor(c0); Col24 col2 = Col24FromColor(c1); lerp_color(&c, &col1, &col2, f); return ColorFromCol24(c); }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Stucco::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); // pblock->GetValue(PB_COL1, t, col[0], texValidity); pblock->GetValue(stucco_color1, t, col[0], texValidity); col[0].ClampMinMax(); // pblock->GetValue(PB_COL2, t, col[1], texValidity); pblock->GetValue(stucco_color2, t, col[1], texValidity); col[1].ClampMinMax(); // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(stucco_size, t, size, texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); // pblock->GetValue(PB_THRESH, t, thresh, texValidity); pblock->GetValue(stucco_threshold, t, thresh, texValidity); ClampFloat(thresh, MIN_THRESH, MAX_THRESH); // pblock->GetValue(PB_THICK, t, thick, texValidity); pblock->GetValue(stucco_thickness, t, thick, texValidity); pblock->GetValue(stucco_mapon1, t, mapOn[0], texValidity); pblock->GetValue(stucco_mapon2, t, mapOn[1], texValidity); ClampFloat(thick, MIN_THICK, MAX_THICK); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { if (subTex[i]) subTex[i]->Update(t, texValidity); } } ivalid &= texValidity; }
void CellTex::Init() { if (xyzGen) xyzGen->Reset(); else ReplaceReference(1, GetNewDefaultXYZGen()); if (texout) texout->Reset(); else ReplaceReference(2, GetNewDefaultTextureOutput()); RegisterDistanceDefault(_T("Cellular Params"), _T("Size"), 5.0f, IN_TO_M(5.0f)); float size = GetDistanceDefault(_T("Cellular Params"), _T("Size")); pblock->SetValue(cellular_size,0,size); /* pblock->SetValue(PB_CELLCOL,0,Point3(1,1,1)); pblock->SetValue(PB_DIVCOL1,0,Point3(.5f,.5f,.5f)); pblock->SetValue(PB_DIVCOL2,0,Point3(0,0,0)); pblock->SetValue(PB_SIZE,0,5.0f); pblock->SetValue(PB_SPREAD,0,0.5f); pblock->SetValue(PB_LOW,0,0.0f); pblock->SetValue(PB_MID,0,0.5f); pblock->SetValue(PB_HIGH,0,1.0f); pblock->SetValue(PB_FRACT,0,0); pblock->SetValue(PB_ITER,0,3.0f); pblock->SetValue(PB_USECELLMAP,0,1); pblock->SetValue(PB_USEDIV1MAP,0,1); pblock->SetValue(PB_USEDIV2MAP,0,1); pblock->SetValue(PB_SMOOTH,0,0.1f); pblock->SetValue(PB_ADAPT,0,1); if (paramDlg) paramDlg->pmap->SetParamBlock(pblock); */ fract = 0; ivalid.SetEmpty(); }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Speckle::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); // pblock->GetValue(PB_COL1, t, col[0], texValidity); pblock->GetValue(speckle_color1, t, col[0], texValidity); col[0].ClampMinMax(); // pblock->GetValue(PB_COL2, t, col[1], texValidity); pblock->GetValue(speckle_color2, t, col[1], texValidity); col[1].ClampMinMax(); // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(speckle_size, t, size, texValidity); pblock->GetValue(speckle_mapon1, t, mapOn[0], texValidity); pblock->GetValue(speckle_mapon2, t, mapOn[1], texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_DISPLAY_MATERIAL_CHANGE); } if (!mapValid.InInterval(t)) { mapValid.SetInfinite(); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { if (subTex[i]) subTex[i]->Update(t, mapValid); } } ivalid &= texValidity; ivalid &= mapValid; }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Splat::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); // pblock->GetValue(PB_COL1, t, col[0], texValidity); pblock->GetValue(splat_color1, t, col[0], texValidity); col[0].ClampMinMax(); // pblock->GetValue(PB_COL2, t, col[1], texValidity); pblock->GetValue(splat_color2, t, col[1], texValidity); col[1].ClampMinMax(); // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(splat_size, t, size, texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); // pblock->GetValue(PB_THRESH, t, thresh, texValidity); pblock->GetValue(splat_threshold, t, thresh, texValidity); ClampFloat(thresh, MIN_THRESH, MAX_THRESH); // pblock->GetValue(PB_ITER, t, iter, texValidity); pblock->GetValue(splat_iteration, t, iter, texValidity); pblock->GetValue(splat_mapon1, t, mapOn[0], texValidity); pblock->GetValue(splat_mapon2, t, mapOn[1], texValidity); ClampInt(iter, (int) MIN_ITER, (int) MAX_ITER); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { if (subTex[i]) subTex[i]->Update(t, texValidity); } } ivalid &= texValidity; }
// --- Methods inherited from Texmap --- RGBA Water::EvalColor(ShadeContext& sc) { float d; float q[3]; Point3 p, dp; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); q[0] = p.x; q[1] = p.y; q[2] = p.z; d = ScalarWave(q); if (d>1.0f) d = 1.0f; // If we have sub-texmaps and they are enabled, get the colors from // the sub-texmaps, otherwise get them from the color swatch RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0]; RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1]; Col24 c; Col24 col1 = Col24FromColor(c0); Col24 col2 = Col24FromColor(c1); lerp_color(&c, &col1, &col2, d); return ColorFromCol24(c); }
// --- Methods inherited from Texmap --- RGBA Speckle::EvalColor(ShadeContext& sc) { // After being evaluated, if a map or material has a non-zero gbufID, // it should call ShadeContext::SetGBuffer() to store it into // the shade context. if (gbufID) sc.SetGBufferID(gbufID); // Use the XYZGen instance to get a transformed point from the // ShadeContext. Point3 p, dp; xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 0.0001f; p *= SCALE_FACTOR/size; float d = SpeckleFunc(p); if (d>1.0f) d = 1.0f; // If we have sub-texmaps and they are enabled, get the colors from // the sub-texmaps, otherwise get them from the color swatch RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0]; RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1]; // Composite the colors together and return the result. return (1.0f-d)*c0 + d*c1; }
// --- Methods inherited from Texmap --- RGBA Smoke::EvalColor(ShadeContext& sc) { float d; Point3 p, dp; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 1.0f; d = SmokeFunc(p/size, iter); // If we have sub-texmaps and they are enabled, get the colors from // the sub-texmaps, otherwise get them from the color swatch RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0]; RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1]; Col24 c; Col24 col1 = Col24FromColor(c0); Col24 col2 = Col24FromColor(c1); lerp_color(&c, &col1, &col2, d); return ColorFromCol24(c); }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Planet::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); for (int i = 0; i < NUM_COLORS; i++) { // pblock->GetValue(i+PB_COL1, t, col[i], texValidity); pblock->GetValue(i+planet_color1, t, col[i], texValidity); col[i].ClampMinMax(); } // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(planet_size, t, size, texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); // pblock->GetValue(PB_ISLAND, t, island, texValidity); pblock->GetValue(planet_island, t, island, texValidity); ClampFloat(island, MIN_ISLAND, MAX_ISLAND); // pblock->GetValue(PB_PERCENT, t, percent, texValidity); pblock->GetValue(planet_percent, t, percent, texValidity); ClampFloat(percent, MIN_PERCENT, MAX_PERCENT); land = percent/100.0f; // pblock->GetValue(PB_SEED, t, seed, texValidity); pblock->GetValue(planet_seed, t, seed, texValidity); ClampInt(seed, (int) MIN_SEED, (int) MAX_SEED); pblock->GetValue(planet_blend, t, blend, texValidity); } ivalid &= texValidity; }
RGBA Noise::EvalColor(ShadeContext& sc) { Point3 p,dp; if (!sc.doMaps) return black; AColor c; if (sc.GetCache(this,c)) return c; if (gbufID) sc.SetGBufferID(gbufID); //IPoint2 ps = sc.ScreenCoord(); UpdateCache(sc.CurTime()); // DS 10/3/00 xyzGen->GetXYZ(sc,p,dp); p /= size; filter = sc.filterMaps; float smw; float limlev = LimitLevel(dp,smw); float d = NoiseFunction(p,limlev,smw); RGBA c0 = mapOn[0]&&subTex[0] ? subTex[0]->EvalColor(sc): col[0]; RGBA c1 = mapOn[1]&&subTex[1] ? subTex[1]->EvalColor(sc): col[1]; c = texout->Filter((1.0f-d)*c0 + d*c1); sc.PutCache(this,c); return c; }
// This method is called to reset the texmap back to its default values. void Planet::Init() { // Reset the XYZGen or allocate a new one if (xyzGen) xyzGen->Reset(); else ReplaceReference(0, GetNewDefaultXYZGen()); // ReplaceReference(1, CreateParameterBlock(pbdesc, // PB_LENGTH, PLANET_PB_VERSION)); // if (paramDlg) // paramDlg->pmap->SetParamBlock(pblock); // Set the inital parameters // {10,20,80},{10,30,80},{10,40,90},{10,100,12}, // {100,80,12},{80,20,8},{100,80,50},{100,100,100} SetColor(0, Color(0.04f, 0.08f, 0.31f), TimeValue(0)); SetColor(1, Color(0.04f, 0.12f, 0.31f), TimeValue(0)); SetColor(2, Color(0.04f, 0.16f, 0.31f), TimeValue(0)); SetColor(3, Color(0.04f, 0.39f, 0.05f), TimeValue(0)); SetColor(4, Color(0.39f, 0.31f, 0.05f), TimeValue(0)); SetColor(5, Color(0.31f, 0.08f, 0.03f), TimeValue(0)); SetColor(6, Color(0.39f, 0.31f, 0.20f), TimeValue(0)); SetColor(7, Color(0.39f, 0.39f, 0.39f), TimeValue(0)); SetSize(40.0f, TimeValue(0)); SetIsland(0.5f, TimeValue(0)); SetPercent(60.0f, TimeValue(0)); SetSeed(12345, TimeValue(0)); blend = 1; // Set the validity interval of the texture to empty texValidity.SetEmpty(); }
void Noise::Init() { if (xyzGen) xyzGen->Reset(); else ReplaceReference( XYZGEN_REF, GetNewDefaultXYZGen()); if (texout) texout->Reset(); else ReplaceReference( TEXOUT_REF, GetNewDefaultTextureOutput()); ivalid.SetEmpty(); cacheValid.SetEmpty(); macroRecorder->Disable(); // disable macrorecorder during reset SetColor(0, Color(0.0f,0.0f,0.0f), TimeValue(0)); SetColor(1, Color(1.0f,1.0f,1.0f), TimeValue(0)); noiseType = NOISE_REGULAR; #ifndef RENDER_VER RegisterDistanceDefault(_T("Noise Params"), _T("Size"), DEFAULT_NOISE_SIZE, IN_TO_M(DEFAULT_NOISE_SIZE)); float size = GetDistanceDefault(_T("Noise Params"), _T("Size")); SetSize(size, TimeValue(0)); #else SetSize(DEFAULT_NOISE_SIZE, TimeValue(0)); #endif SetPhase(.0f,TimeValue(0)); SetLevels(3.0f,TimeValue(0)); pblock->SetValue(noise_hithresh,0,1.0f); macroRecorder->Enable(); for (int i=0; i<NSUBTEX; i++) mapOn[i] = 1; }
float Stucco::EvalFunc(ShadeContext &sc) { Point3 p, dp; xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 0.0001f; p /= size; float scl = compscl(dp, size); return Func(p, scl); }
Point3 Planet::EvalNormalPerturb(ShadeContext& sc) { float del,d; Point3 p,dp; if (!sc.doMaps) return Point3(0,0,0); if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc,p,dp); if (size == 0.0f) size = 0.0001f; p /= size; del = 10.0f; d = BumpFunc(p); Point3 np; Point3 M[3]; xyzGen->GetBumpDP(sc,M); np.x = (BumpFunc(p+del*M[0]) - d)/del; np.y = (BumpFunc(p+del*M[1]) - d)/del; np.z = (BumpFunc(p+del*M[2]) - d)/del; return sc.VectorFromNoScale(np*100.0f,REF_OBJECT); }
// --- Methods inherited from Texmap --- RGBA Planet::EvalColor(ShadeContext& sc) { float d, x, y, z; RGBA color; // After being evaluated, if a map or material has a non-zero gbufID, // it should call ShadeContext::SetGBuffer() to store it into // the shade context. if (gbufID) sc.SetGBufferID(gbufID); // Use the XYZGen instance to get a transformed point from the // ShadeContext. Point3 p, dp; xyzGen->GetXYZ(sc, p, dp); if (size == 0.0f) size = 0.0001f; x = p.x/size; y = p.y/size; z = p.z/size; d = NoiseFunc(x, y, z); if (d < land) { float frac; int index; d = d/land*3.0f; index = (int)d; frac = d-(float)index; if (index < 2) color = (1.0f-frac)*col[index]+frac*col[index+1]; else { if (blend) color = (1.0f-frac)*col[2]+frac*col[3]; else color = col[2]; } } else { float divfac, frac; int index; divfac = 1.0f-land; if (divfac==0.0) divfac = .000001f; d = (d-land)/divfac*5; index = (int)d; frac = d-(float)index; if (index < 4) color = (1.0f-frac)*col[index+3]+frac*col[index+4]; else color = col[7]; } return color; }
Point3 Noise::EvalNormalPerturb(ShadeContext& sc) { Point3 p,dp; if (!sc.doMaps) return Point3(0,0,0); if (gbufID) sc.SetGBufferID(gbufID); UpdateCache(sc.CurTime()); // DS 10/3/00 xyzGen->GetXYZ(sc,p,dp); p /= size; filter = sc.filterMaps; float smw; float limlev = LimitLevel(dp,smw); float del,d; d = NoiseFunction(p,limlev,smw); //del = (dp.x+dp.y+dp.z)/(size*3.0f); del = .1f; Point3 np; Point3 M[3]; xyzGen->GetBumpDP(sc,M); np.x = (NoiseFunction(p+del*M[0],limlev,smw) - d)/del; np.y = (NoiseFunction(p+del*M[1],limlev,smw) - d)/del; np.z = (NoiseFunction(p+del*M[2],limlev,smw) - d)/del; np = sc.VectorFromNoScale(np, REF_OBJECT); Texmap *sub0 = mapOn[0]?subTex[0]:NULL; Texmap *sub1 = mapOn[1]?subTex[1]:NULL; if (sub0||sub1) { // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da float a,b; Point3 da,db; if (sub0) { a = sub0->EvalMono(sc); da = sub0->EvalNormalPerturb(sc); } else { a = Intens(col[0]); da = Point3(0.0f,0.0f,0.0f); } if (sub1) { b = sub1->EvalMono(sc); db = sub1->EvalNormalPerturb(sc); } else { b = Intens(col[1]); db= Point3(0.0f,0.0f,0.0f); } np = (b-a)*np + d*(db-da) + da; } else np *= Intens(col[1])-Intens(col[0]); return texout->Filter(np); }
AColor CellTex::EvalColor(ShadeContext& sc) { // Get object point Point3 p,dp; if (gbufID) sc.SetGBufferID(gbufID); xyzGen->GetXYZ(sc,p,dp); p += ptOffset; p = p/size; // Eval maps Color cellC, div1C, div2C; if (useCellMap && subTex[0]) cellC = subTex[0]->EvalColor(sc); else cellC = cellCol; if (useDiv1Map && subTex[1]) div1C = subTex[1]->EvalColor(sc); else div1C = divCol1; if (useDiv2Map && subTex[2]) div2C = subTex[2]->EvalColor(sc); else div2C = divCol2; // Evaluate cell function float dist[2]; int ids[2]; float u; if (type) { if (fract) FractalCellFunction(p,iterations,rough,2,dist,ids); else CellFunction(p,2,dist,ids); u = 1.0f - (dist[1]-dist[0])/spread; } else { if (fract) FractalCellFunction(p,iterations,rough,1,dist,ids); else CellFunction(p,1,dist,ids); u = dist[0]/spread; } // Vari cell color if (var>0.0f) { float vr = RandFromCellID(ids[0])*var + varOff; cellC.r = cellC.r*vr; cellC.g = cellC.g*vr; cellC.b = cellC.b*vr; cellC.ClampMinMax(); } if (u<low) return texout->Filter(RGBA(cellC)); if (u>high) return texout->Filter(RGBA(div2C)); if (u<mid) { u = (u-low)/(midMinuslow); return texout->Filter(RGBA(div1C*u + (1.0f-u)*cellC)); } else { u = (u-mid)/(highMinusmid); return texout->Filter(RGBA(div2C*u + (1.0f-u)*div1C)); } }
// This method is called to reset the texmap back to its default values. void Speckle::Init() { // Reset the XYZGen or allocate a new one if (xyzGen) xyzGen->Reset(); else ReplaceReference(0, GetNewDefaultXYZGen()); // Set the inital colors and size SetColor(0, DEFAULT_COLOR1, TimeValue(0)); SetColor(1, DEFAULT_COLOR2, TimeValue(0)); SetSize(DEFAULT_SPECKLE_SIZE, TimeValue(0)); // Set the validity interval of the texture to empty texValidity.SetEmpty(); }
ParamDlg* CellTex::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { // paramDlg = new CellTexParamDlg(this,imp,hwMtlEdit); // return paramDlg; // create the rollout dialogs xyzGenDlg = xyzGen->CreateParamDlg(hwMtlEdit, imp); IAutoMParamDlg* masterDlg = cellTexCD.CreateParamDlgs(hwMtlEdit, imp, this); texoutDlg = texout->CreateParamDlg(hwMtlEdit, imp); // add the secondary dialogs to the master masterDlg->AddDlg(xyzGenDlg); masterDlg->AddDlg(texoutDlg); // celTex_param_blk.SetUserDlgProc(new NoiseDlgProc(this)); return masterDlg; }
// This method is called to reset the texmap back to its default values. void Speckle::Init() { // Reset the XYZGen or allocate a new one if (xyzGen) xyzGen->Reset(); else ReplaceReference(0, GetNewDefaultXYZGen()); // Set the inital colors and size SetColor(0, DEFAULT_COLOR1, TimeValue(0)); SetColor(1, DEFAULT_COLOR2, TimeValue(0)); RegisterDistanceDefault(_T("Speckle Params"), _T("Size"), DEFAULT_SPECKLE_SIZE, IN_TO_M(DEFAULT_SPECKLE_SIZE)); float size = GetDistanceDefault(_T("Speckle Params"), _T("Size")); SetSize(size, TimeValue(0)); // Set the validity interval of the texture to empty texValidity.SetEmpty(); }
// This method gets called when the material or texture is to be displayed // in the material editor parameters area. ParamDlg* Planet::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { // Allocate a new instance of ParamDlg to manage the UI. This will // create the rollup page in the materials editor. // PlanetDlg *planetDlg = new PlanetDlg(hwMtlEdit, imp, this); // Update the dialog display with the proper values of the texture. // planetDlg->LoadDialog(); // paramDlg = planetDlg; // return planetDlg; // create the rollout dialogs xyzGenDlg = xyzGen->CreateParamDlg(hwMtlEdit, imp); IAutoMParamDlg* masterDlg = planetCD.CreateParamDlgs(hwMtlEdit, imp, this); // add the secondary dialogs to the master masterDlg->AddDlg(xyzGenDlg); return masterDlg; }
// This method is called to reset the texmap back to its default values. void Stucco::Init() { // Reset the XYZGen or allocate a new one if (xyzGen) xyzGen->Reset(); else ReplaceReference(0, GetNewDefaultXYZGen()); // Set the inital parameters SetColor(0, Color(0.0f, 0.0f, 0.0f), TimeValue(0)); SetColor(1, Color(0.9f, 0.9f, 0.9f), TimeValue(0)); SetSize(20.0f, TimeValue(0)); SetThresh(0.57f, TimeValue(0)); SetThick(0.15f, TimeValue(0)); // Set the validity interval of the texture to empty texValidity.SetEmpty(); }
// This method gets called when the material or texture is to be displayed // in the material editor parameters area. ParamDlg* Speckle::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { // Allocate a new instance of ParamDlg to manage the UI. This will // create the rollup page in the materials editor. // SpeckleDlg *speckleDlg = new SpeckleDlg(hwMtlEdit, imp, this); // Update the dialog display with the proper values of the texture. // speckleDlg->LoadDialog(); // paramDlg = speckleDlg; // return speckleDlg; xyzGenDlg = xyzGen->CreateParamDlg(hwMtlEdit, imp); IAutoMParamDlg* masterDlg = speckleCD.CreateParamDlgs(hwMtlEdit, imp, this); // add the secondary dialogs to the master masterDlg->AddDlg(xyzGenDlg); speckle_param_blk.SetUserDlgProc(new SpeckleDlgProc(this)); return masterDlg; }
// This method is called to reset the texmap back to its default values. void Water::Init() { // Reset the XYZGen or allocate a new one if (xyzGen) xyzGen->Reset(); else ReplaceReference(0, GetNewDefaultXYZGen()); // This replaces the reference to the previous parameter block with // a new one. Note that the previous one is automatically deleted // because when the last reference to an item is deleted, MAX deletes // the item itself. // ReplaceReference(1, CreateParameterBlock(pbdesc, // PB_LENGTH, WATER_PB_VERSION)); // if (paramDlg) // paramDlg->pmap->SetParamBlock(pblock); // Set the inital parameters SetColor(0, DEFAULT_COLOR1, TimeValue(0)); SetColor(1, DEFAULT_COLOR2, TimeValue(0)); SetRandSeed(0x75cf); SetNum(DEFAULT_NUM_WAVESETS, TimeValue(0)); RegisterDistanceDefault(_T("Wave Params"), _T("Size"), DEFAULT_WAVE_RADIUS, IN_TO_M(DEFAULT_WAVE_RADIUS)); float size = GetDistanceDefault(_T("Wave Params"), _T("Size")); SetSize(size, TimeValue(0)); RegisterDistanceDefault(_T("Wave Params"), _T("Len Min"), DEFAULT_WAVE_LEN_MIN, IN_TO_M(DEFAULT_WAVE_LEN_MIN)); float lenMin = GetDistanceDefault(_T("Wave Params"), _T("Len Min")); SetLenMin(lenMin, TimeValue(0)); RegisterDistanceDefault(_T("Wave Params"), _T("Len Max"), DEFAULT_WAVE_LEN_MAX, IN_TO_M(DEFAULT_WAVE_LEN_MAX)); float lenMax = GetDistanceDefault(_T("Wave Params"), _T("Len Max")); SetLenMax(lenMax, TimeValue(0)); SetAmp(1.0f, TimeValue(0)); SetPhase(0.0f, TimeValue(0)); ReInit(); type = 0; // Set the validity interval of the texture to empty texValidity.SetEmpty(); }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Water::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); // pblock->GetValue(PB_COL1, t, col[0], texValidity); pblock->GetValue(water_color1, t, col[0], texValidity); col[0].ClampMinMax(); // pblock->GetValue(PB_COL2, t, col[1], texValidity); pblock->GetValue(water_color2, t, col[1], texValidity); col[1].ClampMinMax(); // pblock->GetValue(PB_NUM, t, count, texValidity); pblock->GetValue(water_num, t, count, texValidity); ClampInt(count, (int) MIN_NUM, (int) MAX_NUM); // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(water_size, t, size, texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); // pblock->GetValue(PB_LEN_MIN, t, minperiod, texValidity); pblock->GetValue(water_len_min, t, minperiod, texValidity); ClampFloat(minperiod, MIN_LEN_MIN, MAX_LEN_MIN); // > 6/11/02 - 2:42pm --MQM-- typo, was MIN_LEN_MIN, MAX_LEN_MAX // pblock->GetValue(PB_LEN_MAX, t, maxperiod, texValidity); pblock->GetValue(water_len_max, t, maxperiod, texValidity); ClampFloat(maxperiod, MIN_LEN_MAX, MAX_LEN_MAX); // pblock->GetValue(PB_AMP, t, amp, texValidity); pblock->GetValue(water_amp, t, amp, texValidity); ClampFloat(amp, MIN_AMP, MAX_AMP); // pblock->GetValue(PB_PHASE, t, phase, texValidity); // pblock->GetValue(PB_TYPE, t, type, texValidity); pblock->GetValue(water_phase, t, phase, texValidity); pblock->GetValue(water_type, t, type, texValidity); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { if (subTex[i]) subTex[i]->Update(t, texValidity); // pblock->GetValue(PB_SEED, t, randSeed, texValidity); pblock->GetValue(water_seed, t, randSeed, texValidity); pblock->GetValue(water_mapon1, t, mapOn[0], texValidity); pblock->GetValue(water_mapon2, t, mapOn[1], texValidity); ReInit(); } } ivalid &= texValidity; }
ParamDlg* Noise::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { // JBW: the main difference here is the automatic creation of a ParamDlg by the new // ClassDesc2 function CreateParamDlgs(). This mirrors the way BeginEditParams() // can be redirected to the ClassDesc2 for automatic ParamMap2 management. In this // case a special subclass of ParamDlg, AutoMParamDlg, defined in IParamm2.h, is // created. It can act as a 'master' ParamDlg to which you can add any number of // secondary dialogs and it will make sure all the secondary dialogs are kept // up-to-date and deleted as necessary. // create the rollout dialogs xyzGenDlg = xyzGen->CreateParamDlg(hwMtlEdit, imp); IAutoMParamDlg* masterDlg = noiseCD.CreateParamDlgs(hwMtlEdit, imp, this); texoutDlg = texout->CreateParamDlg(hwMtlEdit, imp); // add the secondary dialogs to the master masterDlg->AddDlg(xyzGenDlg); masterDlg->AddDlg(texoutDlg); noise_param_blk.SetUserDlgProc(new NoiseDlgProc(this)); EnableStuff(); return masterDlg; }