MCPcopy Create free account
hub / github.com/assimp/assimp / Execute

Method Execute

code/PostProcessing/TextureTransform.cpp:194–536  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

192
193// ------------------------------------------------------------------------------------------------
194void TextureTransformStep::Execute( aiScene* pScene) {
195 ASSIMP_LOG_DEBUG("TransformUVCoordsProcess begin");
196
197 /* We build a per-mesh list of texture transformations we'll need
198 * to apply. To achieve this, we iterate through all materials,
199 * find all textures and get their transformations and UV indices.
200 * Then we search for all meshes using this material.
201 */
202 typedef std::list<STransformVecInfo> MeshTrafoList;
203 std::vector<MeshTrafoList> meshLists(pScene->mNumMeshes);
204
205 for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
206
207 aiMaterial* mat = pScene->mMaterials[i];
208 for (unsigned int a = 0; a < mat->mNumProperties;++a) {
209
210 aiMaterialProperty* prop = mat->mProperties[a];
211 if (!::strcmp( prop->mKey.data, "$tex.file")) {
212 STransformVecInfo info;
213
214 // Setup a shortcut structure to allow for a fast updating
215 // of the UV index later
216 TTUpdateInfo update;
217 update.mat = (aiMaterial*) mat;
218 update.semantic = prop->mSemantic;
219 update.index = prop->mIndex;
220
221 // Get textured properties and transform
222 for (unsigned int a2 = 0; a2 < mat->mNumProperties;++a2) {
223 aiMaterialProperty* prop2 = mat->mProperties[a2];
224 if (prop2->mSemantic != prop->mSemantic || prop2->mIndex != prop->mIndex) {
225 continue;
226 }
227
228 if ( !::strcmp( prop2->mKey.data, "$tex.uvwsrc")) {
229 info.uvIndex = *((int*)prop2->mData);
230
231 // Store a direct pointer for later use
232 update.directShortcut = (unsigned int*) prop2->mData;
233 }
234
235 else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodeu")) {
236 info.mapU = *((aiTextureMapMode*)prop2->mData);
237 }
238 else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodev")) {
239 info.mapV = *((aiTextureMapMode*)prop2->mData);
240 }
241 else if ( !::strcmp( prop2->mKey.data, "$tex.uvtrafo")) {
242 // ValidateDS should check this
243 ai_assert(prop2->mDataLength >= 20);
244 ::memcpy(&info.mTranslation.x,prop2->mData,sizeof(float)*5);
245
246 // Directly remove this property from the list
247 mat->mNumProperties--;
248 for (unsigned int a3 = a2; a3 < mat->mNumProperties;++a3) {
249 mat->mProperties[a3] = mat->mProperties[a3+1];
250 }
251

Callers

nothing calls this directly

Calls 15

aiVector2DClass · 0.85
UpdateUVIndexFunction · 0.85
ai_snprintfFunction · 0.85
MappingModeToCharFunction · 0.85
GetNumUVChannelsMethod · 0.80
IsUntransformedMethod · 0.80
eraseMethod · 0.80
emplace_backMethod · 0.80
minFunction · 0.70
swapFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected