Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) setup3dObjectsWithThread
- {
- /*
- dispatch_queue_t queue = dispatch_queue_create("", NULL);
- dispatch_async(queue, ^{
- //code to be executed in the background
- NSString* dataPath = [[NSBundle mainBundle] resourcePath];
- NSString * m1 = @"Apple.3ds";
- model1 = new REVuModel([dataPath UTF8String], [m1 UTF8String]) ;
- if(model1->isValid)
- {
- model1->TranslateTo(0, 0, 0);
- model1->ScaleUniformTo(0.4);
- model1->RotateTo(0, 0, 0);
- model1->Alpha(1.0);
- model1->SwitchLight(true);
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- //code to be executed on the main thread when background task is finished
- NSLog(@"Ending Point of loading models %@ and start of main_queue", queue);
- });
- });*/
- NSThread* myThread = [[NSThread alloc] initWithTarget:self
- selector:@selector(myThread_MainMethod:)
- object:nil];
- [myThread start];
- }
- -(void) myThread_MainMethod:(id)sender
- {
- NSString* dataPath = [[NSBundle mainBundle] resourcePath];
- NSString * m1 = @"Apple.3ds";
- model1 = new REVuModel([dataPath UTF8String], [m1 UTF8String]) ;
- if(model1->isValid)
- {
- model1->TranslateTo(0, 0, 0);
- model1->ScaleUniformTo(0.4);
- model1->RotateTo(0, 0, 0);
- model1->Alpha(1.0);
- model1->SwitchLight(true);
- }
- }
- REVuModel::REVuModel(const char *dataPath, const char * modelName)
- {
- rootPath.Set(dataPath);
- rootPath.Append("/");
- aiString modelPath = rootPath;
- modelPath.Append("/");
- modelPath.Append(modelName);
- scene = NULL;
- isValid = false;
- //DEFAULTS
- _scale = vec3(1.0 , 1.0, 1.0);
- _position = vec3(0.0, 0.0, 0.0);
- _rotation = vec3(kInitalRoation, 0.0, 0.0);
- _lightDirection = vec3(0.0, 0., -1.0); //FRONT & ABOVE
- _alpha =1.0;
- _customTexture = false;
- _customMaterial = false;
- Assimp::Importer* importer = new Assimp::Importer();
- printf("\nASSIMP Version %i.%i.%i\n", aiGetVersionMajor(), aiGetVersionMinor(),aiGetVersionRevision());
- //printf("FREEIMAGE Version %s \n\n", FreeImage_GetVersion());
- scene = importer->ReadFile(modelPath.data,aiProcessPreset_TargetRealtime_MaxQuality);
- if(!scene || !initShaders())
- {
- isValid = false;
- printf("nASSIMP model loader: failed to load %s \n\n", modelName);
- }
- else
- {
- aiVector3D scene_min, scene_max;
- getBoundingBoxWithMinVector(&scene_min, &scene_max);
- normalizedScale = scene_max.x-scene_min.x;
- normalizedScale = aisgl_max(scene_max.y - scene_min.y,normalizedScale);
- normalizedScale = aisgl_max(scene_max.z - scene_min.z,normalizedScale);
- normalizedScale = 1.f / normalizedScale * 255; //????
- _scale = vec3(normalizedScale , normalizedScale, normalizedScale);
- loadGLResources();
- isValid = true;
- printf("nASSIMP model loader: %s loaded \n\n", modelName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement