From 9b75b5aa0cc569790d101c5bfc37a02ff6aa3f78 Mon Sep 17 00:00:00 2001 From: Alecu100 <lui_alecu@yahoo.co.uk> Date: Wed, 8 Feb 2012 04:40:16 +0200 Subject: [PATCH] fixed a bug in the complex shape because of which normals weren't imported into maya --- include/ComplexShape.h | 5 +---- src/ComplexShape.cpp | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/include/ComplexShape.h b/include/ComplexShape.h index 455e971c..47c2711a 100644 --- a/include/ComplexShape.h +++ b/include/ComplexShape.h @@ -5,11 +5,9 @@ All rights reserved. Please see niflib.h for license. */ #define _COMPLEX_SHAPE_H_ #include "Ref.h" -#include "obj/BSDismemberSkinInstance.h" -#include "obj/NiSkinPartition.h" #include "nif_math.h" #include "nif_basic_types.h" -#include "gen/BodyPartList.h" +#include "../include/obj/BSDismemberSkinInstance.h" #include <vector> namespace Niflib { @@ -21,7 +19,6 @@ class NiProperty; class NiNode; class NiAVObject; class NiTriBasedGeom; -class BSDismemberSkinInstance; class NiSkinPartition; /*! Marks empty data indices */ diff --git a/src/ComplexShape.cpp b/src/ComplexShape.cpp index b2988dac..b7b3b6ff 100644 --- a/src/ComplexShape.cpp +++ b/src/ComplexShape.cpp @@ -15,9 +15,16 @@ All rights reserved. Please see niflib.h for license. */ #include "../include/obj/NiSkinData.h" #include "../include/obj/NiTextureProperty.h" #include "../include/gen/SkinWeight.h" +#include "../include/obj/NiSkinPartition.h" +#include "../include/gen/BodyPartList.h" +#include "../include/obj/BSShaderTextureSet.h" +#include "../include/obj/BSLightingShaderProperty.h" #include <stdlib.h> + + + using namespace Niflib; //Wrape these in the Niflib namespace so they don't polute the Class View @@ -379,13 +386,32 @@ void ComplexShape::Merge( NiAVObject * root ) { if ( niProp != NULL ) { niTexProp = DynamicCast<NiTextureProperty>(niProp); } + BSShaderTextureSetRef bsTexProp = NULL; + niProp = (*geom)->GetPropertyByType(BSShaderTextureSet::TYPE); + if(niProp != NULL) { + bsTexProp = DynamicCast<BSShaderTextureSet>(niProp); + } + niProp = (*geom)->getBsProperties()[0]; + if(niProp != NULL && niProp->GetType().IsSameType(BSLightingShaderProperty::TYPE)) { + BSLightingShaderPropertyRef bs_shader = DynamicCast<BSLightingShaderProperty>(niProp); + if(bs_shader->getTextureSet() != NULL) { + bsTexProp = bs_shader->getTextureSet(); + } + } + niProp = (*geom)->getBsProperties()[1]; + if(niProp != NULL && niProp->GetType().IsSameType(BSLightingShaderProperty::TYPE)) { + BSLightingShaderPropertyRef bs_shader = DynamicCast<BSLightingShaderProperty>(niProp); + if(bs_shader->getTextureSet() != NULL) { + bsTexProp = bs_shader->getTextureSet(); + } + } //Create a list of UV sets to check //pair.first = Texture Type //pair.second = UV Set ID vector< pair<TexType, unsigned int> > uvSets; - if ( shapeUVs.size() != 0 && (niTexingProp != NULL || niTexProp != NULL) ) { + if ( shapeUVs.size() != 0 && (niTexingProp != NULL || niTexProp != NULL || bsTexProp != NULL) ) { if ( niTexingProp != NULL ) { //Add the UV set to the list for every type of texture slot that uses it for ( int tex = 0; tex < 8; ++tex ) { @@ -396,7 +422,7 @@ void ComplexShape::Merge( NiAVObject * root ) { uvSets.push_back( pair<TexType, unsigned int>( TexType(tex), td.uvSet ) ); } } - } else if ( niTexProp != NULL ) { + } else if ( niTexProp != NULL || bsTexProp != NULL ) { //Add the base UV set to the list and just use zero. uvSets.push_back( pair<TexType, unsigned int>( BASE_MAP, 0 ) ); } @@ -619,6 +645,10 @@ void ComplexShape::Merge( NiAVObject * root ) { } } } + + for(int x = 0; x < current_body_parts_faces.size(); x++) { + dismemberPartitionsFaces.push_back(current_body_parts_faces[x]); + } } } -- GitLab