| 265 | } |
| 266 | |
| 267 | void LocalFileFormat::bake(const Baker & baker, |
| 268 | const std::string & formatName, |
| 269 | std::ostream & ostream) const |
| 270 | { |
| 271 | |
| 272 | static const int DEFAULT_CUBE_SIZE = 32; |
| 273 | |
| 274 | if(formatName != "spi3d") |
| 275 | { |
| 276 | std::ostringstream os; |
| 277 | os << "Unknown spi format name, '"; |
| 278 | os << formatName << "'."; |
| 279 | throw Exception(os.str().c_str()); |
| 280 | } |
| 281 | |
| 282 | ConstConfigRcPtr config = baker.getConfig(); |
| 283 | |
| 284 | int cubeSize = baker.getCubeSize(); |
| 285 | if(cubeSize==-1) cubeSize = DEFAULT_CUBE_SIZE; |
| 286 | cubeSize = std::max(2, cubeSize); // smallest cube is 2x2x2 |
| 287 | |
| 288 | std::vector<float> cubeData; |
| 289 | cubeData.resize(cubeSize*cubeSize*cubeSize*3); |
| 290 | GenerateIdentityLut3D(&cubeData[0], cubeSize, 3, LUT3DORDER_FAST_BLUE); |
| 291 | PackedImageDesc cubeImg(&cubeData[0], cubeSize*cubeSize*cubeSize, 1, 3); |
| 292 | ConstCPUProcessorRcPtr inputToTarget = GetInputToTargetProcessor(baker); |
| 293 | inputToTarget->apply(cubeImg); |
| 294 | |
| 295 | ostream << "SPILUT 1.0\n"; |
| 296 | ostream << "3 3\n"; |
| 297 | ostream << cubeSize << " " << cubeSize << " " << cubeSize << "\n"; |
| 298 | |
| 299 | // Set to a fixed 6 decimal precision |
| 300 | ostream.setf(std::ios::fixed, std::ios::floatfield); |
| 301 | ostream.precision(6); |
| 302 | for(int i=0; i<cubeSize*cubeSize*cubeSize; ++i) |
| 303 | { |
| 304 | ostream << ((i / cubeSize) / cubeSize) % cubeSize << " " |
| 305 | << (i / cubeSize) % cubeSize << " " |
| 306 | << i % cubeSize << " " |
| 307 | << cubeData[3*i+0] << " " |
| 308 | << cubeData[3*i+1] << " " |
| 309 | << cubeData[3*i+2] << "\n"; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | void LocalFileFormat::buildFileOps(OpRcPtrVec & ops, |
| 314 | const Config & /*config*/, |
nothing calls this directly
no test coverage detected