ComponentType componentType; //!< The datatype of components in the attribute. (required)
unsigned int count; //!< The number of attributes referenced by this accessor. (required)
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
- //std::vector<float> max; //!< Maximum value of each component in this attribute.
- //std::vector<float> min; //!< Minimum value of each component in this attribute.
+ std::vector<float> max; //!< Maximum value of each component in this attribute.
+ std::vector<float> min; //!< Minimum value of each component in this attribute.
unsigned int GetNumComponents();
unsigned int GetBytesPerComponent();
inline Value& MakeValue(Value& val, float(&r)[N], MemoryPoolAllocator<>& al) {
val.SetArray();
val.Reserve(N, al);
- for (decltype(N) i = 0; i < N; ++i) {
+ for (decltype(N) i = 0; i < N; ++i) {
+ val.PushBack(r[i], al);
+ }
+ return val;
+ }
+
+ inline Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
+ val.SetArray();
+ val.Reserve(r.size(), al);
+ for (int i = 0; i < r.size(); ++i) {
val.PushBack(r[i], al);
}
return val;
obj.AddMember("componentType", int(a.componentType), w.mAl);
obj.AddMember("count", a.count, w.mAl);
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
+
+ Value vTmpMax, vTmpMin;
+ obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
+ obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
}
inline void Write(Value& obj, Animation& a, AssetWriter& w)
asset.SetObject();
{
char versionChar[10];
- snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version);
+ ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version);
asset.AddMember("version", Value(versionChar, mAl).Move(), mAl);
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
acc->count = count;
acc->type = typeOut;
+ // calculate min and max values
+ {
+ // Allocate and initialize with large values.
+ float float_MAX = 10000000000000;
+ for (int i = 0 ; i < numCompsOut ; i++) {
+ acc->min.push_back( float_MAX);
+ acc->max.push_back(-float_MAX);
+ }
+
+ // Search and set extreme values.
+ float valueTmp;
+ for (int i = 0 ; i < count ; i++) {
+ for (int j = 0 ; j < numCompsOut ; j++) {
+
+ valueTmp = static_cast<aiVector3D*>(data)[i][j];
+ if (valueTmp < acc->min[j]) {
+ acc->min[j] = valueTmp;
+ }
+ if (valueTmp > acc->max[j]) {
+ acc->max[j] = valueTmp;
+ }
+ }
+ }
+ }
+
// copy the data
acc->WriteData(count, data, numCompsIn*bytesPerComp);