| 226 | } |
| 227 | |
| 228 | bool loadRAWfile(const char* filename, RAWImportCallback& cb, PxReal scale) |
| 229 | { |
| 230 | File* fp = NULL; |
| 231 | PxToolkit::fopen_s(&fp, filename, "rb"); |
| 232 | if(!fp) |
| 233 | return false; |
| 234 | |
| 235 | // General info |
| 236 | const PxU32 tag = read32(fp); |
| 237 | const PxU32 generalVersion = read32(fp); |
| 238 | const PxU32 nbMaterials = read32(fp); |
| 239 | const PxU32 nbTextures = read32(fp); |
| 240 | const PxU32 nbMeshes = read32(fp); |
| 241 | const PxU32 nbShapes = read32(fp); |
| 242 | const PxU32 nbHelpers = read32(fp); |
| 243 | |
| 244 | (void)tag; |
| 245 | (void)generalVersion; |
| 246 | char objectName[512]; |
| 247 | |
| 248 | // Textures |
| 249 | for(PxU32 i=0;i<nbTextures;i++) |
| 250 | { |
| 251 | RAWTexture data; |
| 252 | |
| 253 | readName(fp, objectName); |
| 254 | data.mName = objectName; |
| 255 | data.mTransform = PxTransform(PxIdentity); // PT: texture transform not supported yet |
| 256 | data.mID = read32(fp); |
| 257 | |
| 258 | RendererColorAlloc* pixels = NULL; |
| 259 | if(read8(fp)) |
| 260 | { |
| 261 | data.mWidth = read32(fp); |
| 262 | data.mHeight = read32(fp); |
| 263 | data.mHasAlpha = read8(fp)!=0; |
| 264 | const PxU32 nbPixels = data.mWidth*data.mHeight; |
| 265 | pixels = SAMPLE_NEW(RendererColorAlloc)[nbPixels]; |
| 266 | data.mPixels = pixels; |
| 267 | for(PxU32 i=0;i<nbPixels;i++) |
| 268 | { |
| 269 | pixels[i].r = read8(fp); |
| 270 | pixels[i].g = read8(fp); |
| 271 | pixels[i].b = read8(fp); |
| 272 | if(data.mHasAlpha) |
| 273 | pixels[i].a = read8(fp); |
| 274 | else |
| 275 | pixels[i].a = 0xff; |
| 276 | } |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | data.mWidth = 0; |
| 281 | data.mHeight = 0; |
| 282 | data.mHasAlpha = false; |
| 283 | data.mPixels = NULL; |
| 284 | } |
| 285 |
no test coverage detected