| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 String *error_messages) { | 87 String *error_messages) { |
| 88 // Create a service locator and renderer. | 88 // Create a service locator and renderer. |
| 89 ServiceLocator service_locator; | 89 ServiceLocator service_locator; |
| 90 EvaluationCounter evaluation_counter(&service_locator); | 90 EvaluationCounter evaluation_counter(&service_locator); |
| 91 ClassManager class_manager(&service_locator); | 91 ClassManager class_manager(&service_locator); |
| 92 ObjectManager object_manager(&service_locator); | 92 ObjectManager object_manager(&service_locator); |
| 93 Profiler profiler(&service_locator); | 93 Profiler profiler(&service_locator); |
| 94 ErrorStatus error_status(&service_locator); | 94 ErrorStatus error_status(&service_locator); |
| 95 Features features(&service_locator); | 95 Features features(&service_locator); |
| 96 | 96 |
| 97 Collada::Init(&service_locator); |
| 97 features.Init("MaxCapabilities"); | 98 features.Init("MaxCapabilities"); |
| 98 | 99 |
| 99 // Collect error messages. | 100 // Collect error messages. |
| 100 ErrorCollector error_collector(&service_locator); | 101 ErrorCollector error_collector(&service_locator); |
| 101 | 102 |
| 102 scoped_ptr<Renderer> renderer( | 103 scoped_ptr<Renderer> renderer( |
| 103 Renderer::CreateDefaultRenderer(&service_locator)); | 104 Renderer::CreateDefaultRenderer(&service_locator)); |
| 104 renderer->InitCommon(); | 105 renderer->InitCommon(); |
| 105 | 106 |
| 106 Pack::Ref pack(object_manager.CreatePack()); | 107 Pack::Ref pack(object_manager.CreatePack()); |
| 107 Transform* root = pack->Create<Transform>(); | 108 Transform* root = pack->Create<Transform>(); |
| 108 root->set_name(String(Serializer::ROOT_PREFIX) + String("root")); | 109 root->set_name(String(Serializer::ROOT_PREFIX) + String("root")); |
| 109 | 110 |
| 110 // Setup a ParamFloat to be the source to all animations in this file. | 111 // Setup a ParamFloat to be the source to all animations in this file. |
| 111 ParamObject* param_object = pack->Create<ParamObject>(); | 112 ParamObject* param_object = pack->Create<ParamObject>(); |
| 112 // This is some arbitrary name | 113 // This is some arbitrary name |
| 113 param_object->set_name(O3D_STRING_CONSTANT("animSourceOwner")); | 114 param_object->set_name(O3D_STRING_CONSTANT("animSourceOwner")); |
| 114 ParamFloat* param_float = param_object->CreateParam<ParamFloat>("animSource"); | 115 ParamFloat* param_float = param_object->CreateParam<ParamFloat>("animSource"); |
| 115 | 116 |
| 116 Collada::Options collada_options; | 117 Collada::Options collada_options; |
| 117 collada_options.condition_document = options.condition; | 118 collada_options.condition_document = options.condition; |
| 118 collada_options.keep_original_data = true; | 119 collada_options.keep_original_data = true; |
| 119 collada_options.base_path = options.base_path; | 120 collada_options.base_path = options.base_path; |
| 120 collada_options.up_axis = options.up_axis; | 121 collada_options.up_axis = options.up_axis; |
| 121 Collada collada(pack.Get(), collada_options); | 122 Collada collada(pack.Get(), collada_options); |
| 122 if (!collada.ImportFile(in_filename, root, param_float)) { | 123 bool result = collada.ImportFile(in_filename, root, param_float); |
| 124 if (!result || !error_collector.errors().empty()) { |
| 123 if (error_messages) { | 125 if (error_messages) { |
| 124 *error_messages += error_collector.errors(); | 126 *error_messages += error_collector.errors(); |
| 125 } | 127 } |
| 126 return false; | 128 return false; |
| 127 } | 129 } |
| 128 | 130 |
| 129 // Remove the animation param_object (and indirectly the param_float) | 131 // Remove the animation param_object (and indirectly the param_float) |
| 130 // if there is no animation. | 132 // if there is no animation. |
| 131 if (param_float->output_connections().empty()) { | 133 if (param_float->output_connections().empty()) { |
| 132 pack->RemoveObject(param_object); | 134 pack->RemoveObject(param_object); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 << FilePathToUTF8(in_filename).c_str() << "'"; | 377 << FilePathToUTF8(in_filename).c_str() << "'"; |
| 376 } | 378 } |
| 377 } | 379 } |
| 378 if (error_messages) { | 380 if (error_messages) { |
| 379 *error_messages = error_collector.errors(); | 381 *error_messages = error_collector.errors(); |
| 380 } | 382 } |
| 381 return true; | 383 return true; |
| 382 } | 384 } |
| 383 } // end namespace converter | 385 } // end namespace converter |
| 384 } // end namespace o3d | 386 } // end namespace o3d |
| OLD | NEW |