Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading FO4 textures into UV editor. #120

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions src/ui/widgets/uvedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "message.h"
#include "nifskope.h"
#include "io/material.h"
#include "gl/gltex.h"
#include "gl/gltools.h"
#include "model/nifmodel.h"
Expand Down Expand Up @@ -920,19 +921,32 @@ bool UVWidget::setNifData( NifModel * nifModel, const QModelIndex & nifIndex )
iTexProp = nif->getBlock( l, "BSLightingShaderProperty" );

if ( iTexProp.isValid() ) {
QModelIndex iTexSource = nif->getBlock( nif->getLink( iTexProp, "Texture Set" ) );

if ( iTexSource.isValid() ) {
// Assume that a FO3 mesh never has embedded textures...
//texsource = iTexSource;
//return true;
QModelIndex iTextures = nif->getIndex( iTexSource, "Textures" );

if ( iTextures.isValid() ) {
texfile = TexCache::find( nif->get<QString>( iTextures.child( 0, 0 ) ), nif->getFolder() );
return true;
// FO4 BGSM
// Check it first because FO4 BSLightingShaderProperty
// usually also has "Texture Set" node
// with textures not blank sometimes.
QString name = nif->get<QString>( iTexProp, "Name" );
if ( name.endsWith( ".bgsm", Qt::CaseInsensitive ) ) {
QScopedPointer<Material> mat( new ShaderMaterial(name) );
if ( mat && mat->isValid() ) {
texfile = TexCache::find( mat->textures()[0], nif->getFolder() );
return true;
}
} else {
QModelIndex iTexSource = nif->getBlock( nif->getLink( iTexProp, "Texture Set" ) );

if ( iTexSource.isValid() ) {
// Assume that a FO3 mesh never has embedded textures...
//texsource = iTexSource;
//return true;
QModelIndex iTextures = nif->getIndex( iTexSource, "Textures" );

if ( iTextures.isValid() ) {
texfile = TexCache::find( nif->get<QString>( iTextures.child( 0, 0 ) ), nif->getFolder() );
return true;
}
}
}
}
} else {
iTexProp = nif->getBlock( l, "BSEffectShaderProperty" );

Expand Down