void animateMaterials(MMesh * mesh, MMaterialsAnim * materialsAnim, float t) { M_PROFILE_SCOPE(animateMaterials); MMaterialAnim * matAnim = materialsAnim->getMaterialsAnim(); float opacity; float shininess; float customValue; MVector3 diffuse; MVector3 specular; MVector3 emit; MVector3 customColor; unsigned int m; unsigned int mSize = materialsAnim->getMaterialsAnimNumber(); for (m = 0; m < mSize; m++) { MMaterial * material = mesh->getMaterial(m); // opacity if(animateFloat(matAnim->getOpacityKeys(), matAnim->getOpacityKeysNumber(), t, &opacity)) material->setOpacity(opacity); // shininess if(animateFloat(matAnim->getShininessKeys(), matAnim->getShininessKeysNumber(), t, &shininess)) material->setShininess(shininess); // customValue if(animateFloat(matAnim->getCustomValueKeys(), matAnim->getCustomValueKeysNumber(), t, &customValue)) material->setCustomValue(customValue); // diffuse if(animateVector3(matAnim->getDiffuseKeys(), matAnim->getDiffuseKeysNumber(), t, &diffuse)) material->setDiffuse(diffuse); // specular if(animateVector3(matAnim->getSpecularKeys(), matAnim->getSpecularKeysNumber(), t, &specular)) material->setSpecular(specular); // emit if(animateVector3(matAnim->getEmitKeys(), matAnim->getEmitKeysNumber(), t, &emit)) material->setEmit(emit); // customColor if(animateVector3(matAnim->getCustomColorKeys(), matAnim->getCustomColorKeysNumber(), t, &customColor)) material->setCustomColor(customColor); matAnim++; } }
void animateTextures(MMesh * mesh, MTexturesAnim * texturesAnim, float t) { MTextureAnim * texAnim = texturesAnim->getTexturesAnim(); float rotation; MVector2 translate; MVector2 scale; unsigned int tex; unsigned int texSize = texturesAnim->getTexturesAnimNumber(); for (tex = 0; tex < texSize; tex++) { MTexture * texture = mesh->getTexture(tex); // rotation if(animateFloat(texAnim->getRotationKeys(), texAnim->getRotationKeysNumber(), t, &rotation)) texture->setTexRotate(rotation); // translate if(animateVector2(texAnim->getTranslateKeys(), texAnim->getTranslateKeysNumber(), t, &translate)) texture->setTexTranslate(translate); // scale if(animateVector2(texAnim->getScaleKeys(), texAnim->getScaleKeysNumber(), t, &scale)) texture->setTexScale(scale); texAnim++; } }