Merge remote-tracking branch 'origin/master' into Rendering

# Conflicts:
#	include/Game/HardcodedTestWorld.h
This commit is contained in:
viktorljung
2015-12-08 10:15:00 +01:00
24 changed files with 1279 additions and 249 deletions
+40
View File
@@ -4,6 +4,7 @@
#include "../Common.h"
#include "EntityWrapper.h"
#include "ComponentInfo.h"
#include "Util/Any.h"
struct ComponentWrapper
{
@@ -62,4 +63,43 @@ struct ComponentWrapper
SubscriptProxy operator[](std::string propertyName) { return SubscriptProxy(this, propertyName); }
};
// TODO: Move this to Tests once entity importing is finished
class ComponentWrapperFactory
{
public:
ComponentWrapperFactory() = default;
ComponentWrapperFactory(std::string componentTypeName, std::size_t allocation = 0)
{
m_ComponentInfo.Name = componentTypeName;
m_ComponentInfo.Meta.Allocation = allocation;
}
template <typename T>
void AddProperty(std::string fieldName, T defaultValue)
{
m_DefaultValues.push_back(defaultValue);
m_ComponentInfo.FieldTypes[fieldName] = typeid(T).name();
m_ComponentInfo.FieldOffsets[fieldName] = m_ComponentInfo.Meta.Stride;
m_ComponentInfo.Meta.Stride += sizeof(T);
}
ComponentInfo& Finalize()
{
m_ComponentInfo.Defaults = std::shared_ptr<char>(new char[m_ComponentInfo.Meta.Stride]);
std::size_t offset = 0;
for (auto& val : m_DefaultValues) {
memcpy(m_ComponentInfo.Defaults.get() + offset, val.Data.get(), val.Size);
offset += val.Size;
}
return m_ComponentInfo;
}
operator ComponentInfo&() { return Finalize(); }
private:
ComponentInfo m_ComponentInfo;
std::vector<Any> m_DefaultValues;
};
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef Util_Any_h__
#define Util_Any_h__
#include <memory>
struct Any
{
Any() { }
template <typename T>
Any(const T& value)
{
Data = std::shared_ptr<char>(new char[sizeof(T)]);
Size = sizeof(T);
memcpy(Data.get(), &value, Size);
}
template <typename T>
Any(T&& value)
{
Data = std::shared_ptr<char>(new char[sizeof(T)]);
Size = sizeof(T);
memcpy(Data.get(), &value, Size);
}
template <typename T>
Any& operator=(const T& value)
{
return Any(value);
}
template <typename T>
Any& operator=(T&& value)
{
return Any(value);
}
std::shared_ptr<char> Data = nullptr;
std::size_t Size = 0;
};
#endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef Client_h__
#define Client_h__
#include <boost\asio.hpp>
class Client
{
Client();
~Client();
};
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef Server_h__
#define Server_h__
#include <boost\asio.hpp>
class Server
{
Server();
~Server();
};
#endif
+52 -113
View File
@@ -3,39 +3,7 @@
#include <boost/any.hpp>
#include "GLM.h"
#include "Core/World.h"
struct any
{
any() { }
template <typename T>
any(const T& value)
{
Buffer = std::shared_ptr<char>(new char[sizeof(T)]);
memcpy(Buffer.get(), &value, sizeof(T));
}
template <typename T>
any(T&& value)
{
Buffer = std::shared_ptr<char>(new char[sizeof(T)]);
memcpy(Buffer.get(), &value, sizeof(T));
}
template <typename T>
any& operator=(const T& value)
{
return any(value);
}
template <typename T>
any& operator=(T&& value)
{
return any(value);
}
std::shared_ptr<char> Buffer = nullptr;
};
#include "Core/Util/Any.h"
class HardcodedTestWorld : public World
{
@@ -50,29 +18,7 @@ public:
private:
void registerTestComponents()
{
std::unordered_map<std::string, std::list<std::tuple<std::size_t, std::string, any>>> components
{
{
"Test",
{
std::make_tuple(sizeof(int), "TestInteger", 1337),
std::make_tuple(sizeof(float), "TestFloat", 13.37f)
}
},
{
"Debug",
{
std::make_tuple(sizeof(std::string), "Name", std::string("Unnamed")),
std::make_tuple(sizeof(glm::vec3), "PickingColor", glm::vec3(0.f))
}
},
{
"Transform",
{
std::make_tuple(sizeof(glm::vec3), "Position", glm::vec3(0.f, 0.f, 0.f)),
std::make_tuple(sizeof(glm::quat), "Orientation", glm::quat()),
std::make_tuple(sizeof(glm::vec3), "Scale", glm::vec3(1.f, 1.f, 1.f))
}
ComponentWrapperFactory f;
},
{
"Model",
@@ -80,73 +26,66 @@ private:
std::make_tuple(sizeof(std::string), "ModelFile", std::string("Unnamed")),
std::make_tuple(sizeof(glm::vec4), "Color", glm::vec4(1.f, 1.f, 1.f, 1.f)),
}
}
};
for (auto& c : components) {
ComponentInfo ci;
ci.Name = c.first;
f = ComponentWrapperFactory("Test");
f.AddProperty("TestInteger", 1337);
f.AddProperty("TestFloat", 13.37f);
f.AddProperty("TestString", std::string("Carlito"));
RegisterComponent(f);
// Fields
unsigned int stride = 0;
for (auto& f : c.second) {
stride += std::get<0>(f);
}
ci.Meta.Stride = stride;
ci.Defaults = std::shared_ptr<char>(new char[stride]);
unsigned int offset = 0;
for (auto& f : c.second) {
std::size_t size;
std::string fieldName;
any defaultValue;
std::tie(size, fieldName, defaultValue) = f;
f = ComponentWrapperFactory("Debug");
f.AddProperty("Name", std::string("Unnamed"));
RegisterComponent(f);
ci.FieldOffsets[fieldName] = offset;
ci.FieldTypes[fieldName] = "undefined";
memcpy(ci.Defaults.get() + offset, defaultValue.Buffer.get(), size);
offset += size;
}
f = ComponentWrapperFactory("Transform");
f.AddProperty("Position", glm::vec3(0.f, 0.f, 0.f));
f.AddProperty("Orientation", glm::quat());
f.AddProperty("Scale", glm::vec3(1.f, 1.f, 1.f));
RegisterComponent(f);
RegisterComponent(ci);
}
f = ComponentWrapperFactory("Model");
f.AddProperty("Resource", std::string());
f.AddProperty("Color", glm::vec4(1.f, 1.f, 1.f, 1.f));
f.AddProperty("Visible", true);
RegisterComponent(f);
}
void createTestEntities()
{
{
EntityID e = CreateEntity();
AttachComponent(e, "Test");
AttachComponent(e, "Debug");
AttachComponent(e, "Transform");
ComponentWrapper testComponent = GetComponent(e, "Test");
int testValue = testComponent["TestInteger"];
float testFloat = testComponent["TestFloat"];
ComponentWrapper debugComponent = GetComponent(e, "Debug");
std::string name = debugComponent["Name"];
glm::vec3 pickingColor = debugComponent["PickingColor"];
ComponentWrapper testTransform = GetComponent(e, "Transform");
glm::vec3 pos = testTransform["Position"];
glm::quat ori = testTransform["Orientation"];
glm::vec3 scale = testTransform["Scale"];
}
World& world = *this;
{
EntityID entityTranslationWidget = CreateEntity();
AttachComponent(entityTranslationWidget, "Transform");
AttachComponent(entityTranslationWidget, "Model");
ComponentWrapper testTransform = GetComponent(entityTranslationWidget, "Transform");
glm::vec3 pos = testTransform["Position"];
glm::quat ori = testTransform["Orientation"];
glm::vec3 scale = testTransform["Scale"];
ComponentWrapper testModel = GetComponent(entityTranslationWidget, "Model");
std::string file = testModel["ModelFile"];
testModel["ModelFile"] = "Models/TranslationWidget.obj";
glm::vec4 col = testModel["Color"];
// Create an entity
EntityID e = world.CreateEntity();
// Attach a Debug component
ComponentWrapper debug = world.AttachComponent(e, "Debug");
// Set the Name field of the Debug component using subscript operator
debug["Name"] = "Carlito";
// Attach a Transform component
world.AttachComponent(e, "Transform");
// Fetch the component based on EntityID and component type
ComponentWrapper transform = world.GetComponent(e, "Transform");
// Set the fields of the Transform component
transform["Position"] = glm::vec3(0.f, 0.f, 0.f);
transform["Scale"] = glm::vec3(1.f, 1.f, 1.f);
// Move on the X axis by fetching field as reference
((glm::vec3&)transform["Position"]).x += 10.f;
// Shrink by a factor of 100
((glm::vec3&)transform["Scale"]) /= 100.f;
// Loop through all Transform components and print them
for (auto& transform : world.GetComponents("Transform")) {
glm::vec3 pos = transform["Position"];
std::cout << "Position: " << pos.x << " " << pos.y << " " << pos.z << std::endl;
glm::vec3 scale = transform["Scale"];
std::cout << "Scale: " << scale.x << " " << scale.y << " " << scale.z << std::endl;
// Fetch the Debug component also present in this entity
ComponentWrapper debug = world.GetComponent(transform.EntityID, "Debug");
std::cout << "Name: " << (std::string)debug["Name"] << std::endl;
}
{
EntityID entityScaleWidget = CreateEntity();
AttachComponent(entityScaleWidget, "Transform");
AttachComponent(entityScaleWidget, "Model");
ComponentWrapper testTransform = GetComponent(entityScaleWidget, "Transform");
testTransform["Position"] = glm::vec3(-1.5f, 0.f, 0.f);
glm::quat ori = testTransform["Orientation"];
+7
View File
@@ -46,6 +46,12 @@ file(GLOB SOURCE_FILES_Input
)
source_group(Input FILES ${SOURCE_FILES_Input})
file(GLOB SOURCE_FILES_Network
"${INCLUDE_PATH}/Network/*.h"
"Network/*.cpp"
)
source_group(Network FILES ${SOURCE_FILES_Network})
file(GLOB SOURCE_FILES_Rendering
"${INCLUDE_PATH}/Rendering/*.h"
"Rendering/*.cpp"
@@ -68,6 +74,7 @@ set(SOURCE_FILES
${SOURCE_FILES_Core}
${SOURCE_FILES_Core_Util}
#${SOURCE_FILES_Input}
${SOURCE_FILES_Network}
${SOURCE_FILES_GUI}
${SOURCE_FILES_Rendering}
${SOURCE_FILES_Rendering_Util}
+11
View File
@@ -0,0 +1,11 @@
#include "Network\Client.h"
Client::Client()
{
}
Client::~Client()
{
}
+11
View File
@@ -0,0 +1,11 @@
#include "Network\Server.h"
Server::Server()
{
}
Server::~Server()
{
}
+54 -24
View File
@@ -1,41 +1,71 @@
#include <boost/test/unit_test.hpp>
namespace utf = boost::unit_test;
#include "Common.h"
#include "GLM.h"
#include "Core/World.h"
BOOST_AUTO_TEST_CASE(WorldTest)
BOOST_AUTO_TEST_CASE(WorldTestSingleAllocation, * boost::unit_test::tolerance(0.001))
{
ComponentInfo ci;
ci.Name = "Test";
ci.FieldTypes["Field"] = "int";
ci.FieldOffsets["Field"] = 0;
ci.Meta.Stride = sizeof(int);
ci.Meta.Allocation = 3;
ci.Defaults = std::shared_ptr<char>(new char[ci.Meta.Stride]);
int default_Field = 1337;
memcpy(ci.Defaults.get(), &default_Field, ci.Meta.Stride);
World w;
w.RegisterComponent(ci);
std::vector<EntityID> ids;
auto f = ComponentWrapperFactory("Test");
f.AddProperty("TestInteger", 1337);
f.AddProperty("TestDouble", 13.37);
f.AddProperty("TestString", std::string("Carlito"));
f.AddProperty("TestVec3", glm::vec3(1.f, 2.f, 3.f));
w.RegisterComponent(f);
EntityID e = w.CreateEntity();
ComponentWrapper c = w.AttachComponent(e, "Test");
// Check default values
BOOST_TEST((int)c["TestInteger"] == c.Property<int>("TestInteger"));
BOOST_TEST((int)c["TestInteger"] == 1337);
BOOST_TEST((double)c["TestDouble"] == 13.37);
BOOST_TEST((std::string)c["TestString"] == "Carlito");
glm::vec3 vec3 = c["TestVec3"];
BOOST_TEST(vec3.x == 1.f);
BOOST_TEST(vec3.y == 2.f);
BOOST_TEST(vec3.z == 3.f);
// Change values
((int&)c["TestInteger"]) += 1;
BOOST_TEST((int)c["TestInteger"] == 1338);
((double&)c["TestDouble"]) += 1.11;
std::cout << (double)c["TestDouble"] << std::endl;
BOOST_TEST((double)c["TestDouble"] == 14.48);
c["TestString"] = "Siesta";
BOOST_TEST((std::string)c["TestString"] == "Siesta");
((glm::vec3&)c["TestVec3"]).y += 1.f;
BOOST_TEST(((glm::vec3)c["TestVec3"]).y == 3.f);
}
BOOST_AUTO_TEST_CASE(WorldTestMultipleAllocations, * utf::tolerance(0.00001))
{
World w;
// Create allocation for 3 entities
auto f = ComponentWrapperFactory("Test", 3);
f.AddProperty("TestInteger", 1337);
f.AddProperty("TestDouble", 13.37);
f.AddProperty("TestString", std::string("Carlito"));
f.AddProperty("TestVec3", glm::vec3(1.f, 2.f, 3.f));
w.RegisterComponent(f);
// Create 6 entities with Test components
// 3 will reside in contiguous memory
// 3 will be allocated dynamically
for (int i = 0; i < 6; i++) {
EntityID e = w.CreateEntity();
ids.push_back(e);
w.AttachComponent(e, "Test");
ComponentWrapper c = w.GetComponent(e, "Test");
BOOST_CHECK(c.EntityID == e);
BOOST_CHECK((int)c["Field"] == 1337);
c.SetProperty("Field", i);
BOOST_CHECK((int)c["Field"] == i);
ComponentWrapper c = w.AttachComponent(e, "Test");
c["TestInteger"] = i;
}
// Loop through them and check data
int i = 0;
for (auto& c : w.GetComponents("Test")) {
EntityID e = ids.at(i);
BOOST_CHECK(c.EntityID == e);
BOOST_CHECK((int)c["Field"] == i);
BOOST_TEST((int)c["TestInteger"] == i);
i++;
}
}
+36
View File
@@ -0,0 +1,36 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MayaExporter", "MayaExporter\MayaExporter.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|ARM.ActiveCfg = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|ARM.ActiveCfg = Release|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,107 @@
/****************************************************************************
** Meta object code from reading C++ file 'Menu.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.6)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../Menu.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'Menu.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.6. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Menu[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
7, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
14, 6, 5, 5, 0x08,
35, 5, 5, 5, 0x08,
59, 5, 5, 5, 0x08,
75, 5, 5, 5, 0x08,
95, 5, 5, 5, 0x08,
116, 5, 5, 5, 0x08,
137, 5, 5, 5, 0x08,
0 // eod
};
static const char qt_meta_stringdata_Menu[] = {
"Menu\0\0checked\0ExportSelected(bool)\0"
"ExportPathClicked(bool)\0ExportAll(bool)\0"
"CancelClicked(bool)\0Button1Clicked(bool)\0"
"Button2Clicked(bool)\0Button3Clicked(bool)\0"
};
void Menu::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
Menu *_t = static_cast<Menu *>(_o);
switch (_id) {
case 0: _t->ExportSelected((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 1: _t->ExportPathClicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 2: _t->ExportAll((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 3: _t->CancelClicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 4: _t->Button1Clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 5: _t->Button2Clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 6: _t->Button3Clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData Menu::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject Menu::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_Menu,
qt_meta_data_Menu, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &Menu::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *Menu::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *Menu::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Menu))
return static_cast<void*>(const_cast< Menu*>(this));
return QWidget::qt_metacast(_clname);
}
int Menu::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 7)
qt_static_metacall(this, _c, _id, _a);
_id -= 7;
}
return _id;
}
QT_END_MOC_NAMESPACE
@@ -0,0 +1,29 @@
/****************************************************************************
** Resource object code
**
** Created by: The Resource Compiler for Qt version 4.8.6
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
int QT_MANGLE_NAMESPACE(qInitResources_leeeeel)()
{
return 1;
}
Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_leeeeel))
int QT_MANGLE_NAMESPACE(qCleanupResources_leeeeel)()
{
return 1;
}
Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_leeeeel))
@@ -0,0 +1,69 @@
/********************************************************************************
** Form generated from reading UI file 'MayaExporter.ui'
**
** Created by: Qt User Interface Compiler version 4.8.6
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAYAEXPORTER_H
#define UI_MAYAEXPORTER_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_leeeeelClass
{
public:
QMenuBar *menuBar;
QToolBar *mainToolBar;
QWidget *centralWidget;
QStatusBar *statusBar;
void setupUi(QMainWindow *leeeeelClass)
{
if (leeeeelClass->objectName().isEmpty())
leeeeelClass->setObjectName(QString::fromUtf8("leeeeelClass"));
leeeeelClass->resize(600, 400);
menuBar = new QMenuBar(leeeeelClass);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
leeeeelClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(leeeeelClass);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
leeeeelClass->addToolBar(mainToolBar);
centralWidget = new QWidget(leeeeelClass);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
leeeeelClass->setCentralWidget(centralWidget);
statusBar = new QStatusBar(leeeeelClass);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
leeeeelClass->setStatusBar(statusBar);
retranslateUi(leeeeelClass);
QMetaObject::connectSlotsByName(leeeeelClass);
} // setupUi
void retranslateUi(QMainWindow *leeeeelClass)
{
leeeeelClass->setWindowTitle(QApplication::translate("leeeeelClass", "leeeeel", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class leeeeelClass: public Ui_leeeeelClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAYAEXPORTER_H
+42
View File
@@ -0,0 +1,42 @@
#include "MayaIncludes.h"
#include "Menu.h"
#include <iostream>
#include <maya/MFnPlugin.h>
using namespace std;
QDialog* dialog;
Menu* menu;
// called when the plugin is loaded
EXPORT MStatus initializePlugin(MObject obj)
{
MStatus res = MS::kSuccess;
MFnPlugin myPlugin(obj, "Maya plugin", "1.0", "Any", &res);
if (MFAIL(res))
{
CHECK_MSTATUS(res);
}
MGlobal::displayInfo("Maya plugin loaded!");
dialog = new QDialog();
dialog->setWindowTitle("Custom Exporter");
menu = new Menu(dialog);
dialog->resize(300, 200);
dialog->show();
return res;
}
EXPORT MStatus uninitializePlugin(MObject obj)
{
MFnPlugin plugin(obj);
MGlobal::displayInfo("Maya plugin unloaded!");
delete dialog;
delete menu;
return MS::kSuccess;
}
@@ -0,0 +1,29 @@
<UI version="4.0" >
<class>leeeeelClass</class>
<widget class="QMainWindow" name="leeeeelClass" >
<property name="objectName" >
<string notr="true">leeeeelClass</string>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle" >
<string>leeeeel</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources>
<include location="leeeeel.qrc"/>
</resources>
<connections/>
</UI>
@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B12702AD-ABFB-343A-A199-8E24837244A3}</ProjectGuid>
<Keyword>Qt4VSv1.0</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>MayaExporter</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetExt>.mll</TargetExt>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetExt>.mll</TargetExt>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>UNICODE;WIN32;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\Maya2016\include;.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\Maya2016\lib;$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmaind.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>QT_DLL;QT_NO_IMPORT_QT47_QML;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files\Autodesk\Maya2016\include;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<WarningLevel>Level1</WarningLevel>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>C:\Program Files\Autodesk\Maya2016\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>qtmain.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;QT_DLL;QT_NO_DEBUG;QT_NO_IMPORT_QT47_QML;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>
</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>qtmain.lib;%(AdditionalDependencies)</AdditionalDependencies>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Menu.cpp" />
<ClCompile Include="GeneratedFiles\Debug\moc_Menu.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\qrc_leeeeel.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_Menu.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="MayaExporter.ui">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="Menu.h">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing Menu.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -D_WINDLL -D_UNICODE "-IC:\Program Files\Autodesk\Maya2016\include" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing Menu.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DQT_DLL -DQT_NO_IMPORT_QT47_QML -DUNICODE -DWIN32 -D_WINDLL -D_UNICODE "-IC:\Program Files\Autodesk\Maya2016\include" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing Menu.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing Menu.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DNDEBUG -DQT_DLL -DQT_NO_DEBUG -DQT_NO_IMPORT_QT47_QML -DUNICODE -DWIN32 "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
</CustomBuild>
<ClInclude Include="GeneratedFiles\ui_MayaExporter.h" />
<ClInclude Include="MayaIncludes.h" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="leeeeel.qrc">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Rcc%27ing %(Identity)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Rcc%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Rcc%27ing %(Identity)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Rcc%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties MocDir=".\GeneratedFiles\$(ConfigurationName)" UicDir=".\GeneratedFiles" RccDir=".\GeneratedFiles" lupdateOptions="" lupdateOnBuild="0" lreleaseOptions="" Qt5Version_x0020_Win32="4.8.6" Qt5Version_x0020_x64="Maya2016" MocOptions="" />
</VisualStudio>
</ProjectExtensions>
</Project>
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;cxx;c;def</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h</Extensions>
</Filter>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>
<Extensions>qrc;*</Extensions>
<ParseFiles>false</ParseFiles>
</Filter>
<Filter Include="Generated Files">
<UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>
<Extensions>moc;h;cpp</Extensions>
<SourceControlFiles>False</SourceControlFiles>
</Filter>
<Filter Include="Generated Files\Debug">
<UniqueIdentifier>{bd033994-5bd0-43b7-8fdf-7b8a213a1c55}</UniqueIdentifier>
<Extensions>cpp;moc</Extensions>
<SourceControlFiles>False</SourceControlFiles>
</Filter>
<Filter Include="Generated Files\Release">
<UniqueIdentifier>{f53efcfb-95d1-44a6-a82f-295bb0b0509c}</UniqueIdentifier>
<Extensions>cpp;moc</Extensions>
<SourceControlFiles>False</SourceControlFiles>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="GeneratedFiles\qrc_leeeeel.cpp">
<Filter>Generated Files</Filter>
</ClCompile>
<ClCompile Include="GeneratedFiles\Debug\moc_Menu.cpp">
<Filter>Generated Files\Debug</Filter>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_Menu.cpp">
<Filter>Generated Files\Release</Filter>
</ClCompile>
<ClCompile Include="Menu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="leeeeel.qrc">
<Filter>Resource Files</Filter>
</CustomBuild>
<CustomBuild Include="Menu.h">
<Filter>Header Files</Filter>
</CustomBuild>
<CustomBuild Include="MayaExporter.ui">
<Filter>Form Files</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MayaIncludes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GeneratedFiles\ui_MayaExporter.h">
<Filter>Generated Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<QTDIR>C:\Program Files\Autodesk\Maya2016</QTDIR>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<QTDIR>C:\Program Files\Autodesk\Maya2016</QTDIR>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<QTDIR>C:\Program Files\Autodesk\Maya2016</QTDIR>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<QTDIR>C:\Program Files\Autodesk\Maya2016</QTDIR>
</PropertyGroup>
</Project>
@@ -0,0 +1,62 @@
#ifndef MAYAINCLUDES_H
#define MAYAINCLUDES_H
#define NT_PLUGIN
#define REQUIRE_IOSTREAM
#define EXPORT __declspec(dllexport)
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MFloatPointArray.h>
#include <maya/MPointArray.h>
#include <maya/MIntArray.h>
#include <maya/MPoint.h>
#include <maya/MMatrix.h>
#include <maya/MEulerRotation.h>
#include <maya/MVector.h>
#include <maya/MItDag.h>
#include <maya/MFnCamera.h>
#include <maya/M3dView.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MPlugArray.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnLambertShader.h>
#include <maya/MFnBlinnShader.h>
#include <maya/MFnPhongShader.h>
#include <maya/MImage.h>
#include <maya/MFnPointLight.h>
#include <maya/MSelectionList.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MCommandMessage.h>
// Wrappers
#include <maya/MGlobal.h>
#include <maya/MCallbackIdArray.h>
#include <maya/MQtUtil.h>
// Messages
#include <maya/MMessage.h>
#include <maya/MTimerMessage.h>
#include <maya/MDGMessage.h>
#include <maya/MEventMessage.h>
#include <maya/MPolyMessage.h>
#include <maya/MNodeMessage.h>
#include <maya/MDagPath.h>
#include <maya/MDagMessage.h>
#include <maya/MUiMessage.h>
#include <maya/MModelMessage.h>
// Commands
#include <maya/MPxCommand.h>
// Libraries to link from Maya
#pragma comment(lib,"Foundation.lib")
#pragma comment(lib,"OpenMaya.lib")
#pragma comment(lib,"OpenMayaUI.lib")
#endif
+239
View File
@@ -0,0 +1,239 @@
#include "Menu.h"
#include <iostream>
using namespace std;
Menu::Menu()
{
}
Menu::Menu(QDialog* dialog)
{
// Save the dialog pointer. Needed when the application gets destroyed
dialogPointer = dialog;
// Create QpushButtons & give them names
exportSelectedButton = new QPushButton("&Export Selected", this);
browseButton = new QPushButton("&...", this);
exportAllButton = new QPushButton("&Export All", this);
cancelButton = new QPushButton("&Cancel", this);
// Option box and checkboxes
QGroupBox *optionsBox = new QGroupBox(tr("Options"));
exportAnimationsButton = new QCheckBox(tr("&Export Animations"));
copyTexturesButton = new QCheckBox(tr("&Copy Textures"));
button3 = new QCheckBox(tr("option3"));
exportAnimationsButton->setChecked(true);
copyTexturesButton->setChecked(true);
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(exportAnimationsButton);
vbox->addWidget(copyTexturesButton);
vbox->addWidget(button3);
vbox->addStretch(1);
optionsBox->setLayout(vbox);
// Connect the buttons with signals & functions
connect(exportSelectedButton, SIGNAL(clicked(bool)), this, SLOT(ExportSelected(bool)));
connect(browseButton, SIGNAL(clicked(bool)), this, SLOT(ExportPathClicked(bool)));
connect(exportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool)));
connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(CancelClicked(bool)));
connect(exportAnimationsButton, SIGNAL(clicked(bool)), this, SLOT(Button1Clicked(bool)));
connect(copyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool)));
connect(button3, SIGNAL(clicked(bool)), this, SLOT(Button3Clicked(bool)));
// Creating several layouts, adding widgets & adding them to one layout in the end
QHBoxLayout* topLayout = new QHBoxLayout;
QVBoxLayout* midLayout = new QVBoxLayout;
QHBoxLayout* botLayout = new QHBoxLayout;
QVBoxLayout* baseLayout = new QVBoxLayout;
exportPath = new QLineEdit;
fileDialog = new QFileDialog;
QLabel* exportLabel = new QLabel;
exportLabel->setText("Export Path:");
midLayout->addWidget(optionsBox);
topLayout->addWidget(exportLabel);
topLayout->addWidget(exportPath);
topLayout->addWidget(browseButton);
botLayout->addWidget(exportSelectedButton);
botLayout->addWidget(exportAllButton);
botLayout->addWidget(cancelButton);
baseLayout->addLayout(topLayout);
baseLayout->addLayout(midLayout);
baseLayout->addSpacing(10);
baseLayout->addLayout(botLayout);
baseLayout->addStretch();
// Set the layout for our window
dialog->setLayout(baseLayout);
}
void Menu::ExportSelected(bool checked)
{
// Retrieving the objects we currently have selected
MSelectionList selected;
MGlobal::getActiveSelectionList(selected);
// Loop through or list of selection(s)
for (unsigned int i = 0; i < selected.length();i++)
{
MObject object;
selected.getDependNode(i, object);
MFnDependencyNode thisNode(object);
cout << thisNode.name().asChar() << endl;
GetMeshData(object);
}
if (exportPath->text().isEmpty())
cout << "Please select a folder." << endl;
else
cout << exportPath->text().toLocal8Bit().constData() << endl;
}
void Menu::ExportPathClicked(bool)
{
// Opens up a file dialog. Save/Changes the name in the exportPath
fileDialog->setFileMode(QFileDialog::Directory);
fileDialog->setOption(QFileDialog::ShowDirsOnly);
QString fileName = fileDialog->getExistingDirectory(this, "Select", "/home", QFileDialog::ShowDirsOnly);
exportPath->setText(fileName);
}
void Menu::ExportAll(bool)
{
MDagPath path;
// Loop through all nodes in the scene
MItDependencyNodes it(MFn::kInvalid);
for (;!it.isDone();it.next())
{
MObject node = it.thisNode();
if (node.hasFn(MFn::kMesh))
{
MFnDependencyNode thisNode(node);
cout << thisNode.name().asChar() << endl;
GetMeshData(node);
}
}
if (exportPath->text().isEmpty())
cout << "Please select a folder." << endl;
else
cout << exportPath->text().toLocal8Bit().constData() << endl;
}
void Menu::CancelClicked(bool)
{
dialogPointer->close();
}
void Menu::Button1Clicked(bool)
{
if(exportAnimationsButton->isChecked())
cout << "1 checked!" << endl;
else
cout << "1 unchecked!" << endl;
}
void Menu::Button2Clicked(bool)
{
if (copyTexturesButton->isChecked())
cout << "2 checked!" << endl;
else
cout << "2 unchecked!" << endl;
}
void Menu::Button3Clicked(bool)
{
if (button3->isChecked())
cout << "3 checked!" << endl;
else
cout << "3 unchecked!" << endl;
}
void Menu::GetMeshData(MObject object)
{
// In here, we retrieve triangulated polygons from the mesh
MFnMesh mesh(object);
map<UINT, vector<UINT>> vertexToIndex;
vector<VertexLayout> verticesData;
vector<UINT>indexArray;
MIntArray intdexOffsetVertexCount, vertices, triangleList;
MPointArray dummy;
UINT vertexIndex;
MVector normal;
MPoint pos;
float2 UV;
VertexLayout thisVertex;
for (MItMeshPolygon meshPolyIter(object); !meshPolyIter.isDone(); meshPolyIter.next())
{
vector<UINT> localVertexToGlobalIndex;
meshPolyIter.getVertices(vertices);
meshPolyIter.getTriangles(dummy, triangleList);
UINT indexOffset = verticesData.size();
for (UINT i = 0; i < vertices.length(); i++)
{
vertexIndex = meshPolyIter.vertexIndex(i);
pos = meshPolyIter.point(i);
pos.get(thisVertex.pos);
meshPolyIter.getNormal(i, normal);
thisVertex.normal[0] = normal[0];
thisVertex.normal[1] = normal[1];
thisVertex.normal[2] = normal[2];
meshPolyIter.getUV(i, UV);
thisVertex.uv[0] = UV[0];
thisVertex.uv[1] = UV[1];
verticesData.push_back(thisVertex);
localVertexToGlobalIndex.push_back(vertexIndex);
cout << "Pos: " << thisVertex.pos[0] << "/" << thisVertex.pos[1] << "/" << thisVertex.pos[2] << endl;
cout << "Normals: " << thisVertex.normal[0] << "/" << thisVertex.normal[1] << "/" << thisVertex.normal[2] << endl;
cout << "UV: " << thisVertex.uv[0] << "/" << thisVertex.uv[1] << endl;
}
for (UINT i = 0; i < triangleList.length(); i++)
{
UINT k = 0;
while (localVertexToGlobalIndex[k] != triangleList[i])
k++;
indexArray.push_back(indexOffset + k);
}
}
}
void Menu::exportMaterial(MObject object)
{
MItDependencyNodes matIt(MFn::kLambert);
}
Menu::~Menu()
{
//delete exportSelectedButton;
//delete browseButton;
//delete exportPath;
//delete fileDialog;
fileDialog->~QFileDialog();
}
+79
View File
@@ -0,0 +1,79 @@
#ifndef BUTTONS_H
#define BUTTONS_H
#include <map>
#include <vector>
#include "MayaIncludes.h"
// Qt
#pragma comment(lib, "QtCore4")
#pragma comment(lib, "QtGui4")
#include <QtCore/qcoreapplication.h>
#include <maya/MQtUtil.h>
#include <QtGui/qwidget.h>
#include <QtGui/qapplication.h>
#include <QtGui/qdialog.h>
#include <QtGui/qpushbutton.h>
#include <QtGui/qboxlayout.h>
#include <QtGui/qformlayout.h>
#include <QtCore/qthread.h>
#include <QtCore/qpointer.h>
#include <QtCore/qlist.h>
#include <QtGui/qlistwidget.h>
#include <QtUiTools/quiloader.h>
#include <QtCore/qfile.h>
#include <QtGui/qlabel.h>
#include <QtGui/qcheckbox.h>
#include <QtGui/qradiobutton.h>
#include <QtGui/qfiledialog.h>
#include <QtGui/qlineedit.h>
#include <QtGui/qgroupbox.h>
struct VertexLayout
{
float pos[3];
float normal[3];
float uv[2];
};
class Menu : public QWidget
{
Q_OBJECT
public:
Menu(QDialog* dialog);
~Menu();
void GetMeshData(MObject object);
void exportMaterial(MObject object);
private slots:
void ExportSelected(bool checked);
void ExportPathClicked(bool);
void ExportAll(bool);
void CancelClicked(bool);
void Button1Clicked(bool);
void Button2Clicked(bool);
void Button3Clicked(bool);
private:
Menu();
QPushButton* exportSelectedButton;
QPushButton* browseButton;
QPushButton* exportAllButton;
QPushButton* cancelButton;
QCheckBox* exportAnimationsButton;
QCheckBox* copyTexturesButton;
QCheckBox* button3;
QLineEdit* exportPath;
QFileDialog* fileDialog;
QDialog* dialogPointer;
};
#endif
@@ -0,0 +1,4 @@
<RCC>
<qresource prefix="leeeeel">
</qresource>
</RCC>
@@ -1,11 +0,0 @@
{
"type": "service_account",
"private_key_id": "cca18cfac73794c4d2976833949829fe150ead81",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCvgdm4HeS54TS9\nS58jhxbaxrFL5yOyyofJo51CtBAMT0aCuV41ngoethfJArjwO1ZziaPRX0ZrQvBC\n3XtIcBblkR/6w0uYF3lTcwuxqpbNrkptQNc7ms91pYHeRJS/u+U0hmnmS+TI8q4c\nm47xbtpw2ym8Uvq1anvYgmnlQQNNgaFcuYSgFLPhRL2TdOR82fz055rHUeEIT3YG\n7RpZBokWQFaZT5KsWbBjjEMlfexg11/9tK1zbDCjqU/JSBRmzmXh0kEbRCWQWC5k\n+ZHSrcD8Sj3d6nfBsxiu8yAW0pYqMEDNnlX69ovqjVlfa1PO+J+7IwY1svde872C\nzrC1huyzAgMBAAECggEASiq2he7kDIUWE3SUkJ/y0Ysru2a3GEQsM9LXjyumqH0L\n0AxjuobJwgazcHedDbAVrYeZ2c3IZWWJQMh147uygVrdx8ul82TgGZrBc1gimFKy\nEw9WpVKbnxzND8+tiITvrE2tDOw/h4e+ekpmkrKEzzJepb3vQqD4KxuZgo8BxUtw\n1bBAq2hKKukc1IlzXv0cegWYqfw1wA3vFngQh+B/ueR3kbLUWu130z2Ls/SnBdHt\nYaIbER6YUrQ6eG2cQrjh711zMjMgMsinyh+MR/VHERspPR7HnNJkEb8LXivoLQE4\nUbBTihups769NJUr3CSqKXHIwv8QO9EfJ6IN8pglwQKBgQDyMEJW3iE0tKaBgtXY\nzJ4TWOkTOoKAnbuZd19ZbqARPfa+6apT4NWCz7pVXcZKv7rsMZTbCHAf3HfptCAq\nQSVkuRZaCv6SOUaWp0kk8cxIJpbvwMeqBY/BDmQr8SzUir6N0M+7G3tV/joqpY5c\n2V1udZeR0Ch4V+F9M/osmyvOIQKBgQC5hBpQlMmeQivk9P1eHkiB1w9RlLIrYjcQ\ndaSFOwgMiswK2/I04P/9BhXXeIin5r5EmpfHOM32wTdu5RkU5Ts428JqAshQBSwZ\nEciofEJ0fvmxCR+d+imG+Kq2BOneatOC6aYBVWr2VUDq8KyD4jL8tju6KOLvssRR\nsoK26wAYUwKBgQCexHpI3jfgiGj7UB0GkiUyw7+P5nR1AnJgSfxM8ZOnmfpu71nE\nwQjXR3x8yAvdJtHQUzSlXmO6z1og7/+CE9ECtb9safa3PysCSkpOGOF1jy61n6iE\n0j6KLfgHQoTEFOyUpYX4wCxblFznZj7sqWZxqk8hvNc7BUmCPZfMtDDEYQKBgQCP\nK+ZrHgjjvEnH71LCmjh3DBRkb495b9jzOPd5Yu95TnzePJSWPrcQ/OtKWVmNysQ4\nid5s/+fkcYVobiKHP8oOvXsy+WbCatt3lYP4k71tzrjA6jueXfxCkBKfWvdqkaMe\nu1dEXDmqVm09Y/Sf66hR5AoAR6GsP5jHPC8pH//4xQKBgQDlVw8Q6Xq5FFUfURvF\n6p8XsCgheykLDzFZHv2neL4ESXpt2flCaLcb+pC8+IrNDorC8BX6JiZD2WngMn+s\nClAkq4TgGE5Mjmk5ZOhrpg69H7O87OcNK5Cc12+tnoPsnvEcuF8CoGWIy3A6PNt+\nROnL6yOGeh2IHowPjrO3ODKO4Q==\n-----END PRIVATE KEY-----\n",
"client_email": "account-1@toggltospreadsheet.iam.gserviceaccount.com",
"client_id": "108608534336227301760",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/account-1%40toggltospreadsheet.iam.gserviceaccount.com"
}
@@ -1,101 +0,0 @@
import base64
import sys
import re
import pip
try:
import requests
except ImportError:
print 'requests module not installed.'
print 'Installing requests...'
pip.main(['install', 'requests'])
import requests
try:
import gspread
except ImportError:
print 'gspread module not installed.'
print 'Installing gspread...'
pip.main(['install', 'gspread'])
import gspread
import json
import time
from oauth2client.client import SignedJwtAssertionCredentials
def write_to_sheet(values, estimatedTime):
# Note: This is Andreas client email & private google API key. Plz no share
client_email = 'account-1@toggltospreadsheet.iam.gserviceaccount.com'
private_key = 'nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCvgdm4HeS54TS9\nS58jhxbaxrFL5yOyyofJo51CtBAMT0aCuV41ngoethfJArjwO1ZziaPRX0ZrQvBC\n3XtIcBblkR/6w0uYF3lTcwuxqpbNrkptQNc7ms91pYHeRJS/u+U0hmnmS+TI8q4c\nm47xbtpw2ym8Uvq1anvYgmnlQQNNgaFcuYSgFLPhRL2TdOR82fz055rHUeEIT3YG\n7RpZBokWQFaZT5KsWbBjjEMlfexg11/9tK1zbDCjqU/JSBRmzmXh0kEbRCWQWC5k\n+ZHSrcD8Sj3d6nfBsxiu8yAW0pYqMEDNnlX69ovqjVlfa1PO+J+7IwY1svde872C\nzrC1huyzAgMBAAECggEASiq2he7kDIUWE3SUkJ/y0Ysru2a3GEQsM9LXjyumqH0L\n0AxjuobJwgazcHedDbAVrYeZ2c3IZWWJQMh147uygVrdx8ul82TgGZrBc1gimFKy\nEw9WpVKbnxzND8+tiITvrE2tDOw/h4e+ekpmkrKEzzJepb3vQqD4KxuZgo8BxUtw\n1bBAq2hKKukc1IlzXv0cegWYqfw1wA3vFngQh+B/ueR3kbLUWu130z2Ls/SnBdHt\nYaIbER6YUrQ6eG2cQrjh711zMjMgMsinyh+MR/VHERspPR7HnNJkEb8LXivoLQE4\nUbBTihups769NJUr3CSqKXHIwv8QO9EfJ6IN8pglwQKBgQDyMEJW3iE0tKaBgtXY\nzJ4TWOkTOoKAnbuZd19ZbqARPfa+6apT4NWCz7pVXcZKv7rsMZTbCHAf3HfptCAq\nQSVkuRZaCv6SOUaWp0kk8cxIJpbvwMeqBY/BDmQr8SzUir6N0M+7G3tV/joqpY5c\n2V1udZeR0Ch4V+F9M/osmyvOIQKBgQC5hBpQlMmeQivk9P1eHkiB1w9RlLIrYjcQ\ndaSFOwgMiswK2/I04P/9BhXXeIin5r5EmpfHOM32wTdu5RkU5Ts428JqAshQBSwZ\nEciofEJ0fvmxCR+d+imG+Kq2BOneatOC6aYBVWr2VUDq8KyD4jL8tju6KOLvssRR\nsoK26wAYUwKBgQCexHpI3jfgiGj7UB0GkiUyw7+P5nR1AnJgSfxM8ZOnmfpu71nE\nwQjXR3x8yAvdJtHQUzSlXmO6z1og7/+CE9ECtb9safa3PysCSkpOGOF1jy61n6iE\n0j6KLfgHQoTEFOyUpYX4wCxblFznZj7sqWZxqk8hvNc7BUmCPZfMtDDEYQKBgQCP\nK+ZrHgjjvEnH71LCmjh3DBRkb495b9jzOPd5Yu95TnzePJSWPrcQ/OtKWVmNysQ4\nid5s/+fkcYVobiKHP8oOvXsy+WbCatt3lYP4k71tzrjA6jueXfxCkBKfWvdqkaMe\nu1dEXDmqVm09Y/Sf66hR5AoAR6GsP5jHPC8pH//4xQKBgQDlVw8Q6Xq5FFUfURvF\n6p8XsCgheykLDzFZHv2neL4ESXpt2flCaLcb+pC8+IrNDorC8BX6JiZD2WngMn+s\nClAkq4TgGE5Mjmk5ZOhrpg69H7O87OcNK5Cc12+tnoPsnvEcuF8CoGWIy3A6PNt+\nROnL6yOGeh2IHowPjrO3ODKO4Q=='
# Change the path, otherwise the the json_key will not be found and writing to the Sheet will fail.
json_key = json.load(open('TogglToSpreadSheet-cca18cfac737.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
gc = gspread.authorize(credentials)
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1P8HFfktwSAF0rgi9rxpNvdMdR0GYuo845qAGikeJUh8/edit#gid=0')
worksheet = sh.get_worksheet(0)
currentDate = time.strftime("%Y-%m-%d")
results = [currentDate,values]
worksheet.insert_row(results, 3)
worksheet.update_acell("F2", estimatedTime)
return;
def get_totaltime_data():
api_token = '136ab033e06f9202497093b989f59f39'
_workspace_id = 1190663
print 'Sending Request...'
r = requests.get('https://toggl.com/reports/api/v2/summary', auth=(api_token, 'api_token'), params={'workspace_id': _workspace_id, 'since' : '2015-11-01', 'user_agent': 'api_test'})
if r.status_code != 200:
print 'Request Failed. Check your API Token'
return;
index = []
rWorkspace = requests.get('https://www.toggl.com/api/v8/workspaces/1190663/projects', auth=(api_token, 'api_token'))
workspaceText = rWorkspace.text
taskMap = map(int, re.findall(r'\d+', workspaceText))
estimatedTime = 0
counter = 0
index = [x-1 for x, i in enumerate(taskMap) if i == 1190663]
for x in index:
timeMap = []
rProject = requests.get('https://www.toggl.com/reports/api/v2/project', auth=(api_token, 'api_token'), params={'user_agent': 'api_test','workspace_id': _workspace_id, 'project_id': taskMap[x]})
if r.status_code != 200:
print 'rProject request Failed. Check your API Token'
return;
projectText = rProject.text
text = projectText.replace('null','0')
finalText = text.replace('0.0', '0')
timeMap = map(int, re.findall(r'\d+', finalText))
estimatedTime = estimatedTime + timeMap[6]
counter+= 1
wholeText = r.text
allNumbers = map(int, re.findall('\d+', wholeText))
totalTime = allNumbers[0]
timeleft = totalTime
hours = totalTime / 3600000
timeleft -= hours * 3600000
min = timeleft / 60000
timeleft -= min * 60000
sec = timeleft / 1000
estimatedTimeInHours = estimatedTime / 3600
str = 'Total Time: ' + repr(hours) +':' + repr(min) + ':' + repr(sec)
print str
result = repr(hours) + ':' + repr(min) +':' + repr(sec)
#result = []
#result.append(hours);
#result.append(min);
#result.append(sec);
print 'Writing to Sheet...'
write_to_sheet(result, estimatedTimeInHours)
return;
get_totaltime_data()
print 'Done!'