MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / loadRAWfile

Function loadRAWfile

physx/samples/samplebase/RawLoader.cpp:228–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool 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

Callers 1

importRAWFileMethod · 0.70

Calls 15

read32Function · 0.70
readNameFunction · 0.70
read8Function · 0.70
readFloatFunction · 0.70
readTransformFunction · 0.70
readVerticesFunction · 0.70
readNormalsFunction · 0.70
readVertexColorsFunction · 0.70
readUVsFunction · 0.70
FlipFunction · 0.70
fopen_sFunction · 0.50
PxTransformClass · 0.50

Tested by

no test coverage detected