void BerconGradient::gradMoveKey(int n, float pos) { TimeValue t = GetCOREInterface()->GetTime(); if (n < countKeys()) pblock->SetValue(pb_positions, t, pos, n); ivalid.SetEmpty(); Update(GetCOREInterface()->GetTime(),Interval()); }
void BerconGradient::gradDelKey(int n) { if (!pblock) return; if (n <= 1) return; // Don't delete keys 0 and 1 if (n < countKeys()) { pblock->Delete(pb_submaps, n, 1); pblock->Delete(pb_colors, n, 1); pblock->Delete(pb_positions, n, 1); } ivalid.SetEmpty(); Update(GetCOREInterface()->GetTime(),Interval()); }
void BerconGradient::gradAddKey(float pos) { if (!pblock) return; countKeys(); AColor* col = &gradient->getColor(pos); Texmap* sub = NULL; pblock->Append(pb_submaps, 1, &sub); pblock->Append(pb_colors, 1, &col); pblock->Append(pb_positions, 1, &pos); ivalid.SetEmpty(); Update(GetCOREInterface()->GetTime(),Interval()); }
int ldap_create_sort_keylist ( LDAPSortKey ***sortKeyList, char *keyString ) { int numKeys, rc, i; char *nextKey; LDAPSortKey **keyList = NULL; assert( sortKeyList != NULL ); assert( keyString != NULL ); *sortKeyList = NULL; /* Determine the number of sort keys so we can allocate memory. */ if (( numKeys = countKeys(keyString)) == 0) { return LDAP_PARAM_ERROR; } /* Allocate the array of pointers. Initialize to NULL. */ keyList=(LDAPSortKey**)LBER_CALLOC(numKeys+1, sizeof(LDAPSortKey*)); if ( keyList == NULL) return LDAP_NO_MEMORY; /* For each sort key in the string, create an LDAPSortKey structure and add it to the list. */ nextKey = keyString; /* Points to the next key in the string */ for (i=0; i < numKeys; i++) { rc = readNextKey(&nextKey, &keyList[i]); if (rc != LDAP_SUCCESS) { ldap_free_sort_keylist(keyList); return rc; } } *sortKeyList = keyList; return LDAP_SUCCESS; }
RefTargetHandle BerconGradient::Clone(RemapDir &remap) { int keys = countKeys(); BerconGradient *mnew = new BerconGradient(); *((MtlBase*)mnew) = *((MtlBase*)this); mnew->pblock->SetCount(pb_submaps, keys); for (int i = 0; i<keys; i++) { mnew->ReplaceReference(i+REF_OFFSET+SUBMAPCOUNT, remap.CloneRef(gradient->getSubtex(i))); } mnew->ReplaceReference(MAPTEX_REF, remap.CloneRef(p_maptex)); mnew->ReplaceReference(DISTEX_REF, remap.CloneRef(p_distex)); mnew->ivalid.SetEmpty(); mnew->ReplaceReference(PBLOCK_REF,remap.CloneRef(pblock)); mnew->ReplaceReference(COORD_REF,remap.CloneRef(pbXYZ)); mnew->ReplaceReference(OUTPUT_REF,remap.CloneRef(texout)); mnew->ReplaceReference(CURVE_REF,remap.CloneRef(curve)); mnew->ReplaceReference(CURVEPB_REF,remap.CloneRef(pbCurve)); BaseClone(this, mnew, remap); return (RefTargetHandle)mnew; }
void BerconGradient::Update(TimeValue t, Interval& valid) { //CharStream *out = thread_local(current_stdout); if (pblock == NULL || gradient == NULL) return; if (!ivalid.InInterval(t)) { // Set key information if (gradient->selected >= 0 && gradient->selected < countKeys() && pblock->GetMap() != NULL) { AColor currentKeyColor = pblock->GetAColor(pb_colors, t, gradient->selected); pblock->SetValue(pb_keyCol, t, Color(currentKeyColor.r, currentKeyColor.g, currentKeyColor.b)); pblock->SetValue(pb_keyNum, t, gradient->selected); pblock->SetValue(pb_keyPos, t, pblock->GetFloat(pb_positions, t, gradient->selected)); pblock->GetDesc()->InvalidateUI(pb_keyCol); pblock->GetDesc()->InvalidateUI(pb_keyNum); pblock->GetDesc()->InvalidateUI(pb_keyPos); } ivalid.SetInfinite(); // Start from infinite interval if (p_maptex) p_maptex->Update(t,ivalid); if (p_distex) p_distex->Update(t,ivalid); //if (xyzGen != NULL) //xyzGen->Update(t,ivalid); if (texout != NULL) texout->Update(t,ivalid); pbCurve->GetValue(pb_curve_on, t, p_curveOn, ivalid); // Load gradient int keys = countKeys(); gradient->reset(); pblockGetValue(pb_interpolation,gradient->interpolation); for (int i=0;i<keys;i++) { float pos; AColor col; Texmap* tex; pblock->GetValue(pb_positions, t, pos, ivalid, i); pblock->GetValue(pb_submaps, t, tex, ivalid, i); pblock->GetValue(pb_colors, t, col, ivalid, i); if (i == 0) pos = 0.f; else if (i == 1) pos = 1.f; gradient->addKey(i,pos,col,tex); if (gradient->getSubtex(i)) gradient->getSubtex(i)->Update(t,ivalid); } gradient->sort(); gradient->invalidate(); // General stuff pblockGetValue(pb_seed, p_seed); pblockGetValue(pb_type, p_type); pblockGetValue(pb_rand_obj, p_randObj); pblockGetValue(pb_rand_mat, p_randMat); pblockGetValue(pb_rand_par, p_randPar); pblockGetValue(pb_rand_tile, p_randTile); pblockGetValue(pb_range_min, p_rangeMin); pblockGetValue(pb_range_max, p_rangeMax); pblockGetValue(pb_gradient_uvw, p_uvwType); pblockGetValue(pb_gradient_normal, p_normalType); pblockGetValue(pb_gradient_normal2, p_normalFunction); pblockGetValue(pb_ior, p_ior); pblockGetValue(pb_dison, p_disOn); pblockGetValue(pb_disstr, p_disStr); pblockGetValue(pb_reverse, p_reverse); pblockGetValue(pb_range_loop, p_rangeLoop); pblockGetValue(pb_node, p_node); if (p_rangeMin > p_rangeMax) // Switch so rangeMax is always bigger { float f = p_rangeMin; p_rangeMax = p_rangeMin; p_rangeMin = f; } EnableStuff(); berconXYZ.update(pbXYZ, t, ivalid); } valid &= ivalid; }