void filter_values::calculate (type type, float freq, float res, float srate) { /* Adapt the values to avoid strange noise */ freq = tMax(freq, 0.01f); res = tMax(res, 0.01f); m_type = type; m_freq = freq; m_res = res; m_srate = srate; calculate(); }
//---------------------------------------------------------------------------- // Reset the texture coordinates after a split. // void ITR3DMImport::normalizeTexture(Poly* poly) { Point2F tMin(+1.0E20f,+1.0E20f); Point2F tMax(-1.0E20f,-1.0E20f); for (int i = 0; i < poly->vertexList.size(); i++) { Point2F& tv = poly->vertexList[i].texture; tv.x += poly->textureOffset.x; tv.y += poly->textureOffset.y; tMin.setMin(tv); tMax.setMax(tv); } tMin.x = floor(tMin.x); tMin.y = floor(tMin.y); tMax.x = ceil(tMax.x); tMax.y = ceil(tMax.y); // Mask onto power of 2 bitmap size. Point2I offset; offset.x = int(tMin.x) & MaxTextureMask; offset.y = int(tMin.y) & MaxTextureMask; // Adjust offset to multiple of 8 to avoid // mipmap jumping. poly->textureOffset.x = offset.x & ~0x7; poly->textureOffset.y = offset.y & ~0x7; tMin.x -= float(offset.x & 0x7); tMin.y -= float(offset.y & 0x7); poly->textureSize.x = int(tMax.x - tMin.x); poly->textureSize.y = int(tMax.y - tMin.y); for (int v = 0; v < poly->vertexList.size(); v++) poly->vertexList[v].texture -= tMin; }
void filter_values::calculate (float freq) { freq = tMax(freq, 0.01f); m_freq = freq; calculate(); }
void ITR3DMImport::boxMap(Poly* poly) { Point2F tMin(+1.0E20f,+1.0E20f); Point2F tMax(-1.0E20f,-1.0E20f); // Select box mapping if (fabs(poly->plane.x) > fabs(poly->plane.y)) poly->boxMapping = (fabs(poly->plane.x) > fabs(poly->plane.z))? MapYZ: MapXY; else poly->boxMapping = (fabs(poly->plane.y) > fabs(poly->plane.z))? MapXZ: MapXY; // Map vertices to box face. for (int i = 0; i < poly->vertexList.size(); i++) { Point3F& tp = poly->vertexList[i].point; Point2F& tv = poly->vertexList[i].texture; switch(poly->boxMapping) { case MapYZ: tv.set(tp.y,-tp.z); break; case MapXY: tv.set(tp.x,-tp.y); break; case MapXZ: tv.set(tp.x,-tp.z); break; } tv *= textureScale; tMin.setMin(tv); tMax.setMax(tv); } // Min/Max must be whole numbers tMin.x = floor(tMin.x); tMin.y = floor(tMin.y); tMax.x = ceil(tMax.x); tMax.y = ceil(tMax.y); poly->textureSize.x = int(tMax.x - tMin.x); poly->textureSize.y = int(tMax.y - tMin.y); // poly->textureOffset.x = int(tMin.x) & MaxTextureMask; poly->textureOffset.y = int(tMin.y) & MaxTextureMask; // Translate coor. so they fit on the texture. for (int v = 0; v < poly->vertexList.size(); v++) poly->vertexList[v].texture -= tMin; }