char HPolygonalUV::save(APolygonalUV * poly) { int nuv = poly->numCoords(); if(!hasNamedAttr(".nuv")) addIntAttr(".nuv"); writeIntAttr(".nuv", &nuv); int nind = poly->numIndices(); if(!hasNamedAttr(".nind")) addIntAttr(".nind"); writeIntAttr(".nind", &nind); if(!hasNamedData(".ucoord")) addFloatData(".ucoord", nuv); writeFloatData(".ucoord", nuv, (float *)poly->ucoord()); if(!hasNamedData(".vcoord")) addFloatData(".vcoord", nuv); writeFloatData(".vcoord", nuv, (float *)poly->vcoord()); if(!hasNamedData(".uvid")) addIntData(".uvid", nind); writeIntData(".uvid", nind, (int *)poly->indices()); return 1; }
void HAttributeGroup::writeEnum(AEnumAttribute * data) { short a, b; int v = data->value(a, b); if(!hasNamedAttr(".val")) addIntAttr(".val"); writeIntAttr(".val", &v); int r[2]; r[0] = a; r[1] = b; if(!hasNamedAttr(".range")) addIntAttr(".range", 2); writeIntAttr(".range", r); // std::cout<<" value "<<v; // std::cout<<" range "<<a<<":"<<b; short i; std::stringstream sst; for(i=a; i<=b; i++) { std::string fn = data->fieldName(i); sst.str(""); sst<<i; if(!hasNamedAttr(sst.str().c_str())) addStringAttr(sst.str().c_str(), fn.size()); writeStringAttr(sst.str().c_str(), fn); // std::cout<<" field "<<i<<":"<<fn; } }
char HField::save(AField * fld) { if(fld->numChannels() < 1) { std::cout<<"\n field has no channel"; return 0; } if(!hasNamedAttr(".fieldType")) addIntAttr(".fieldType"); int t = fld->fieldType(); writeIntAttr(".fieldType", &t); std::vector<std::string > names; fld->getChannelNames(names); int nc = names.size(); if(!hasNamedAttr(".fieldNumChannels")) addIntAttr(".fieldNumChannels"); writeIntAttr(".fieldNumChannels", &nc); std::string combined = SHelper::Combine(names); if(!hasNamedAttr(".fieldChannelNames")) addStringAttr(".fieldChannelNames", combined.size()); writeStringAttr(".fieldChannelNames", combined); std::vector<std::string >::const_iterator it = names.begin(); for(; it!= names.end();++it) saveAChannel(*it, fld->namedChannel(*it)); return 1; }
char HTriangleMesh::save(ATriangleMesh * tri) { int nv = tri->numPoints(); if(!hasNamedAttr(".nv")) addIntAttr(".nv"); writeIntAttr(".nv", &nv); int nt = tri->numTriangles(); if(!hasNamedAttr(".ntri")) addIntAttr(".ntri"); writeIntAttr(".ntri", &nt); if(!hasNamedData(".p")) addVector3Data(".p", nv); writeVector3Data(".p", nv, (Vector3F *)tri->points()); if(!hasNamedData(".a")) addIntData(".a", nv); writeIntData(".a", nv, (int *)tri->anchors()); if(!hasNamedData(".v")) addIntData(".v", nt * 3); writeIntData(".v", nt * 3, (int *)tri->indices()); return 1; }
char HNumericBundle::save(const ABundleAttribute * d) { if(!hasNamedAttr(".longname")) addStringAttr(".longname", d->longName().size()); writeStringAttr(".longname", d->longName()); int sz = d->size(); if(!hasNamedAttr(".bundle_sz")) addIntAttr(".bundle_sz"); writeIntAttr(".bundle_sz", &sz); int nt = d->numericType(); if(!hasNamedAttr(".bundle_num_typ")) addIntAttr(".bundle_num_typ"); writeIntAttr(".bundle_num_typ", &nt); int l = d->dataLength(); if(!hasNamedData(".raw")) addCharData(".raw", l); writeCharData(".raw", l, (char *)d->value()); return 1; }
void TreeModel::addOptions(QList<TreeItem*> & parents) { addBase(parents, "options", 0); addIntAttr(parents, "max_subdiv", 1, 3); addIntAttr(parents, "AA_samples", 1, 5); addIntAttr(parents, "res_x", 1, 400); addIntAttr(parents, "res_y", 1, 300); }
char HAdaptiveField::save(AdaptiveField * fld) { int nc = fld->numCells(); std::cout<<"\n hadaptivefield save n cells "<<nc; if(!hasNamedAttr(".ncells")) addIntAttr(".ncells"); writeIntAttr(".ncells", &nc); if(!hasNamedAttr(".origin_span")) addFloatAttr(".origin_span", 4); float originSpan[4]; originSpan[0] = fld->origin().x; originSpan[1] = fld->origin().y; originSpan[2] = fld->origin().z; originSpan[3] = fld->span(); writeFloatAttr(".origin_span", originSpan); if(!hasNamedAttr(".max_level")) addIntAttr(".max_level"); int ml = fld->maxLevel(); writeIntAttr(".max_level", &ml); BaseBuffer dhash; dhash.create(nc * 16); IOCellHash * dst = (IOCellHash *)dhash.data(); sdb::CellHash * c = fld->cells(); c->begin(); while(!c->end()) { dst->code = c->key(); dst->level = c->value()->level; dst->visited = c->value()->visited; dst->index = c->value()->index; dst++; c->next(); } if(!hasNamedData(".cellHash")) addCharData(".cellHash", nc*16); writeCharData(".cellHash", nc*16, dhash.data()); return HField::save(fld); }
void HAttributeGroup::writeNumericValueAsInt(ANumericAttribute * data) { short va; int vb; bool vc; switch (data->numericType()) { case ANumericAttribute::TByteNumeric: va = (static_cast<AByteNumericAttribute *> (data))->value(); vb = va; break; case ANumericAttribute::TShortNumeric: va = (static_cast<AShortNumericAttribute *> (data))->value(); vb = va; break; case ANumericAttribute::TIntNumeric: vb = (static_cast<AIntNumericAttribute *> (data))->value(); break; case ANumericAttribute::TBooleanNumeric: vc = (static_cast<ABooleanNumericAttribute *> (data))->value(); vb = vc; break; default: break; } if(!hasNamedAttr(".val")) addIntAttr(".val"); writeIntAttr(".val", &vb); // std::cout<<" value "<<vb; }
void HAttributeGroup::writeNumeric(ANumericAttribute * data) { int t = data->numericType(); if(t==0) return; if(!hasNamedAttr(".num_typ")) addIntAttr(".num_typ"); writeIntAttr(".num_typ", &t); switch (data->numericType()) { case ANumericAttribute::TByteNumeric: case ANumericAttribute::TShortNumeric: case ANumericAttribute::TIntNumeric: case ANumericAttribute::TBooleanNumeric: writeNumericValueAsInt(data); break; case ANumericAttribute::TFloatNumeric: case ANumericAttribute::TDoubleNumeric: writeNumericValueAsFlt(data); break; default: break; } }
char HIntAttributeEntry::save(int * src) { if(!hasNamedAttr(".def_val")) addIntAttr(".def_val"); writeIntAttr(".def_val", src); return HAttributeEntry::save(); }
char HAttributeEntry::save() { if(!hasNamedAttr(".attrib_typ")) addIntAttr(".attrib_typ"); int typasi = attributeType(); writeIntAttr(".attrib_typ", &typasi); return 1; }
char HAnimationCurve::save(AAnimationCurve * curve) { if(!hasNamedAttr(".animcurve_type")) addIntAttr(".animcurve_type"); int t = curve->curveType(); writeIntAttr(".animcurve_type", &t); if(!hasNamedAttr(".n_keys")) addIntAttr(".n_keys"); int n = curve->numKeys(); writeIntAttr(".n_keys", &n); saveKeys(curve, n); return 1; }
void TreeModel::addLights(QList<TreeItem*> & parents) { addBase(parents, "lights", 0); addBase(parents, "distant_key", 1); addFltAttr(parents, "intensity", 2, 1.1); addIntAttr(parents, "samples", 2, 3); addBolAttr(parents, "cast_shadow", 2, false); QColor col; col.setRgbF(1.0, 0.5, 0.4); addRGBAttr(parents, "light_color", 2, col); }
char HOption::save(RenderOptions * opt) { int aas = opt->AASample(); if(!hasNamedAttr(".aas")) addIntAttr(".aas"); writeIntAttr(".aas", &aas); int rw = opt->renderImageWidth(); if(!hasNamedAttr(".rw")) addIntAttr(".rw"); writeIntAttr(".rw", &rw); int rh = opt->renderImageHeight(); if(!hasNamedAttr(".rh")) addIntAttr(".rh"); writeIntAttr(".rh", &rh); int msd = opt->maxSubdiv(); if(!hasNamedAttr(".msd")) addIntAttr(".msd"); writeIntAttr(".msd", &msd); int uds = 0; if(opt->useDisplaySize()) uds = 1; if(!hasNamedAttr(".uds")) addIntAttr(".uds"); writeIntAttr(".uds", &uds); return 1; }
char HTriangleMeshGroup::save(ATriangleMeshGroup * tri) { if(!hasNamedAttr(".npart")) addIntAttr(".npart"); int np = tri->numStripes(); writeIntAttr(".npart", &np); if(!hasNamedData(".pntdrift")) addIntData(".pntdrift", np); writeIntData(".pntdrift", np, (int *)tri->pointDrifts()); if(!hasNamedData(".inddrift")) addIntData(".inddrift", np); writeIntData(".inddrift", np, (int *)tri->indexDrifts()); return HTriangleMesh::save(tri); }
char HAttributeGroup::save(AAttribute * data) { if(!hasNamedAttr(".attr_typ")) addIntAttr(".attr_typ"); int t = data->attrType(); writeIntAttr(".attr_typ", &t); // std::cout<<"\nsave attr type "<<data->attrTypeStr(); if(!hasNamedAttr(".longname")) addStringAttr(".longname", data->longName().size()); writeStringAttr(".longname", data->longName()); // std::cout<<"\nsave attr name "<<data->longName(); if(data->isNumeric()) writeNumeric( static_cast<ANumericAttribute *> (data) ); else if(data->isEnum()) writeEnum( static_cast<AEnumAttribute *> (data) ); else if(data->isString()) writeString( static_cast<AStringAttribute *> (data) ); else if(data->isCompound()) writeCompound( static_cast<ACompoundAttribute *> (data) ); return 1; }
char HMesh::save(BaseMesh * mesh) { mesh->verbose(); int nv = mesh->getNumVertices(); if(!hasNamedAttr(".nv")) addIntAttr(".nv"); writeIntAttr(".nv", &nv); int nf = mesh->getNumPolygons(); if(!hasNamedAttr(".nf")) addIntAttr(".nf"); writeIntAttr(".nf", &nf); int nfv = mesh->getNumPolygonFaceVertices(); if(!hasNamedAttr(".nfv")) addIntAttr(".nfv"); writeIntAttr(".nfv", &nfv); int nuv = mesh->getNumUVs(); if(!hasNamedAttr(".nuv")) addIntAttr(".nuv"); writeIntAttr(".nuv", &nuv); int nuvid = mesh->getNumUVIds(); if(!hasNamedAttr(".nuvid")) addIntAttr(".nuvid"); writeIntAttr(".nuvid", &nuvid); if(!hasNamedData(".p")) addVector3Data(".p", nv); writeVector3Data(".p", nv, mesh->getVertices()); if(!hasNamedData(".polyc")) addIntData(".polyc", nf); writeIntData(".polyc", nf, (int *)mesh->getPolygonCounts()); if(!hasNamedData(".polyv")) addIntData(".polyv", nfv); std::cout<<" polyv[0]"<<mesh->getPolygonIndices()[0]<<"\n"; std::cout<<" polyv["<<nfv<<"-1]"<<mesh->getPolygonIndices()[nfv - 1]<<"\n"; writeIntData(".polyv", nfv, (int *)mesh->getPolygonIndices()); if(!hasNamedData(".us")) addFloatData(".us", nuv); writeFloatData(".us", nuv, mesh->getUs()); if(!hasNamedData(".vs")) addFloatData(".vs", nuv); writeFloatData(".vs", nuv, mesh->getVs()); if(!hasNamedData(".uvids")) addIntData(".uvids", nuvid); writeIntData(".uvids", nuvid, (int *)mesh->getUvIds()); return 1; }