Exemplo n.º 1
0
void Mask::Update(TimeValue t, Interval& valid) {		

	if (Param1)
		{
		pblock->SetValue( mask_map1_on, 0, mapOn[0]);
		pblock->SetValue( mask_map2_on, 0, mapOn[1]);
		pblock->SetValue( mask_invert, 0, invertMask);
		Param1 = FALSE;
		}

	if (!ivalid.InInterval(t)) {

		ivalid.SetInfinite();

		pblock->GetValue( mask_map1_on, t, mapOn[0], ivalid);
		pblock->GetValue( mask_map2_on, t, mapOn[1], ivalid);
		pblock->GetValue( mask_invert, t, invertMask, ivalid);
		NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_DISPLAY_MATERIAL_CHANGE);
		}
	if (!mapValid.InInterval(t))
	{
		mapValid.SetInfinite();
		for (int i=0; i<NSUBTEX; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t,mapValid);
		}
	}
	valid &= mapValid;
	valid &= ivalid;
	}
Exemplo n.º 2
0
// 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;
}
Exemplo n.º 3
0
void Noise::UpdateCache(TimeValue t)
	{
        //Intel's fix is to check the validity before entering the critical section, if it's valid, no need to update
	if (cacheValid.InInterval(t))
		return;

	EnterCriticalSection(&csect);
	if (!cacheValid.InInterval(t)) {
		ComputeAvgValue();
		cacheValid = ivalid;
		}
	LeaveCriticalSection(&csect);
	}
Exemplo n.º 4
0
Point3 PBombField::Force(TimeValue t,const Point3 &pos, const Point3 &vel,int index)
{	float d,chaos,dv;
	Point3 dlta,xb,yb,zb,center,expv;
	int decaytype,symm;
	Point3 zero=Zero;
		fValid = FOREVER;		
		if (!tmValid.InInterval(t)) 
		{	tmValid = FOREVER;
			tm = node->GetObjectTM(t,&tmValid);
			invtm = Inverse(tm);
		}
		xb=tm.GetRow(0);
		yb=tm.GetRow(1);
		zb=tm.GetRow(2);
		center=tm.GetTrans();
		fValid &= tmValid;
		TimeValue t0,t2,lastsfor;
		obj->pblock->GetValue(PB_STARTTIME,t,t0,fValid);
		obj->pblock->GetValue(PB_LASTSFOR,t,lastsfor,fValid);
		t2=t0+lastsfor;
		dlta=Zero;
		if ((t>=t0)&&(t<=t2))
		{ float L=Length(dlta=pos-center);
		  obj->pblock->GetValue(PB_DECAY,t,d,fValid);
		  obj->pblock->GetValue(PB_DECAYTYPE,t,decaytype,fValid);
		  if ((decaytype==0)||(L<=d))
		  { obj->pblock->GetValue(PB_DELTA_V,t,dv,fValid);
		    obj->pblock->GetValue(PB_CHAOS,t,chaos,fValid);
		    obj->pblock->GetValue(PB_SYMMETRY,t,symm,fValid);
		    Point3 r;
		    if (symm==SPHERE)
		      expv=(r=dlta/L);
	        else if (symm==PLANAR)
		    { L=DotProd(dlta,zb);
			  expv=(L<0.0f?L=-L,-zb:zb);
		    }
		    else
		    { Point3 E;
		      E=DotProd(dlta,xb)*xb+DotProd(dlta,yb)*yb;
		      L=Length(E);
		      expv=E/L;
		    }
		    dlta=(dv*expv)/(float)dtsq;
			if (decaytype==1)
			 dlta*=(d-L)/d;
			else if (decaytype==2)
			 dlta*=(1/(float)exp(L/d));
			if ((!FloatEQ0(chaos))&&(lastsfor==0.0f))
			{ float theta;
			  theta=HalfPI*chaos*RND01();
			  // Martell 4/14/01: Fix for order of ops bug.
			  float ztmp=RND11(); float ytmp=RND11(); float xtmp=RND11();
			  Point3 d=Point3(xtmp,ytmp,ztmp);
			  Point3 c=Normalize(dlta^d);
			  RotateOnePoint(&dlta.x,&zero.x,&c.x,theta);
			}
		  }	else dlta=Zero; 
		}
	return dlta;
	}
Exemplo n.º 5
0
// 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;
}
Exemplo n.º 6
0
// 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;
}
Exemplo n.º 7
0
// 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;
}
Exemplo n.º 8
0
void OrenNayarBlinnShader::Update(TimeValue t, Interval &valid) {
	Point3 p, p2;
	if( inUpdate )
		return;
	inUpdate = TRUE;
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();

//		pblock->GetValue( onb_ambient, t, p, ivalid );
//		ambient = LimitColor(Color(p.x,p.y,p.z));
		pblock->GetValue( onb_diffuse, t, p, ivalid );
		diffuse= LimitColor(Color(p.x,p.y,p.z));
		pblock->GetValue( onb_ambient, t, p2, ivalid );
		if( lockAD && (p!=p2)){
			pblock->SetValue( onb_ambient, t, diffuse);
			ambient = diffuse;
		} else {
			pblock->GetValue( onb_ambient, t, p, ivalid );
			ambient = Bound(Color(p.x,p.y,p.z));
		}
		pblock->GetValue( onb_specular, t, p2, ivalid );
		if( lockDS && (p!=p2)){
			pblock->SetValue( onb_specular, t, diffuse);
			specular = diffuse;
		} else {
			pblock->GetValue( onb_specular, t, p, ivalid );
			specular = Bound(Color(p.x,p.y,p.z));
		}
//		pblock->GetValue( onb_specular, t, p, ivalid );
//		specular = LimitColor(Color(p.x,p.y,p.z));

		pblock->GetValue( onb_glossiness, t, glossiness, ivalid );
		LIMIT0_1(glossiness);
		pblock->GetValue( onb_specular_level, t, specularLevel, ivalid );
		LIMITMINMAX(specularLevel,0.0f,9.99f);
		pblock->GetValue( onb_soften, t, softThresh, ivalid); 
		LIMIT0_1(softThresh);

		pblock->GetValue( onb_self_illum_amnt, t, selfIllum, ivalid );
		LIMIT0_1(selfIllum);
		pblock->GetValue( onb_self_illum_color, t, p, ivalid );
		selfIllumClr = LimitColor(Color(p.x,p.y,p.z));

		pblock->GetValue( onb_diffuse_level, t, diffLevel, ivalid );
		LIMITMINMAX(diffLevel,0.0f, 4.00f);
		pblock->GetValue( onb_roughness, t, diffRough, ivalid );
		LIMIT0_1(diffRough);

		// also get the non-animatables in case changed from scripter or other pblock accessors
		pblock->GetValue(onb_ds_lock, t, lockDS, ivalid);
		pblock->GetValue(onb_ad_lock, t, lockAD, ivalid);
		pblock->GetValue(onb_ad_texlock, t, lockADTex, ivalid);
		pblock->GetValue(onb_use_self_illum_color, t, selfIllumClrOn, ivalid);

		curTime = t;
	}
	valid &= ivalid;
	inUpdate = FALSE;
}
void OrientConstRotation::GetValue(TimeValue t, void *val, Interval &valid, GetSetMethod method)
{
	if (firstTimeFlag) {
		Point3 trans, scaleP;
		Quat quat;
		Matrix3 tempMat(1);
		// CAL-9/26/2002: in absolute mode the value could be un-initialized (random value).
		if (method == CTRL_RELATIVE) tempMat = *(Matrix3*)val;
		DecomposeMatrix(tempMat, trans, quat, scaleP);
		baseRotQuatWorld = baseRotQuatLocal * quat;
		baseRotQuatWorld.Normalize();
		firstTimeFlag = 0;
	}
	if (!ivalid.InInterval(t)) {
		DbgAssert(val != NULL);
		Update(t);
	}
	valid &= ivalid;

			 
	if (method==CTRL_RELATIVE) {
		Interval iv;

		if (IsLocal()){			// From Update, I'm getting target_local_TM in curRot
			Matrix3 *mat = (Matrix3*)val; // this is source_Parent_TM
			Quat q = curRot;			// this is target_local_TM
			PreRotateMatrix(*mat, q);	// source_world_TM = source_Parent_TM * target_local_TM 
		}
		
		else { 		// i.e., WorldToWorld: from Update, I'm getting target_world_TM in curRot
			int ct = pblock->Count(orientation_target_list);;
			if (ct < 1){
				Matrix3 *mat = (Matrix3*)val;
				Quat q = curRot;
				PreRotateMatrix(*mat, q);
			}
			else{
				Matrix3 *mat = (Matrix3*)val; // this is source_Parent_TM
				// CAL-06/24/02: preserve all components and replace with the new orientation.
				AffineParts ap;
				decomp_affine( *mat, &ap );
				ap.q = curRot;				// target world rotation
				comp_affine( ap, *mat );
				// CAL-06/24/02: this only preserve the translation component
				// Point3 tr;
				// tr = mat->GetTrans();
				// mat->IdentityMatrix();
				// Quat q = curRot;			// this is target_world_TM
				// q.MakeMatrix(*mat);
				// mat->SetTrans(tr);
			}
		}
	} 
	else {
		*((Quat*)val) = curRot;
	}
//		RedrawListbox(GetCOREInterface()->GetTime());
}
Exemplo n.º 10
0
DWORD_PTR Speckle::GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) {
	if (texHandle) {
		if (texHandleValid.InInterval(t))
			return texHandle->GetHandle();
		else DiscardTexHandle();
		}
	texHandle = thmaker.MakeHandle(GetVPDisplayDIB(t,thmaker,texHandleValid));
	return texHandle->GetHandle();
	}
Exemplo n.º 11
0
void StraussShader::Update(TimeValue t, Interval &valid) {
   Point3 p;
   if (!ivalid.InInterval(t)) {
      ivalid.SetInfinite();

      pblock->GetValue( st_diffuse, t, p, ivalid );
      diffuse= Bound(Color(p.x,p.y,p.z));
      pblock->GetValue( st_glossiness, t, glossiness, ivalid );
      glossiness = Bound(glossiness );
      pblock->GetValue( st_metalness, t, metalness, ivalid );
      metalness = Bound(metalness );
   }
   valid &= ivalid;
}
Exemplo n.º 12
0
// 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 Smoke::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(smoke_color1, t, col[0], texValidity);
		col[0].ClampMinMax();
//		pblock->GetValue(PB_COL2, t, col[1], texValidity);
		pblock->GetValue(smoke_color2, t, col[1], texValidity);
		col[1].ClampMinMax();
//		pblock->GetValue(PB_SIZE, t, size, texValidity);
		pblock->GetValue(smoke_size, t, size, texValidity);
		ClampFloat(size, MIN_SIZE, MAX_SIZE);
//		pblock->GetValue(PB_EXP, t, power, texValidity);
		pblock->GetValue(smoke_exponent, t, power, texValidity);
		ClampFloat(power, MIN_EXP, MAX_EXP);
//		pblock->GetValue(PB_PHASE, t, phase, texValidity);
//		pblock->GetValue(PB_ITER, t, iter, texValidity);
		pblock->GetValue(smoke_phase, t, phase, texValidity);
		pblock->GetValue(smoke_iteration, t, iter, texValidity);
		ClampInt(iter, (int) MIN_ITER, (int) MAX_ITER);
		pblock->GetValue(smoke_mapon1, t, mapOn[0], texValidity);
		pblock->GetValue(smoke_mapon2, t, mapOn[1], texValidity);

		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;
}
Exemplo n.º 13
0
void Composite::Update(TimeValue t, Interval& valid) 
	{
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();		
		int n = pblock->Count(comptex_ons);
		if (n!=mapOn.Count()) mapOn.SetCount(n);
		for (int i=0; i<subTex.Count(); i++) {
			pblock->GetValue(comptex_ons,0,mapOn[i],valid,i);
	
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}
		}
	valid &= ivalid;
	}
Exemplo n.º 14
0
void WardShader::Update(TimeValue t, Interval &valid) {
	Point3 p, p2;
	if( inUpdate )
		return;
	inUpdate = TRUE;
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();

//		pblock->GetValue( PB_AMBIENT_CLR, t, p, ivalid );
//		ambient = LimitColor(Color(p.x,p.y,p.z));
		pblock->GetValue( PB_DIFFUSE_CLR, t, p, ivalid );
		diffuse= LimitColor(Color(p.x,p.y,p.z));
		pblock->GetValue( PB_AMBIENT_CLR, t, p2, ivalid );
		if( lockAD && (p!=p2)){
			pblock->SetValue( PB_AMBIENT_CLR, t, diffuse);
			ambient = diffuse;
		} else {
			pblock->GetValue( PB_AMBIENT_CLR, t, p, ivalid );
			ambient = Bound(Color(p.x,p.y,p.z));
		}
		pblock->GetValue( PB_SPECULAR_CLR, t, p2, ivalid );
		if( lockDS && (p!=p2)){
			pblock->SetValue( PB_SPECULAR_CLR, t, diffuse);
			specular = diffuse;
		} else {
			pblock->GetValue( PB_SPECULAR_CLR, t, p, ivalid );
			specular = Bound(Color(p.x,p.y,p.z));
		}

//		pblock->GetValue( PB_SPECULAR_CLR, t, p, ivalid );
//		specular = LimitColor(Color(p.x,p.y,p.z));

		pblock->GetValue( PB_GLOSSINESS_X, t, glossinessX, ivalid );
		LIMITMINMAX(glossinessX, 0.0001f, 1.0f );
		pblock->GetValue( PB_GLOSSINESS_Y, t, glossinessY, ivalid );
		LIMITMINMAX(glossinessY, 0.0001f, 1.0f );

		pblock->GetValue( PB_SPECULAR_LEV, t, specLevel, ivalid );
		LIMITMINMAX(specLevel,0.0f,4.00f);
		pblock->GetValue( PB_DIFFUSE_LEV, t, diffLevel, ivalid );
		LIMITMINMAX(diffLevel,0.0f,2.0f);
		curTime = t;
	}
	valid &= ivalid;
	inUpdate = FALSE;
}
Exemplo n.º 15
0
Point3 PinField::Force(TimeValue t,const Point3 &pos, const Point3 &vel,int index) //ok
{	fValid= FOREVER;		
	if (!tmValid.InInterval(t)) 
	{	tmValid=FOREVER;
		tm=node->GetObjectTM(t,&tmValid);
		invtm=Inverse(tm);
	}
	fValid&=tmValid;
	TimeValue t1,t2;
	obj->pblock->GetValue(PB_ONTIME,t,t1,fValid);
	obj->pblock->GetValue(PB_OFFTIME,t,t2,fValid);
	Point3 OutPin;
	if ((t>=t1)&&(t<=t2))
		OutPin = Zero;
	else 
		OutPin = Zero;
	return OutPin*6.25e-03f;
}
Exemplo n.º 16
0
void Plate::Update(TimeValue t, Interval& valid) {		
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();
		pblock->GetValue( plate_blur, t, blur, ivalid );
		pblock->GetValue( plate_reframt, t, refrAmt, ivalid);
		pblock->GetValue( plate_thick, t, thick, ivalid);


		pblock->GetValue( plate_apply, t, applyBlur, ivalid );

		pblock->GetValue( plate_nthframe, t, nth, ivalid);
		pblock->GetValue( plate_useenviroment, t, useEnvMap, ivalid);
		pblock->GetValue( plate_frame, t, do_nth, ivalid);


		}
	valid &= ivalid;
	}
Exemplo n.º 17
0
// 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;
}
Exemplo n.º 18
0
void Gradient::Update(TimeValue t, Interval& valid) 
	{
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();
		uvGen->Update(t,ivalid);
		texout->Update(t,ivalid);
		pblock->GetValue( grad_color1, t, col[0], ivalid );
		col[0].ClampMinMax();
		pblock->GetValue( grad_color2, t, col[1], ivalid );
		col[1].ClampMinMax();
		pblock->GetValue( grad_color3, t, col[2], ivalid );
		col[2].ClampMinMax();		
		pblock->GetValue( grad_map1_on, t, mapOn[0], ivalid);
		pblock->GetValue( grad_map2_on, t, mapOn[1], ivalid);
		pblock->GetValue( grad_map3_on, t, mapOn[2], ivalid);
		pblock->GetValue( grad_type, t, type, ivalid );
		pblock->GetValue( grad_noise_type, t, noiseType, ivalid );
		pblock->GetValue( grad_amount, t, amount, ivalid );
		pblock->GetValue( grad_size, t, size, ivalid );
		pblock->GetValue( grad_phase, t, phase, ivalid );
		pblock->GetValue( grad_center, t, center, ivalid );
		pblock->GetValue( grad_levels, t, levels, ivalid );
		pblock->GetValue( grad_high_thresh, t, high, ivalid );
		pblock->GetValue( grad_low_thresh, t, low, ivalid );
		pblock->GetValue( grad_thresh_smooth, t, smooth, ivalid );		
		if (low>high) {
			float temp = low;
			low = high;
			high = temp;
			}
		hminusl = (high-low);
		sd = hminusl*0.5f*smooth;
		if (size!=0.0f) size1 = 20.0f/size;
		else size1 = 0.0f;
		for (int i=0; i<NSUBTEX; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}
		EnableStuff();
		}
	valid &= ivalid;
	}
Exemplo n.º 19
0
void Output::Update(TimeValue t, Interval& valid) {		

	if (Param1)
		{
		pblock->SetValue( output_map1_on, 0, mapOn[0]);
		Param1 = FALSE;
		}

	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();
		texout->Update(t,ivalid);
		pblock->GetValue( output_map1_on, t, mapOn[0], ivalid);

		for (int i=0; i<NSUBTEX; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}
		}
	valid &= ivalid;
	}
Exemplo n.º 20
0
Point3 PinField::Force(TimeValue t,const Point3 &pos, const Point3 &vel,int index) //ok
{	fValid= FOREVER;		
	if (!tmValid.InInterval(t)) 
	{	tmValid=FOREVER;
		tm=node->GetObjectTM(t,&tmValid);
		invtm=Inverse(tm);
	}
	fValid&=tmValid;
	TimeValue t1,t2;

	if (obj == NULL) return Point3(0.0f,0.0f,0.0f);  //667105 watje xrefs can change the base object type through proxies which will cause this to be null or the user can copy a new object type over ours

	obj->pblock->GetValue(PB_ONTIME,t,t1,fValid);
	obj->pblock->GetValue(PB_OFFTIME,t,t2,fValid);
	Point3 OutPin;
	if ((t>=t1)&&(t<=t2))
		OutPin = Zero;
	else 
		OutPin = Zero;
	return OutPin*6.25e-03f;
}
Exemplo n.º 21
0
void Noise::Update(TimeValue t, Interval& valid) {

	if (pblock == NULL) return;

	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();
		if (xyzGen != NULL)
			xyzGen->Update(t,ivalid);
		if (texout != NULL)
			texout->Update(t,ivalid);
		pblock->GetValue( noise_color1, t, col[0], ivalid );
		col[0].ClampMinMax();
		pblock->GetValue( noise_color2, t, col[1], ivalid );
		col[1].ClampMinMax();
		pblock->GetValue( noise_size, t,   size, ivalid );
		pblock->GetValue( noise_phase, t,  phase, ivalid );
		pblock->GetValue( noise_levels, t,  levels, ivalid );
		for (int i=0; i<NSUBTEX; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}		
		pblock->GetValue( noise_hithresh, t, high, ivalid );
		pblock->GetValue( noise_lowthresh, t, low, ivalid );		

		if (high<low) {
			float tmp = low;
			low = high;
			high = tmp;
			}
		pblock->GetValue( noise_map1_on, t, mapOn[0], ivalid);
		pblock->GetValue( noise_map2_on, t, mapOn[1], ivalid);
		pblock->GetValue( noise_type, t, noiseType, ivalid);


		//ComputeAvgValue(); // moved to UpdateCache DDS 10/3/00
		EnableStuff();
		}
	valid &= ivalid;
	}
Exemplo n.º 22
0
// 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); 
		for (int i = 0; i < NUM_SUB_TEXMAPS; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t, texValidity);
		}
	}
	ivalid &= texValidity;
}
Exemplo n.º 23
0
DWORD UVtex::GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) {
#endif
	if (texHandle) {
		if (texHandleValid.InInterval(t))
			return texHandle->GetHandle();
		else DiscardTexHandle();
	}

	Interval v;
	Update(t,v);

	Bitmap *bm;
	bm = BuildBitmap(thmaker.Size());
	texHandle = thmaker.CreateHandle(bm);
	bm->DeleteThis();

	texHandleValid.SetInfinite();
	int i;
	pblock->GetValue(uv_uvchannel, t, i, texHandleValid);
	pblock->GetValue(uv_rtype, t, i, texHandleValid);
	pblock->GetValue(uv_gtype, t, i, texHandleValid);
	pblock->GetValue(uv_btype, t, i, texHandleValid);
	pblock->GetValue(uv_rcount, t, i, texHandleValid);
	pblock->GetValue(uv_gcount, t, i, texHandleValid);
	pblock->GetValue(uv_bcount, t, i, texHandleValid);
	float f;
	pblock->GetValue(uv_tintAmount, t, f, texHandleValid);
	pblock->GetValue(uv_rAmount, t, f, texHandleValid);
	pblock->GetValue(uv_gAmount, t, f, texHandleValid);
	pblock->GetValue(uv_bAmount, t, f, texHandleValid);
	Color c;
	pblock->GetValue(uv_tintColor, t, c, texHandleValid);
	BOOL b;
	pblock->GetValue(uv_clampUVW, t, b, texHandleValid);
	return texHandle->GetHandle();
}
Exemplo n.º 24
0
void UVtex::Update(TimeValue t, Interval& valid) {
	EnterCriticalSection(&csect);
	if (!ivalid.InInterval(t)) {
		ivalid = FOREVER;
		pblock->GetValue(uv_uvchannel,t,uvChannel,ivalid);
#if MAX_RELEASE > 3100
		uvChannel = Clamp(uvChannel, -NUM_HIDDENMAPS, (MAX_MESHMAPS-1));
#else
		uvChannel = Clamp(uvChannel);
#endif
		pblock->GetValue(uv_rtype,t,rType,ivalid);
		rType = Clamp(rType, 0, 1);
		pblock->GetValue(uv_gtype,t,gType,ivalid);
		gType = Clamp(gType, 0, 1);
		pblock->GetValue(uv_btype,t,bType,ivalid);
		bType = Clamp(bType, 0, 1);
		pblock->GetValue(uv_rcount,t,rCount,ivalid);
		rCount = Clamp(rCount, 0, 1000);
		pblock->GetValue(uv_gcount,t,gCount,ivalid);
		gCount = Clamp(gCount, 0, 1000);
		pblock->GetValue(uv_bcount,t,bCount,ivalid);
		bCount = Clamp(bCount, 0, 1000);
		pblock->GetValue(uv_tintColor,t,tintColor,ivalid);
		pblock->GetValue(uv_tintAmount,t,tintAmount,ivalid);
		tintAmount = Clamp(tintAmount);
		pblock->GetValue(uv_rAmount,t,rAmount,ivalid);
		rAmount = Clamp(rAmount);
		pblock->GetValue(uv_gAmount,t,gAmount,ivalid);
		gAmount = Clamp(gAmount);
		pblock->GetValue(uv_bAmount,t,bAmount,ivalid);
		bAmount = Clamp(bAmount);
		pblock->GetValue(uv_clampUVW,t,clampUVW,ivalid);
	}
	valid &= ivalid;
	LeaveCriticalSection(&csect);
}
Exemplo n.º 25
0
Point3 PtForceField::Force(TimeValue t,const Point3 &pos, const Point3 &vel,int index)
{   Point3 ApplyAt,OutForce,zdir;
    fValid= FOREVER;
    if (!tmValid.InInterval(t))
    {   tmValid=FOREVER;
        tm=node->GetObjectTM(t,&tmValid);
        invtm=Inverse(tm);
    }
    ApplyAt=tm.GetTrans();
    fValid&=tmValid;
    TimeValue t1,t2;

    if (obj == NULL) return Point3(0.0f,0.0f,0.0f);  //667105 watje xrefs can change the base object type through proxies which will cause this to be null or the user can copy a new object type over ours

    obj->pblock->GetValue(PB_ONTIME,t,t1,fValid);
    obj->pblock->GetValue(PB_OFFTIME,t,t2,fValid);
    if ((t>=t1)&&(t<=t2))
    {   float BaseF;
        zdir=tm.GetRow(2);
        obj->pblock->GetValue(PB_STRENGTH,t,BaseF,fValid); //assume N
        int tpf=GetTicksPerFrame();
        //int tpf2=tpf*tpf;
        int tps=TIME_TICKSPERSEC;
        int tps2=tps*tps;
        //int FToTick=(int)((float)tps/(float)GetFrameRate());
        BaseF/=(float)tps2;//convert to kg-m/t2
        BaseF*=100.0f; //convert to kg-cm/t2
        int UnitsVal;
        obj->pblock->GetValue(PB_UNITS,t,UnitsVal,fValid);
        if (UnitsVal!=0) BaseF*=4.4591f; //lbf is this much larger than N=kg-m/s2
        TimeValue tage=t-t1;
        TimeValue Per1,Per2;
        obj->pblock->GetValue(PB_TIMEPER1,t,Per1,fValid);
        obj->pblock->GetValue(PB_TIMEPER2,t,Per2,fValid);
        float scalefactor=1.0f;
        int sintoggle;
        obj->pblock->GetValue(PB_ENABLESINES,t,sintoggle,fValid);
        if (sintoggle)
        {   if (Per1>0)
            {   float phase1,amp1;
                float relage1=(float)tage/(float)Per1;
                obj->pblock->GetValue(PB_PHASPER1,t,phase1,fValid);
                obj->pblock->GetValue(PB_AMP1,t,amp1,fValid);
                scalefactor+=0.01f*amp1*(float)sin(TWOPI*relage1+phase1);
            }
            if (Per2>0)
            {   float phase2,amp2;
                float relage2=(float)tage/(float)Per2;
                obj->pblock->GetValue(PB_PHASPER2,t,phase2,fValid);
                obj->pblock->GetValue(PB_AMP2,t,amp2,fValid);
                scalefactor+=0.01f*amp2*(float)sin(TWOPI*relage2+phase2);
            }
        }
        int feedback;
        obj->pblock->GetValue(PB_FEEDBACKON,t,feedback,fValid);
        float scalefactorg=1.0f;
        if (feedback)
        {   float targetspeed,loopgain;
            obj->pblock->GetValue(PB_TARGETVEL,t,targetspeed,fValid);
            targetspeed/=(float)tpf;
            obj->pblock->GetValue(PB_CONTROLGAIN,t,loopgain,fValid);
            float diffspeed=targetspeed-DotProd(vel,zdir);
            //scalefactorg*=diffspeed*loopgain/(float)tpf;
            scalefactorg*=diffspeed*loopgain/100.0f;
            int revon;
            obj->pblock->GetValue(PB_REVERSIBLE,t,revon,fValid);
            if ((!revon)&&(scalefactorg<0.0f)) scalefactorg=0.0f;
        }
        OutForce=zdir*BaseF*scalefactor*scalefactorg;
        int rangeon;
        obj->pblock->GetValue(PB_RANGEON,t,rangeon,fValid);
        if (rangeon)
        {   float maxrange;
            obj->pblock->GetValue(PB_RANGEVAL,t,maxrange,fValid);
            float distance=Length(ApplyAt-pos);
            if (distance<maxrange)
            {   if (maxrange>FLOAT_EPSILON) OutForce*=(1.0f-distance/maxrange);
                else OutForce=Zero;
            }
            else OutForce=Zero;
        }
    }
    else OutForce=Zero;
    return OutForce*6.25e-03f;
}
Exemplo n.º 26
0
void Composite::SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb)
{
	Interval valid;
	Texmap *sub[MAXTEXHANDLES];
	int texOp;

	IHardwareMaterial *pIHWMat = (IHardwareMaterial *)GetProperty(PROPID_HARDWARE_MATERIAL);
	if (pIHWMat) {
		// This is only true if Direct3D is in use
		if (texHandleValid.InInterval(t)) {
			pIHWMat->SetNumTexStages(numTexHandlesUsed);
			int nt = numTexHandlesUsed;
			if (numTexHandlesUsed == 1) {
				texOp = TX_MODULATE;
			}
			else {
				texOp = TX_ALPHABLEND;
			}
			for (int i = 0; i < nt; i++) {
				if (texHandle[i]) {
					pIHWMat->SetTexture(i, texHandle[i]->GetHandle());
					// Kludge to pass in the TextureStage number
					mtl->texture[0].useTex = i;
					cb.GetGfxTexInfoFromTexmap(t, mtl->texture[0], subTex[useSubForTex[i]]); 		
					SetHWTexOps(pIHWMat, i, texOp);
				}
			}
			return;
		}
		else {
			DiscardTexHandles();
		}

		int forceW = 0;
		int forceH = 0;

		int nsupport = cb.NumberTexturesSupported();

		nsupport = (nsupport > MAXTEXHANDLES) ? MAXTEXHANDLES : nsupport;

		numTexHandlesUsed = 0;

		for (int i = 0; i < MAXTEXHANDLES; i++) {
			texHandle[i] = NULL;
			sub[i] = NULL;
		}

		int nmaps = 0;
		for (i = 0; i < subTex.Count(); i++) {
			if (mapOn[i]) {
				if (subTex[i]) {
					sub[nmaps] = subTex[i];
					useSubForTex[nmaps] = i;
					if (++nmaps >= nsupport) {
						break;
					}
				}
			}
		}

		pIHWMat->SetNumTexStages(nmaps);
		for (i = 0; i < nmaps; i++) {
			pIHWMat->SetTexture(i, (DWORD_PTR)NULL);
		}

		numTexHandlesUsed  = nmaps;

		texHandleValid.SetInfinite();
		
		if (numTexHandlesUsed == 1) {
			texOp = TX_MODULATE;
		}
		else {
			texOp = TX_ALPHABLEND;
		}
		for (i = 0; i < numTexHandlesUsed; i++) {
			// Kludge to pass in the TextureStage number
			mtl->texture[0].useTex = i;
			cb.GetGfxTexInfoFromTexmap(t, mtl->texture[0], sub[i]);
			BITMAPINFO *bmi = sub[i]->GetVPDisplayDIB(t, cb, valid, FALSE, 0, 0);
			texHandle[i] = cb.MakeHandle(bmi);
			pIHWMat->SetTexture(i, texHandle[i]->GetHandle());
			SetHWTexOps(pIHWMat, i, texOp);
		}
	}
	else {
		if (texHandleValid.InInterval(t)) {
			mtl->texture.SetCount(numTexHandlesUsed);
			int nt = numTexHandlesUsed;
			for (int i=0; i<nt; i++) {
				if (texHandle[i]) {
					mtl->texture[i].textHandle = texHandle[i]->GetHandle();
					cb.GetGfxTexInfoFromTexmap(t, mtl->texture[i], subTex[useSubForTex[i]] ); 		
					SetTexOps(&mtl->texture[i],numTexHandlesUsed==1?TX_MODULATE:TX_ALPHABLEND);
				}
			}
			return;
		}
		else {
			DiscardTexHandles();
		}

		int forceW = 0;
		int forceH = 0;

		int nsupport = cb.NumberTexturesSupported();

		nsupport = (nsupport > MAXTEXHANDLES) ? MAXTEXHANDLES : nsupport;

		numTexHandlesUsed = 0;

		for (int i=0; i<MAXTEXHANDLES; i++) {
			texHandle[i] = NULL;
			sub[i]=NULL;
			}

		
		int nmaps = 0;
		for (i=0; i<subTex.Count(); i++) {
			if (mapOn[i]) {
				if (subTex[i]) {
					sub[nmaps] = subTex[i];
					useSubForTex[nmaps] = i;
					if (++nmaps>=nsupport)
						break;
					}
				}
			}

		mtl->texture.SetCount(nmaps);
		for (i=0; i<nmaps; i++) {
			mtl->texture[i].textHandle = NULL;
			}

		numTexHandlesUsed  = nmaps;

		texHandleValid.SetInfinite();
		
		for (i=0; i<nmaps; i++) {
			cb.GetGfxTexInfoFromTexmap(t, mtl->texture[i], sub[i] ); 		
			BITMAPINFO *bmi = sub[i]->GetVPDisplayDIB(t,cb,valid,FALSE,0,0); 
			texHandle[i] = cb.MakeHandle(bmi); 
			mtl->texture[i].textHandle = texHandle[i]->GetHandle();
			SetTexOps(&mtl->texture[i],nmaps==1?TX_MODULATE:TX_ALPHABLEND);
			}
		mtl->texture.SetCount(nmaps);
	}
}
Exemplo n.º 27
0
void TriPatchObject::UpdatePatchMesh(TimeValue t) {
	if ( ivalid.InInterval(t) ) {
		return;
		}
	BuildPatch(t,patch);
	}
Exemplo n.º 28
0
// Output float keys if this is a known float controller that
// supports key operations. Otherwise we will sample the controller 
// once for each frame to get the value.
void AsciiExp::DumpFloatKeys(Control* cont, int indentLevel) 
{
	if (!cont)
		return;
	
	int i;
	TSTR indent = GetIndent(indentLevel);
	IKeyControl *ikc = NULL;

	// If the user wants us to always sample, we will ignore the KeyControlInterface
	if (!GetAlwaysSample())
		ikc = GetKeyControlInterface(cont);
	
	// TCB float
	if (ikc && cont->ClassID() == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0)) {
		_ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_CONTROL_FLOAT_TCB); 
		for (i=0; i<ikc->GetNumKeys(); i++) {
			ITCBFloatKey key;
			ikc->GetKey(i, &key);
			_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s"),
				indent.data(),
				ID_TCB_FLOAT_KEY,
				key.time,
				Format(key.val));
			_ftprintf(pStream, _T("\t%s\t%s\t%s\t%s\t%s\n"), Format(key.tens), Format(key.cont), Format(key.bias), Format(key.easeIn), Format(key.easeOut));
		}
		_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
	}
	// Bezier float
	else if (ikc && cont->ClassID() == Class_ID(HYBRIDINTERP_FLOAT_CLASS_ID, 0)) {
		_ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_CONTROL_FLOAT_BEZIER); 
		for (i=0; i<ikc->GetNumKeys(); i++) {
			IBezFloatKey key;
			ikc->GetKey(i, &key);
			_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s"),
				indent.data(),
				ID_BEZIER_FLOAT_KEY,
				key.time, 
				Format(key.val));
			_ftprintf(pStream, _T("\t%s\t%s\t%d\n"), Format(key.intan), Format(key.outtan), key.flags);
		}
		_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
	}
	else if (ikc && cont->ClassID() == Class_ID(LININTERP_FLOAT_CLASS_ID, 0)) {
		_ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_CONTROL_FLOAT_LINEAR); 
		for (i=0; i<ikc->GetNumKeys(); i++) {
			ILinFloatKey key;
			ikc->GetKey(i, &key);
			_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"),
				indent.data(),
				ID_FLOAT_KEY,
				key.time,
				Format(key.val));
		}
		_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
	}
	else {
		
		// Unknown controller, no key interface or sample on demand -
		// This might be a procedural controller or something else we
		// don't know about. The last resort is to get the value from the 
		// controller at every n frames.
		
		TSTR name;
		cont->GetClassName(name);
		TSTR className = FixupName(name);
		Interface14 *iface = GetCOREInterface14();
		UINT codepage  = iface-> DefaultTextSaveCodePage(true);
		const char* className_locale = className.ToCP(codepage);
		_ftprintf(pStream, _T("%s\t\t%s \"%hs\" {\n"), indent.data(), ID_CONTROL_FLOAT_SAMPLE,
			className_locale);
		
		// If it is animated at all...
		if (cont->IsAnimated()) {
			// Get the range of the controller animation 
			Interval range; 
			// Get range of full animation
			Interval animRange = ip->GetAnimRange(); 
			TimeValue t = cont->GetTimeRange(TIMERANGE_ALL).Start();
			float value;
			
			// While we are inside the animation... 
			while (animRange.InInterval(t)) {
				// Sample the controller
				range = FOREVER;
				cont->GetValue(t, &value, range);
				
				// Set time to start of controller validity interval 
				t = range.Start();
				
				// Output the sample
				_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"),
					indent.data(),
					ID_FLOAT_KEY,
					t,
					Format(value));
				
				// If the end of the controller validity is beyond the 
				// range of the animation
				if (range.End() > cont->GetTimeRange(TIMERANGE_ALL).End()) {
					break;
				}
				else {
					t = (range.End()/GetTicksPerFrame()+GetKeyFrameStep()) * GetTicksPerFrame();
				}
			}
		}
		_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
	}
}
Exemplo n.º 29
0
void CellTex::Update(TimeValue t, Interval& valid)
	{
	EnterCriticalSection(&csect);
	if (!ivalid.InInterval(t)) {
		ivalid = FOREVER;		
		xyzGen->Update(t,ivalid);
		texout->Update(t,ivalid);
/*	
		pblock->GetValue(PB_CELLCOL,t,cellCol,ivalid);
		pblock->GetValue(PB_DIVCOL1,t,divCol1,ivalid);
		pblock->GetValue(PB_DIVCOL2,t,divCol2,ivalid);
		pblock->GetValue(PB_VAR,t,var,ivalid);
		pblock->GetValue(PB_SIZE,t,size,ivalid);
		pblock->GetValue(PB_SPREAD,t,spread,ivalid);
		pblock->GetValue(PB_LOW,t,low,ivalid);
		pblock->GetValue(PB_MID,t,mid,ivalid);
		pblock->GetValue(PB_HIGH,t,high,ivalid);		
		pblock->GetValue(PB_TYPE,t,type,ivalid);
		pblock->GetValue(PB_FRACT,t,fract,ivalid);
		pblock->GetValue(PB_ITER,t,iterations,ivalid);		
		pblock->GetValue(PB_USECELLMAP,t,useCellMap,ivalid);
		pblock->GetValue(PB_USEDIV1MAP,t,useDiv1Map,ivalid);
		pblock->GetValue(PB_USEDIV2MAP,t,useDiv2Map,ivalid);		
		pblock->GetValue(PB_ROUGH,t,rough,ivalid);
		pblock->GetValue(PB_SMOOTH,t,smooth,ivalid);
		pblock->GetValue(PB_ADAPT,t,adapt,ivalid);
*/		

		pblock->GetValue(cellular_celcolor,t,cellCol,ivalid);
		pblock->GetValue(cellular_divcol1,t,divCol1,ivalid);
		pblock->GetValue(cellular_divcol2,t,divCol2,ivalid);
		pblock->GetValue(cellular_variation,t,var,ivalid);
		pblock->GetValue(cellular_size,t,size,ivalid);
		pblock->GetValue(cellular_spread,t,spread,ivalid);
		pblock->GetValue(cellular_lowthresh,t,low,ivalid);
		pblock->GetValue(cellular_midthresh,t,mid,ivalid);
		pblock->GetValue(cellular_highthresh,t,high,ivalid);		
		pblock->GetValue(cellular_type,t,type,ivalid);
		pblock->GetValue(cellular_fractal,t,fract,ivalid);
		pblock->GetValue(cellular_iteration,t,iterations,ivalid);		
		pblock->GetValue(cellular_map1_on,t,useCellMap,ivalid);
		pblock->GetValue(cellular_map2_on,t,useDiv1Map,ivalid);
		pblock->GetValue(cellular_map3_on,t,useDiv2Map,ivalid);		
		pblock->GetValue(cellular_rough,t,rough,ivalid);
		pblock->GetValue(cellular_smooth,t,smooth,ivalid);
		pblock->GetValue(cellular_adaptive,t,adapt,ivalid);
		
		
		smooth *= 0.7f;
		rough = 2.0f-rough;

		highMinuslow = high-low;		
		midMinuslow = mid - low;
		highMinusmid = high - mid;		
		if (type) {
			spread = spread/2.0f;
			}		
		var /= 50.0f;
		varOff = 1.0f-var * 0.5f;	

		for (int i=0; i<NSUBTEX; i++) {
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}		
		}
	valid &= ivalid;
	LeaveCriticalSection(&csect);
	}
Exemplo n.º 30
0
Point3 WindField::Force(
		TimeValue t,const Point3 &pos, const Point3 &vel,int index)
	{
	if (!obj)
		return Point3(0.0f, 0.0f, 0.0f);

	float strength, decay, turb;
	obj->pblock2->GetValue(PB_DECAY,t,decay,fValid);
	obj->pblock2->GetValue(PB_TURBULENCE,t,turb,FOREVER);
	if (decay <0.0f) decay = 0.0f;

	if (!fValid.InInterval(t) || type==FORCE_SPHERICAL || decay!=0.0f) {
		fValid = FOREVER;		
		if (!tmValid.InInterval(t)) {
			tmValid = FOREVER;
			tm = node->GetObjectTM(t,&tmValid);
			}
		fValid &= tmValid;
		obj->pblock2->GetValue(PB_STRENGTH,t,strength,fValid);
		
		if (type==FORCE_PLANAR) {
			force = Normalize(tm.GetRow(2));
			if (decay!=0.0f) {
				float dist = (float)fabs(DotProd(force,pos-tm.GetTrans()));
				strength *= (float)exp(-decay*dist);
				}			
			force *= strength * 0.0001f * forceScaleFactor;
		} else {
			float dist;
			force = pos-tm.GetTrans();
			dist  = Length(force);
			if (dist!=0.0f) force /= dist;
			if (decay!=0.0f) {				
				strength *= (float)exp(-decay*dist);
				}			
			force *= strength * 0.0001f * forceScaleFactor;
			}
		}	
	if (turb!=0.0f) {
		float freq, scale;
		Point3 tf, pt = pos-tm.GetTrans(), p;
		obj->pblock2->GetValue(PB_FREQUENCY,t,freq,FOREVER);
		obj->pblock2->GetValue(PB_SCALE,t,scale,FOREVER);
		freq *= 0.01f;
		turb *= 0.0001f * forceScaleFactor;

		p    = pt;
		p.x  = freq * float(t);
		tf.x = RTurbulence(p,scale);
		p    = pt;
		p.y  = freq * float(t);
		tf.y = RTurbulence(p,scale);
		p    = pt;
		p.z  = freq * float(t);
		tf.z = RTurbulence(p,scale);

		return force + (turb*tf);
	} else {
		return force;
		}
	}