Custom Animations should now work. We also save color values if there's no texture.

This commit is contained in:
antc13
2016-01-24 13:28:40 +01:00
parent 3baa988ad4
commit b5b1140f5c
11 changed files with 341 additions and 28 deletions
+20 -10
View File
@@ -5,23 +5,30 @@ void Material::grabLambertProperties(MaterialNode& material_node, MFnDependencyN
material_node.Name = node.name().asChar();
if (!findColorTexture(material_node, node)) {
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no color texture. Please apply a texture insted of using a value");
node.findPlug("colorR").getValue(material_node.DiffuseColor[0]);
node.findPlug("colorG").getValue(material_node.DiffuseColor[1]);
node.findPlug("colorB").getValue(material_node.DiffuseColor[2]);
}
if (findIncandescenceTexture(material_node, node)) {
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no Incandescence texture. Please apply a texture insted of using value");
if (!findIncandescenceTexture(material_node, node)) {
node.findPlug("incandescenceR").getValue(material_node.IncandescenceColor[0]);
node.findPlug("incandescenceG").getValue(material_node.IncandescenceColor[1]);
node.findPlug("incandescenceB").getValue(material_node.IncandescenceColor[2]);
}
if (findNormalTexture(material_node, node)) {
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no normal texture. Please apply a texture to it");
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no normal texture.");
}
}
void Material::grabBlinnProperties(MaterialNode& material_node, MFnDependencyNode& node)
{
if (findSpecularTexture(material_node, node)) {
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no specular texture. Please apply a specular to it");
if (!findSpecularTexture(material_node, node)) {
node.findPlug("specularColorR").getValue(material_node.SpecularColor[0]);
node.findPlug("specularColorG").getValue(material_node.SpecularColor[1]);
node.findPlug("specularColorB").getValue(material_node.SpecularColor[2]);
}
m_Plug = node.findPlug("reflectivity");
@@ -43,8 +50,10 @@ void Material::grabBlinnProperties(MaterialNode& material_node, MFnDependencyNod
void Material::grabPhongProperties(MaterialNode& material_node, MFnDependencyNode& node)
{
if (findSpecularTexture(material_node, node)) {
MGlobal::displayWarning(MString() + "Material " + node.name() + " has no specular texture. Please apply a specular to it");
if (!findSpecularTexture(material_node, node)) {
node.findPlug("specularColorR").getValue(material_node.SpecularColor[0]);
node.findPlug("specularColorG").getValue(material_node.SpecularColor[1]);
node.findPlug("specularColorB").getValue(material_node.SpecularColor[2]);
}
m_Plug = node.findPlug("reflectivity");
@@ -188,20 +197,21 @@ std::vector<MaterialNode>* Material::DoIt(Mesh mesh)
// All materials we care about inherit from Lambert
MItDependencyNodes matIt(MFn::kLambert);
m_AllMaterials.clear();
int totalIndices = 0;
while (!matIt.isDone()) {
MFnDependencyNode MaterialFnDN(matIt.thisNode());
MaterialNode MaterialStorage;
bool meshHasMaterial = false;
//Mesh Indices is a map with <string : MaterialName, vector<int> : indices>
int totalIndices = 0;
for (auto aMeshMaterial : mesh.Indices) {
MGlobal::displayInfo(MString() + "Material: " + aMeshMaterial.first.c_str() + " " + MaterialFnDN.name().asChar());
if (aMeshMaterial.first.compare(MaterialFnDN.name().asChar()) == 0) {
meshHasMaterial = true;
MaterialStorage.IndexStart = totalIndices;
MaterialStorage.IndexEnd = totalIndices + aMeshMaterial.second.size() - 1;
totalIndices += aMeshMaterial.second.size();
break;
}
totalIndices += aMeshMaterial.second.size();
}
if (meshHasMaterial) {
grabLambertProperties(MaterialStorage, MaterialFnDN);
@@ -19,15 +19,18 @@ public:
float ReflectionFactor;
float SpecularExponent;
float DiffuseColor[3]{ 1.0f };
unsigned int ColorMapFileLength = 0;
std::string ColorMapFile;
float SpecularColor[3]{ 1.0f };
unsigned int SpecularMapFileLength = 0;
std::string SpecularMapFile;
unsigned int NormalMapFileLength = 0;
std::string NormalMapFile;
float IncandescenceColor[3]{ 1.0f };
unsigned int IncandescenceMapFileLength = 0;
std::string IncandescenceMapFile;
@@ -43,6 +46,9 @@ public:
out.write((char*)&SpecularExponent, sizeof(float));
out.write((char*)&ReflectionFactor, sizeof(float));
out.write((char*)&DiffuseColor, sizeof(float) * 3);
out.write((char*)&SpecularColor, sizeof(float) * 3);
out.write((char*)&IncandescenceColor, sizeof(float) * 3);
out.write((char*)&IndexStart, sizeof(unsigned int));
out.write((char*)&IndexEnd, sizeof(unsigned int));
@@ -64,6 +70,9 @@ public:
out << "SpecularExponent: " << SpecularExponent << endl;
out << "ReflectionFactor: " << ReflectionFactor << endl;
out << "DiffuseColor: " << DiffuseColor[0] << " " << DiffuseColor[1] << " " << DiffuseColor[2] << endl;
out << "SpecularColor: " << SpecularColor[0] << " " << SpecularColor[1] << " " << SpecularColor[2] << endl;
out << "IncandescenceColor: " << IncandescenceColor[0] << " " << IncandescenceColor[1] << " " << IncandescenceColor[2] << endl;
out << "IndexStart: " << IndexStart << endl;
out << "IndexEnd: " << IndexEnd << endl;
+4 -3
View File
@@ -104,9 +104,10 @@ Menu::Menu(QDialog* dialog)
// Set the layout for our window
dialog->setLayout(baseLayout);
for (unsigned int i = 0; i < 3; i++) {
this->AddClipClicked(true);
}
this->AddClipClicked(true);
//for (unsigned int i = 0; i < 3; i++) {
// this->AddClipClicked(true);
//}
}
+12 -2
View File
@@ -309,12 +309,22 @@ Mesh MeshClass::GetMeshData(MObjectArray object)
if (hasSkin) {
float totalWeight = 0.0f;
unsigned int totalBones = 0;
MIntArray jointIDs /* ??? */;
weights.selectAncestorLogicalIndex(vertexIndex, weightListObject);
weights.getExistingArrayAttributeIndices(jointIDs);
for (unsigned int i = 0; i < jointIDs.length() && i < 4; i++) {
thisVertex.BoneIndices[i] = jointIDs[i];
thisVertex.BoneWeights[i] = weights[i].asFloat();
if (weights[i].asFloat() > 0.001f) {
thisVertex.BoneIndices[totalBones] = jointIDs[i];
thisVertex.BoneWeights[totalBones] = weights[i].asFloat();
totalWeight = totalWeight + weights[i].asFloat();
totalBones++;
}
}
for (unsigned int i = 0; i < 4; i++) {
thisVertex.BoneWeights[i] = thisVertex.BoneWeights[i] / totalWeight;
}
}
@@ -25,10 +25,13 @@ bool WriteToFile::ASCIIFilePath(string filePathAndFileName)
void WriteToFile::OpenFiles()
{
if (binFile)
binFile.open(binFileName, ofstream::binary);
if (ASCIIFile)
if (binFile) {
binFile.open(binFileName, ofstream::binary);
}
if (ASCIIFile){
ASCIIFile.open(ASCIIFileName);
ASCIIFile << std::fixed << std::setprecision(3);
}
}
void WriteToFile::CloseFiles()
@@ -5,6 +5,7 @@
#include "OutputData.h"
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;