Skip to content
Snippets Groups Projects
Commit 029290cd authored by Gundalf's avatar Gundalf
Browse files

Vertex Colors

parent 25d8fd35
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ void Exporter::writeConfig()
regSet(hKey, "npx_furn", mExportFurn);
regSet(hKey, "npx_lights", mExportLights);
regSet(hKey, "npx_vcolors", mVertexColors);
regSet(hKey, "npx_wthresh", mWeldThresh);
// regSet(hKey, "npx_wthresh", mWeldThresh);
regSet(hKey, "npx_tprefix", mTexPrefix);
regSet(hKey, "npx_coll", mExportCollision);
}
......@@ -52,7 +52,7 @@ void Exporter::readConfig()
regGet(hKey, "npx_furn", mExportFurn);
regGet(hKey, "npx_lights", mExportLights);
regGet(hKey, "npx_vcolors", mVertexColors);
regGet(hKey, "npx_wthresh", mWeldThresh);
// regGet(hKey, "npx_wthresh", mWeldThresh);
regGet(hKey, "npx_tprefix", mTexPrefix);
regGet(hKey, "npx_coll", mExportCollision);
}
......
......@@ -90,7 +90,7 @@ private:
/* mesh export */
// adds a vertex to a face group if it doesn't exist yet. returns new or previous index into the
// vertex array.
int addVertex(FaceGroup &grp, const Point3 &pt, const Point3 &uv, const Point3 &norm);
int addVertex(FaceGroup &grp, int face, int vi, Mesh *mesh);
// adds a face to a face group
void addFace(FaceGroup &grp, int face, const int vi[3], Mesh *mesh);
// returns true if at least one of the colors in the group has a value != (1, 1, 1, 1)
......
......@@ -97,6 +97,9 @@ bool Exporter::makeMesh(NiNodeRef &parent, Mtl *mtl, FaceGroup &grp)
data->SetUVSetCount(1);
data->SetUVSet(0, grp.uvs);
if (grp.vcolors.size() > 0)
data->SetVertexColors(grp.vcolors);
shape->SetData(data);
NiAVObjectRef av(DynamicCast<NiAVObject>(shape));
......@@ -108,20 +111,39 @@ bool Exporter::makeMesh(NiNodeRef &parent, Mtl *mtl, FaceGroup &grp)
return true;
}
int Exporter::addVertex(FaceGroup &grp, const Point3 &pt, const Point3 &uv, const Point3 &norm)
int Exporter::addVertex(FaceGroup &grp, int face, int vi, Mesh *mesh)
{
Point3 pt = mesh->verts[ mesh->faces[ face ].v[ vi ] ];
Point3 uv = mesh->tVerts[ mesh->tvFace[ face ].t[ vi ]];
Point3 norm = getVertexNormal(mesh, face, mesh->getRVertPtr(mesh->faces[ face ].v[ vi ]));
VertColor col;
if (mVertexColors && mesh->vertCol)
col = mesh->vertCol[ mesh->vcFace[ face ].t[ vi ] ];
for (int i=0; i<grp.verts.size(); i++)
{
if (equal(grp.verts[i], pt, mWeldThresh) &&
grp.uvs[i].u==uv.x && grp.uvs[i].v==uv.y &&
equal(grp.vnorms[i], norm, 0))
{
if (mVertexColors && mesh->vertCol &&
(grp.vcolors[i].r!=col.x ||
grp.vcolors[i].g!=col.y ||
grp.vcolors[i].b!=col.z))
continue;
return i;
}
}
grp.verts.push_back(Vector3(pt.x, pt.y, pt.z));
grp.uvs.push_back(TexCoord(uv.x, uv.y));
grp.vnorms.push_back(Vector3(norm.x, norm.y, norm.z));
if (mVertexColors && mesh->vertCol)
grp.vcolors.push_back(Color4(col.x, col.y, col.z, 1));
return grp.verts.size()-1;
}
......@@ -130,11 +152,13 @@ void Exporter::addFace(FaceGroup &grp, int face, const int vi[3], Mesh *mesh)
Triangle tri;
for (int i=0; i<3; i++)
{
Point3 tv = mesh->verts[ mesh->faces[ face ].v[ vi[i] ] ]; // * tm;
/* Point3 tv = mesh->verts[ mesh->faces[ face ].v[ vi[i] ] ]; // * tm;
tri[i] = addVertex(grp,
tv,
mesh->tVerts[ mesh->tvFace[ face ].t[ vi[i] ]],
getVertexNormal(mesh, face, mesh->getRVertPtr(mesh->faces[ face ].v[ vi[i] ])));
*/
tri[i] = addVertex(grp, face, vi[i], mesh);
}
grp.faces.push_back(tri);
......
......@@ -102,7 +102,7 @@ BEGIN
CONTROL "Export Co&llision",IDC_CHK_COLL,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,85,18,68,10
CONTROL "&Vertex Colors",IDC_CHK_VCOLORS,"Button",
BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,85,31,68,10
BS_AUTOCHECKBOX | WS_TABSTOP,85,31,68,10
LTEXT "http://niftools.sourceforge.net",IDC_LBL_LINK,98,87,95,
14,SS_NOTIFY | SS_CENTERIMAGE
END
......
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