Skip to content
Snippets Groups Projects
Commit e8ef07c1 authored by Tazpn's avatar Tazpn
Browse files

1. Change strippifcation to use the niflib version on objects.

2. commit fix for bug with transforms.
parent bb244566
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
o Exporter o Exporter
- Replace the Tri Stripper with a new version. - Replace the Tri Stripper with a new version.
o The old version had some bugs which came when compiled with VS 2005. o The old version had some bugs which came when compiled with VS 2005.
- Fix issues with transforms on exporting with extra nodes and for collision meshes
0.2 0.2
----- -----
......
...@@ -294,6 +294,18 @@ static inline Quat TOQUAT(const Niflib::QuaternionXYZW& q, bool inverse = false) ...@@ -294,6 +294,18 @@ static inline Quat TOQUAT(const Niflib::QuaternionXYZW& q, bool inverse = false)
return (inverse) ? qt.Inverse() : qt; return (inverse) ? qt.Inverse() : qt;
} }
static inline Niflib::QuaternionXYZW TOQUATXYZW(const Niflib::Quaternion& q){
Niflib::QuaternionXYZW qt;
qt.x = q.x; qt.y = q.y; qt.z = q.z; qt.w = q.w;
return qt;
}
static inline Niflib::QuaternionXYZW TOQUATXYZW(const Quat& q){
Niflib::QuaternionXYZW qt;
qt.x = q.x; qt.y = q.y; qt.z = q.z; qt.w = q.w;
return qt;
}
static inline AngAxis TOANGAXIS(const Niflib::Quaternion& q, bool inverse = false){ static inline AngAxis TOANGAXIS(const Niflib::Quaternion& q, bool inverse = false){
Quat qt(q.x, q.y, q.z, q.w); Quat qt(q.x, q.y, q.z, q.w);
if (inverse) qt.Invert(); if (inverse) qt.Invert();
......
...@@ -284,6 +284,13 @@ Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node) ...@@ -284,6 +284,13 @@ Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node)
bhkRigidBodyRef body = makeCollisionBody(node); bhkRigidBodyRef body = makeCollisionBody(node);
body->SetShape(DynamicCast<bhkShape>(shape)); body->SetShape(DynamicCast<bhkShape>(shape));
QuaternionXYZW q;
Vector3 trans;
TimeValue t = 0;
nodeTransform(q, trans, node, t, false);
body->SetRotation(q);
body->SetTranslation(trans / 7.0f);
bhkCollisionObjectRef co = DynamicCast<bhkCollisionObject>(CreateBlock("bhkCollisionObject")); bhkCollisionObjectRef co = DynamicCast<bhkCollisionObject>(CreateBlock("bhkCollisionObject"));
co->SetBody(DynamicCast<NiObject>(body)); co->SetBody(DynamicCast<NiObject>(body));
......
...@@ -81,13 +81,11 @@ Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node) ...@@ -81,13 +81,11 @@ Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node)
|| os.obj->ClassID() == Class_ID(BONE_CLASS_ID,0) || os.obj->ClassID() == Class_ID(BONE_CLASS_ID,0)
|| os.obj->ClassID() == Class_ID(0x00009125,0) /* Biped Twist Helpers */ || os.obj->ClassID() == Class_ID(0x00009125,0) /* Biped Twist Helpers */
) )
) )
newParent = makeNode(nodeParent, node, local); {
#ifdef USE_BIPED
else if (os.obj && os.obj->node->ClassID() == BIPED_CLASS_ID)
newParent = makeNode(nodeParent, node, local); newParent = makeNode(nodeParent, node, local);
#endif }
else else
{ {
newParent = (mExportExtraNodes) ? makeNode(nodeParent, node, local) : nodeParent; newParent = (mExportExtraNodes) ? makeNode(nodeParent, node, local) : nodeParent;
...@@ -180,14 +178,12 @@ Exporter::Result Exporter::exportMesh(NiNodeRef &ninode, INode *node, TimeValue ...@@ -180,14 +178,12 @@ Exporter::Result Exporter::exportMesh(NiNodeRef &ninode, INode *node, TimeValue
} }
bool exportStrips = mTriStrips; bool exportStrips = mTriStrips;
// Disable strips if exporting skin nodes, for now Matrix44 tm = Matrix44::IDENTITY;
//if (exportStrips && mExportSkin && GetSkin(node) != NULL) if (!mExportExtraNodes) {
// exportStrips = false; Matrix33 rot; Vector3 trans;
nodeTransform(rot, trans, node, t, local);
tm = Matrix44(trans, rot, 1.0f);
Matrix33 rot; Vector3 trans; }
nodeTransform(rot, trans, node, t, local);
Matrix44 tm(trans, rot, 1.0f);
TSTR basename = node->NodeName(); TSTR basename = node->NodeName();
TSTR format = (!basename.isNull() && grps.size() > 1) ? "%s:%d" : "%s"; TSTR format = (!basename.isNull() && grps.size() > 1) ? "%s:%d" : "%s";
...@@ -223,23 +219,15 @@ NiTriBasedGeomRef Exporter::makeMesh(NiNodeRef &parent, Mtl *mtl, FaceGroup &grp ...@@ -223,23 +219,15 @@ NiTriBasedGeomRef Exporter::makeMesh(NiNodeRef &parent, Mtl *mtl, FaceGroup &grp
NiTriBasedGeomRef shape; NiTriBasedGeomRef shape;
NiTriBasedGeomDataRef data; NiTriBasedGeomDataRef data;
if (exportStrips) if (exportStrips) {
{ shape = new NiTriStrips();
NiTriStripsRef stripsShape = CreateNiObject<NiTriStrips>(); data = new NiTriStripsData();
shape = DynamicCast<NiTriBasedGeom>(stripsShape); } else {
strippify(grp); shape = new NiTriShape();
NiTriStripsDataRef stripData = makeTriStripsData(grp.strips); data = new NiTriShapeData();
data = DynamicCast<NiTriBasedGeomData>(stripData);
} else
{
NiTriShapeRef tris = CreateNiObject<NiTriShape>();
NiTriShapeDataRef triData = CreateNiObject<NiTriShapeData>();
data = DynamicCast<NiTriBasedGeomData>(triData);
shape = DynamicCast<NiTriBasedGeom>(tris);
triData->SetTriangles(grp.faces);
} }
data->SetTriangles(grp.faces);
data->SetVertices(grp.verts); data->SetVertices(grp.verts);
data->SetNormals(grp.vnorms); data->SetNormals(grp.vnorms);
...@@ -370,12 +358,6 @@ struct SkinInstance : public Exporter::NiCallback ...@@ -370,12 +358,6 @@ struct SkinInstance : public Exporter::NiCallback
{ {
typedef vector<SkinWeight> SkinWeightList; typedef vector<SkinWeight> SkinWeightList;
typedef vector<SkinWeightList> BoneWeightList; typedef vector<SkinWeightList> BoneWeightList;
typedef vector<float> WeightList;
typedef vector<ushort> BoneList;
typedef vector<ushort> Strip;
typedef vector<Strip> Strips;
typedef vector<Triangle> Triangles;
Exporter *owner; Exporter *owner;
// Common Data // Common Data
...@@ -385,15 +367,6 @@ struct SkinInstance : public Exporter::NiCallback ...@@ -385,15 +367,6 @@ struct SkinInstance : public Exporter::NiCallback
// Bone to weight map // Bone to weight map
BoneWeightList boneWeights; BoneWeightList boneWeights;
// Partition
int nWeightsPerVertex;
vector<WeightList> vertexWeights;
BoneList boneMap;
vector<ushort> vertexMap;
Strips strips;
vector<BoneList> boneIndexList;
Triangles triangles;
SkinInstance(Exporter *Owner) : owner(Owner) {} SkinInstance(Exporter *Owner) : owner(Owner) {}
virtual ~SkinInstance() {} virtual ~SkinInstance() {}
virtual Exporter::Result execute(); virtual Exporter::Result execute();
...@@ -429,44 +402,21 @@ bool Exporter::makeSkin(NiTriBasedGeomRef shape, INode *node, FaceGroup &grp, Ti ...@@ -429,44 +402,21 @@ bool Exporter::makeSkin(NiTriBasedGeomRef shape, INode *node, FaceGroup &grp, Ti
mPostExportCallbacks.push_back(si); mPostExportCallbacks.push_back(si);
si->shape = shape; si->shape = shape;
for (TriStrips::iterator strip = grp.strips.begin(); strip != grp.strips.end(); ++strip)
si->strips.push_back(*strip);
// Get number of weights per vertex
int nWeightsPerVertex = 4;
Interval ivalid;
IParamBlock2 *params = mod->GetParamBlockByID(2/*advanced*/);
params->GetValue(0x7/*bone_Limit*/, 0, nWeightsPerVertex, ivalid);
si->nWeightsPerVertex = nWeightsPerVertex;
// Get bone references (may not actually exist in proper structure at this time) // Get bone references (may not actually exist in proper structure at this time)
int totalBones = skin->GetNumBones(); int totalBones = skin->GetNumBones();
si->boneWeights.resize(totalBones); si->boneWeights.resize(totalBones);
si->boneList.resize(totalBones); si->boneList.resize(totalBones);
si->boneMap.resize(totalBones);
for (int i=0; i<totalBones; ++i) { for (int i=0; i<totalBones; ++i) {
string name = skin->GetBone(i)->GetName(); string name = skin->GetBone(i)->GetName();
si->boneList[i] = getNode(name); si->boneList[i] = getNode(name);
si->boneMap[i] = i;
} }
vector<int>& vidx = grp.vidx; vector<int>& vidx = grp.vidx;
vector<Vector3>& verts = grp.verts;
int nv = vidx.size(); int nv = vidx.size();
si->vertexMap.resize(nv);
si->vertexWeights.resize(nv);
si->boneIndexList.resize(nv);
for (int i=0; i<nv; ++i) for (int i=0; i<nv; ++i)
{ {
SkinInstance::WeightList& vertexWeights = si->vertexWeights[i];
SkinInstance::BoneList& boneIndexList = si->boneIndexList[i];
vertexWeights.assign(nWeightsPerVertex, 0.0f);
boneIndexList.resize(nWeightsPerVertex, 0);
si->vertexMap[i] = i;
int vi = vidx[i]; int vi = vidx[i];
Vector3& vert = verts[i];
int nbones = skinData->GetNumAssignedBones(vi); int nbones = skinData->GetNumAssignedBones(vi);
for (int j=0; j<nbones; ++j) for (int j=0; j<nbones; ++j)
{ {
...@@ -477,9 +427,6 @@ bool Exporter::makeSkin(NiTriBasedGeomRef shape, INode *node, FaceGroup &grp, Ti ...@@ -477,9 +427,6 @@ bool Exporter::makeSkin(NiTriBasedGeomRef shape, INode *node, FaceGroup &grp, Ti
SkinInstance::SkinWeightList& weights = si->boneWeights[boneIndex]; SkinInstance::SkinWeightList& weights = si->boneWeights[boneIndex];
weights.push_back(sw); weights.push_back(sw);
boneIndexList[j] = boneIndex;
vertexWeights[j] = sw.weight;
} }
} }
return true; return true;
...@@ -499,29 +446,7 @@ Exporter::Result SkinInstance::execute() ...@@ -499,29 +446,7 @@ Exporter::Result SkinInstance::execute()
else else
shape->SetBoneWeights(bone, emptyweights); shape->SetBoneWeights(bone, emptyweights);
} }
shape->GenHardwareSkinInfo();
NiSkinInstanceRef skin = shape->GetSkinInstance();
NiSkinPartitionRef partition = CreateNiObject<NiSkinPartition>();
partition->SetNumPartitions(1);
partition->SetWeightsPerVertex(0, nWeightsPerVertex);
partition->SetBoneMap(0, boneMap);
partition->SetNumVertices(0, ushort(vertexMap.size()) );
partition->SetVertexMap(0, vertexMap);
partition->EnableVertexWeights(0, true);
for (int i=0; i<vertexWeights.size(); ++i) {
partition->SetVertexWeights(0, i, vertexWeights[i]);
}
//partition->SetTriangles()
partition->SetStripCount(0, ushort(strips.size()) );
for (int i=0; i<strips.size(); ++i) {
partition->SetStrip(0, i, strips[i]);
}
partition->EnableVertexBoneIndices(0, true);
for (int i=0; i<boneIndexList.size(); ++i) {
partition->SetVertexBoneIndices(0, i, boneIndexList[i]);
}
skin->SetSkinPartition(partition);
return Exporter::Ok; return Exporter::Ok;
} }
...@@ -89,12 +89,12 @@ BEGIN ...@@ -89,12 +89,12 @@ BEGIN
CONTROL "&Lights",IDC_CHK_LIGHTS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,14,89,67,10 CONTROL "&Lights",IDC_CHK_LIGHTS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,14,89,67,10
GROUPBOX "Behaviors:",IDC_STATIC,94,6,101,97 GROUPBOX "Behaviors:",IDC_STATIC,94,6,101,97
CONTROL "Generate &Strips",IDC_CHK_STRIPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,17,88,10 CONTROL "Generate &Strips",IDC_CHK_STRIPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,17,88,10
CONTROL "&Remap Indices",IDC_CHK_REMAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,29,88,10 CONTROL "&Remap Indices",IDC_CHK_REMAP,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,102,89,88,10
CONTROL "Extra Nodes on Mesh",IDC_CHK_EXTRA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,41,88,11 CONTROL "Extra Nodes on Mesh",IDC_CHK_EXTRA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,28,88,11
CONTROL "Add User Prop Buffer",IDC_CHK_UPB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,53,88,11 CONTROL "Add User Prop Buffer",IDC_CHK_UPB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,40,88,11
CONTROL "Flatten Hierarchy",IDC_CHK_HIER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,65,88,10 CONTROL "Flatten Hierarchy",IDC_CHK_HIER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,52,88,10
CONTROL "Remove Extra Bones",IDC_CHK_REM_BONES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,77,88,10 CONTROL "Remove Extra Bones",IDC_CHK_REM_BONES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,64,88,10
CONTROL "Sort Nodes",IDC_CHK_SORTNODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,89,88,10 CONTROL "Sort Nodes",IDC_CHK_SORTNODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,76,88,10
CONTROL "",IDC_SPIN,"SpinnerControl",NOT WS_VISIBLE,193,7,7,10 CONTROL "",IDC_SPIN,"SpinnerControl",NOT WS_VISIBLE,193,7,7,10
CONTROL "",IDC_EDIT,"CustEdit",NOT WS_VISIBLE | WS_TABSTOP,194,18,6,10 CONTROL "",IDC_EDIT,"CustEdit",NOT WS_VISIBLE | WS_TABSTOP,194,18,6,10
EDITTEXT IDC_ED_WELDTHRESH,189,30,11,12,ES_AUTOHSCROLL | NOT WS_VISIBLE | WS_DISABLED EDITTEXT IDC_ED_WELDTHRESH,189,30,11,12,ES_AUTOHSCROLL | NOT WS_VISIBLE | WS_DISABLED
...@@ -138,8 +138,8 @@ END ...@@ -138,8 +138,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,2,1,0 FILEVERSION 0,2,2,0
PRODUCTVERSION 0,2,1,0 PRODUCTVERSION 0,2,2,0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
...@@ -155,12 +155,12 @@ BEGIN ...@@ -155,12 +155,12 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileDescription", "3ds Max Nif Exporter" VALUE "FileDescription", "3ds Max Nif Exporter"
VALUE "FileVersion", "0, 2, 1, 0" VALUE "FileVersion", "0, 2, 2, 0"
VALUE "InternalName", "NifExport.dle" VALUE "InternalName", "NifExport.dle"
VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved." VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved."
VALUE "OriginalFilename", "NifExport.dle" VALUE "OriginalFilename", "NifExport.dle"
VALUE "ProductName", "3ds Max Nif Exporter" VALUE "ProductName", "3ds Max Nif Exporter"
VALUE "ProductVersion", "0, 2, 1, 0" VALUE "ProductVersion", "0, 2, 2, 0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
...@@ -107,8 +107,8 @@ END ...@@ -107,8 +107,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,2,1,0 FILEVERSION 0,2,2,0
PRODUCTVERSION 0,2,1,0 PRODUCTVERSION 0,2,2,0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
...@@ -124,12 +124,12 @@ BEGIN ...@@ -124,12 +124,12 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileDescription", "3ds Max Nif Furniture Plugin" VALUE "FileDescription", "3ds Max Nif Furniture Plugin"
VALUE "FileVersion", "0, 2, 1, 0" VALUE "FileVersion", "0, 2, 2, 0"
VALUE "InternalName", "NifFurniture.dlu" VALUE "InternalName", "NifFurniture.dlu"
VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved." VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved."
VALUE "OriginalFilename", "NifFurniture.dlu" VALUE "OriginalFilename", "NifFurniture.dlu"
VALUE "ProductName", "3ds Max Nif Furniture Plugin" VALUE "ProductName", "3ds Max Nif Furniture Plugin"
VALUE "ProductVersion", "0, 2, 1, 0" VALUE "ProductVersion", "0, 2, 2, 0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
...@@ -108,8 +108,8 @@ END ...@@ -108,8 +108,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,2,1,0 FILEVERSION 0,2,2,0
PRODUCTVERSION 0,2,1,0 PRODUCTVERSION 0,2,2,0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
...@@ -125,12 +125,12 @@ BEGIN ...@@ -125,12 +125,12 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileDescription", "3ds Max Nif Importer" VALUE "FileDescription", "3ds Max Nif Importer"
VALUE "FileVersion", "0, 2, 1, 0" VALUE "FileVersion", "0, 2, 2, 0"
VALUE "InternalName", "MaxNifImport.dli" VALUE "InternalName", "MaxNifImport.dli"
VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved." VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved."
VALUE "OriginalFilename", "MaxNifImport.dli" VALUE "OriginalFilename", "MaxNifImport.dli"
VALUE "ProductName", "3ds Max Nif Importer" VALUE "ProductName", "3ds Max Nif Importer"
VALUE "ProductVersion", "0, 2, 1, 0" VALUE "ProductVersion", "0, 2, 2, 0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
...@@ -342,8 +342,8 @@ END ...@@ -342,8 +342,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,2,1,0 FILEVERSION 0,2,2,0
PRODUCTVERSION 0,2,1,0 PRODUCTVERSION 0,2,2,0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
...@@ -359,12 +359,12 @@ BEGIN ...@@ -359,12 +359,12 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileDescription", "3ds Max Nif Reactor Properites Plugin" VALUE "FileDescription", "3ds Max Nif Reactor Properites Plugin"
VALUE "FileVersion", "0, 2, 1, 0" VALUE "FileVersion", "0, 2, 2, 0"
VALUE "InternalName", "NifProps.dlu" VALUE "InternalName", "NifProps.dlu"
VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved." VALUE "LegalCopyright", "Copyright (c) 2006, NIF File Format Library and Tools\r\nAll rights reserved."
VALUE "OriginalFilename", "NifProps.dlu" VALUE "OriginalFilename", "NifProps.dlu"
VALUE "ProductName", "3ds Max Nif Reactor Properites Plugin" VALUE "ProductName", "3ds Max Nif Reactor Properites Plugin"
VALUE "ProductVersion", "0, 2, 1, 0" VALUE "ProductVersion", "0, 2, 2, 0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment