From 4e535c110293b527fe112c8e52a76ed5f3660145 Mon Sep 17 00:00:00 2001 From: antc13 Date: Tue, 15 Dec 2015 15:24:46 +0100 Subject: [PATCH] =?UTF-8?q?File=20Writer=20WIP.=20Rework=20soon=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MayaExporter/MayaExporter.vcxproj | 2 + .../MayaExporter/MayaExporter.vcxproj.filters | 6 ++ tools/MayaExporter/MayaExporter/Menu.h | 1 + tools/MayaExporter/MayaExporter/Var.cpp | 70 +++++++++++++++++++ tools/MayaExporter/MayaExporter/Var.h | 32 +++++++++ 5 files changed, 111 insertions(+) create mode 100644 tools/MayaExporter/MayaExporter/Var.cpp create mode 100644 tools/MayaExporter/MayaExporter/Var.h diff --git a/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj b/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj index 50577919..b04d032f 100644 --- a/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj +++ b/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj @@ -175,6 +175,7 @@ + @@ -199,6 +200,7 @@ + Moc%27ing Menu.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp diff --git a/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj.filters b/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj.filters index cf4a5a35..6f836155 100644 --- a/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj.filters +++ b/tools/MayaExporter/MayaExporter/MayaExporter.vcxproj.filters @@ -59,6 +59,9 @@ Source Files + + Source Files + @@ -87,5 +90,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/tools/MayaExporter/MayaExporter/Menu.h b/tools/MayaExporter/MayaExporter/Menu.h index 6f766025..bf77e59f 100644 --- a/tools/MayaExporter/MayaExporter/Menu.h +++ b/tools/MayaExporter/MayaExporter/Menu.h @@ -33,6 +33,7 @@ #include "MayaIncludes.h" #include "Material.h" #include "Mesh.h" +#include "Var.h" class Menu : public QWidget { diff --git a/tools/MayaExporter/MayaExporter/Var.cpp b/tools/MayaExporter/MayaExporter/Var.cpp new file mode 100644 index 00000000..adfcb212 --- /dev/null +++ b/tools/MayaExporter/MayaExporter/Var.cpp @@ -0,0 +1,70 @@ +#include "Var.h" +#include "MayaIncludes.h" +#include + +Var::Var(Var::Type type, unsigned int numElements) +{ + m_Type = type; + m_NumElements = numElements; + + switch (m_Type) + { + case Var::Type::Int: + m_Data = new int[m_NumElements]; + break; + case Var::Type::Float: + m_Data = new float[m_NumElements]; + break; + case Var::Type::String: + m_Data = new std::string[m_NumElements]; + break; + default: + MGlobal::displayError("Var is an invalid type"); + assert(0); + break; + } +} + +Var& Var::operator=(const int& other) +{ + assert(m_Type == Type::Int); + *(int*)m_Data = other; + return *this; +} + +Var& Var::operator=(const float& other) +{ + assert(m_Type == Type::Float); + *(float*)m_Data = other; + return *this; +} + +Var& Var::operator=(const std::string& other) +{ + assert(m_Type == Type::String); + std::string tmp(other); + (*(std::string*)m_Data).swap(tmp); + return *this; +} + +//Var& Var::operator=(const Var& other) +//{ +// m_Data = other.m_Data; +// m_Type = other.m_Type; +// return *this; +//} + +Var::Type Var::isType() const +{ + return m_Type; +} + +unsigned int Var::NumElements() const +{ + return m_NumElements; +} + +void* Var::Data() +{ + return m_Data; +} \ No newline at end of file diff --git a/tools/MayaExporter/MayaExporter/Var.h b/tools/MayaExporter/MayaExporter/Var.h new file mode 100644 index 00000000..b0ec66dd --- /dev/null +++ b/tools/MayaExporter/MayaExporter/Var.h @@ -0,0 +1,32 @@ +#ifndef Var_Var_h__ +#define Var_Var_h__ + +#include + +class Var +{ +public: + enum class Type + { + Int, + Float, + String + }; + + Var(Var::Type type, unsigned int numElements = 1); + ~Var() { delete[] m_Data; }; + + Var& operator=(const int& other); + Var& operator=(const float& other); + Var& operator=(const std::string& other); + //Var& operator=(const Var& other); + Type isType() const; + unsigned int NumElements() const; + void* Data(); +private: + Type m_Type; + unsigned int m_NumElements; + void* m_Data; +}; + +#endif \ No newline at end of file