From a904eb63227d65804b8c902955fad0315b6a4909 Mon Sep 17 00:00:00 2001 From: meganr28 Date: Mon, 14 Mar 2022 13:21:19 -0400 Subject: [PATCH] Adding .gitignore --- .gitignore | 398 ++++++++++++++++++ cubicStylization/cubicStylization.sln | 31 ++ cubicStylization/cubicStylization/CGGTCmd.cpp | 92 ++++ cubicStylization/cubicStylization/CGGTCmd.h | 24 ++ .../cubicStylization/CGGTNode.cpp | 184 ++++++++ cubicStylization/cubicStylization/CGGTNode.h | 39 ++ .../cubicStylization/PluginMain.cpp | 73 ++++ .../cubicStylization/autoregister.mel | 4 + .../cubicStylization/cubicStylization.vcxproj | 158 +++++++ .../cubicStylization.vcxproj.filters | 36 ++ 10 files changed, 1039 insertions(+) create mode 100644 .gitignore create mode 100644 cubicStylization/cubicStylization.sln create mode 100644 cubicStylization/cubicStylization/CGGTCmd.cpp create mode 100644 cubicStylization/cubicStylization/CGGTCmd.h create mode 100644 cubicStylization/cubicStylization/CGGTNode.cpp create mode 100644 cubicStylization/cubicStylization/CGGTNode.h create mode 100644 cubicStylization/cubicStylization/PluginMain.cpp create mode 100644 cubicStylization/cubicStylization/autoregister.mel create mode 100644 cubicStylization/cubicStylization/cubicStylization.vcxproj create mode 100644 cubicStylization/cubicStylization/cubicStylization.vcxproj.filters diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8dd4607 --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml \ No newline at end of file diff --git a/cubicStylization/cubicStylization.sln b/cubicStylization/cubicStylization.sln new file mode 100644 index 0000000..e96569d --- /dev/null +++ b/cubicStylization/cubicStylization.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31702.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubicStylization", "cubicStylization\cubicStylization.vcxproj", "{A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Debug|x64.ActiveCfg = Debug|x64 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Debug|x64.Build.0 = Debug|x64 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Debug|x86.ActiveCfg = Debug|Win32 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Debug|x86.Build.0 = Debug|Win32 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Release|x64.ActiveCfg = Release|x64 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Release|x64.Build.0 = Release|x64 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Release|x86.ActiveCfg = Release|Win32 + {A7126FEC-7DB8-4616-A5AE-BEE96C5EE5E4}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8A1B38E7-5FB5-4896-B426-1E8F013FBD8B} + EndGlobalSection +EndGlobal diff --git a/cubicStylization/cubicStylization/CGGTCmd.cpp b/cubicStylization/cubicStylization/CGGTCmd.cpp new file mode 100644 index 0000000..2f6c333 --- /dev/null +++ b/cubicStylization/cubicStylization/CGGTCmd.cpp @@ -0,0 +1,92 @@ +#include "CGGTCmd.h" + +#include +#include + +CGGTCmd::CGGTCmd() : MPxCommand() +{ +} + +CGGTCmd::~CGGTCmd() +{ +} + +const char* cubenessFlag = "-c", * cubenessLongFlag = "-cubeness"; + +MSyntax CGGTCmd::newSyntax() +{ + MSyntax syntax; + syntax.addFlag(cubenessFlag, cubenessLongFlag, MSyntax::kDouble); + return syntax; +} + +MStatus CGGTCmd::doIt(const MArgList& args) +{ + // Uncomment this for testing + // MGlobal::displayInfo("Inside doIt function"); + + // Add command arguments + MString cubeness = ""; + MArgDatabase argData(syntax(), args); + + // Check for command line argument + if (argData.isFlagSet(cubenessFlag)) { + argData.getFlagArgument(cubenessFlag, 0, cubeness); + MGlobal::displayInfo("Step Size Set: " + cubeness); + } + + // Create sphere with radius 'cubeness' + // MGlobal::executeCommand("polySphere -r " + cubeness + "; "); + + // mapping from face id to its 3 vertex ids + std::unordered_map> imTheMap; + + MDagPath node; + MObject component; + MSelectionList list; + MFnDagNode nodeFn; + MGlobal::getActiveSelectionList(list); + for (unsigned int index = 0; index < list.length(); index++) + { + list.getDagPath(index, node, component); + nodeFn.setObject(node); + MGlobal::displayInfo(nodeFn.name().asChar()); + } + MFnMesh selectedObject(node); + MFloatPointArray towMater; + selectedObject.getPoints(towMater, MSpace::kWorld); + MFloatPointArray towMaterOUT = towMater; + /*for (int j = 0; j < towMater.length(); ++j) { + towMaterOUT[j].x *= j + 1; + towMaterOUT[j].y *= j + 1; + towMaterOUT[j].z *= j + 1; + }*/ + + /*for (int i = 0; i < towMater.length(); ++i) { + float pointX = towMater[i].x; + float pointY = towMater[i].y; + float pointZ = towMater[i].z; + MString thisPoint = (std::to_string(pointX) + " " + std::to_string(pointY) + " " + std::to_string(pointZ)).c_str(); + MGlobal::displayInfo(thisPoint); + }*/ + selectedObject.setPoints(towMaterOUT); + + MItMeshVertex vertexIter(node); + MIntArray connected_faces; + for (int i = 0; i < towMater.length(); ++i) { + int index = vertexIter.index(); + vertexIter.getConnectedFaces(connected_faces); + for (int j = 0; j < connected_faces.length(); ++j) { + MIntArray connected_vertices; + selectedObject.getPolygonVertices(connected_faces[j], connected_vertices); + std::vector faceVertices = {connected_vertices[0], connected_vertices[1], connected_vertices[2] }; + MString thisPoint = ("Vertex: " + std::to_string(index) + " " + "connected Vertices: " + std::to_string(faceVertices[0]) + " " + std::to_string(faceVertices[1]) + " " + std::to_string(faceVertices[2])).c_str(); + MGlobal::displayInfo(thisPoint); + imTheMap[connected_faces[j]] = faceVertices; + } + vertexIter.next(); + + } + + return MStatus::kSuccess; +} \ No newline at end of file diff --git a/cubicStylization/cubicStylization/CGGTCmd.h b/cubicStylization/cubicStylization/CGGTCmd.h new file mode 100644 index 0000000..7d02c9c --- /dev/null +++ b/cubicStylization/cubicStylization/CGGTCmd.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class CGGTCmd : public MPxCommand +{ +public: + CGGTCmd(); + virtual ~CGGTCmd(); + static void* creator() { return new CGGTCmd(); } + MStatus doIt(const MArgList& args); + static MSyntax newSyntax(); +}; \ No newline at end of file diff --git a/cubicStylization/cubicStylization/CGGTNode.cpp b/cubicStylization/cubicStylization/CGGTNode.cpp new file mode 100644 index 0000000..bf86408 --- /dev/null +++ b/cubicStylization/cubicStylization/CGGTNode.cpp @@ -0,0 +1,184 @@ +#include "CGGTNode.h" + +MObject CGGTNode::cubeness; +MObject CGGTNode::coarse_faces; +MObject CGGTNode::input_geometry; +MObject CGGTNode::output_geometry; +MTypeId CGGTNode::id(0x8000); + +#define McheckErr(stat,msg) \ + if ( MS::kSuccess != stat ) { \ + cerr << msg; \ + return MS::kFailure; \ + } + +MStatus CGGTNode::compute(const MPlug& plug, MDataBlock& data) { + MStatus returnStatus; + + if (plug == output_geometry) { + // MGlobal::displayInfo("Hello World!"); + + // Input handles + MDataHandle cubenessData = data.inputValue(cubeness, &returnStatus); + McheckErr(returnStatus, "Error getting cubeness data handle\n"); + double cubeness_data = cubenessData.asDouble(); + if (cubeness_data == 0) { + return MS::kSuccess; + } + + MDataHandle coarseFacesData = data.inputValue(coarse_faces, &returnStatus); + McheckErr(returnStatus, "Error getting coarse faces data handle\n"); + double coarsefaces_data = coarseFacesData.asDouble(); + if (coarsefaces_data == 0) { + return MS::kSuccess; + } + + MDataHandle inputGeometryData = data.inputValue(input_geometry, &returnStatus); + McheckErr(returnStatus, "Error getting input geometry data handle\n"); + MObject inputgeometry_data = inputGeometryData.asMesh(); + if (inputgeometry_data.isNull()) { + MGlobal::displayInfo("megan reddy"); + return MS::kSuccess; + } + MDataHandle outputGeometryData = data.outputValue(output_geometry, &returnStatus); + McheckErr(returnStatus, "Error getting output geometry data handle\n"); + outputGeometryData.copy(inputGeometryData); + + // Testing code + MString cubenessStr = std::to_string(cubeness_data).c_str(); + MString facesStr = std::to_string(coarsefaces_data).c_str(); + + MGlobal::displayInfo("Cubeness: " + cubenessStr); + MGlobal::displayInfo("Number of faces: " + facesStr); + + std::unordered_map> imTheMap; + + /*MDagPath node; + MObject component; + MSelectionList list; + MFnDagNode nodeFn; + MGlobal::getActiveSelectionList(list); + for (unsigned int index = 0; index < list.length(); index++) + { + list.getDagPath(index, node, component); + nodeFn.setObject(node); + MGlobal::displayInfo(nodeFn.name().asChar()); + } + MFnMesh selectedObject(node);*/ + MFnMesh selectedObject(outputGeometryData.asMesh()); + MFloatPointArray towMater; + selectedObject.getPoints(towMater, MSpace::kWorld); + MGlobal::displayInfo(("vertices: " + std::to_string(towMater.length())).c_str()); + MFloatPointArray towMaterOUT = towMater; + /*for (int j = 0; j < towMater.length(); ++j) { + towMaterOUT[j].x *= j + 1; + towMaterOUT[j].y *= j + 1; + towMaterOUT[j].z *= j + 1; + }*/ + + /*for (int i = 0; i < towMater.length(); ++i) { + float pointX = towMater[i].x; + float pointY = towMater[i].y; + float pointZ = towMater[i].z; + MString thisPoint = (std::to_string(pointX) + " " + std::to_string(pointY) + " " + std::to_string(pointZ)).c_str(); + MGlobal::displayInfo(thisPoint); + }*/ + //selectedObject.setPoints(towMaterOUT); + MDagPath node; + selectedObject.getPath(node); + MItMeshVertex vertexIter(node); + MIntArray connected_faces; + for (int i = 0; i < towMater.length(); ++i) { + int index = vertexIter.index(); + vertexIter.getConnectedFaces(connected_faces); + int faceCount = 0; + //MGlobal::displayInfo(("faces: " + std::to_string(connected_faces.length())).c_str()); + vertexIter.numConnectedFaces(faceCount); + MGlobal::displayInfo(("faces: " + std::to_string(faceCount)).c_str()); + for (int j = 0; j < connected_faces.length(); ++j) { + MIntArray connected_vertices; + selectedObject.getPolygonVertices(connected_faces[j], connected_vertices); + std::vector faceVertices = { connected_vertices[0], connected_vertices[1], connected_vertices[2] }; + MString thisPoint = ("Vertex: " + std::to_string(index) + " " + "connected Vertices: " + std::to_string(faceVertices[0]) + " " + std::to_string(faceVertices[1]) + " " + std::to_string(faceVertices[2])).c_str(); + MGlobal::displayInfo(thisPoint); + imTheMap[connected_faces[j]] = faceVertices; + } + vertexIter.next(); + + } + + + data.setClean(plug); + } + else + return MS::kUnknownParameter; + + return MS::kSuccess; +} + +void* CGGTNode::creator() { + return new CGGTNode; +} + +MStatus CGGTNode::initialize() { + MFnUnitAttribute unitAttr; + MFnTypedAttribute typedAttr; + MFnNumericAttribute numericAttr; + MStatus returnStatus; + + // Create attributes + CGGTNode::cubeness = numericAttr.create("cubeness", "c", + MFnNumericData::kDouble, + 0.0, &returnStatus); + McheckErr(returnStatus, "ERROR creating CGGTNode cubeness attribute\n"); + + CGGTNode::coarse_faces = numericAttr.create("coarse_faces", "f", + MFnNumericData::kDouble, + 0.0, &returnStatus); + McheckErr(returnStatus, "ERROR creating CGGTNode coarse faces attribute\n"); + + CGGTNode::input_geometry = typedAttr.create("input_geometry", "geom_i", + MFnData::kMesh, + MObject::kNullObj, + &returnStatus); + McheckErr(returnStatus, "ERROR creating CGGTNode input input_geometry attribute\n"); + + CGGTNode::output_geometry = typedAttr.create("output_geometry", "geom_o", + MFnData::kMesh, + MObject::kNullObj, + &returnStatus); + McheckErr(returnStatus, "ERROR creating CGGTNode output output_geometry attribute\n"); + typedAttr.setStorable(false); + + // Add attributes + returnStatus = addAttribute(CGGTNode::cubeness); + McheckErr(returnStatus, "ERROR adding cubeness attribute\n"); + + returnStatus = addAttribute(CGGTNode::coarse_faces); + McheckErr(returnStatus, "ERROR adding coarse faces attribute\n"); + + returnStatus = addAttribute(CGGTNode::input_geometry); + McheckErr(returnStatus, "ERROR adding input_geometry attribute\n"); + + returnStatus = addAttribute(CGGTNode::output_geometry); + McheckErr(returnStatus, "ERROR adding output_geometry attribute\n"); + + // Attribute affects + returnStatus = attributeAffects(CGGTNode::cubeness, + CGGTNode::output_geometry); + McheckErr(returnStatus, "ERROR in cubeness attributeAffects\n"); + + returnStatus = attributeAffects(CGGTNode::coarse_faces, + CGGTNode::output_geometry); + McheckErr(returnStatus, "ERROR in coarse faces attributeAffects\n"); + + returnStatus = attributeAffects(CGGTNode::input_geometry, + CGGTNode::output_geometry); + McheckErr(returnStatus, "ERROR in input geometry attributeAffects\n"); + + return MS::kSuccess; +} + + + + diff --git a/cubicStylization/cubicStylization/CGGTNode.h b/cubicStylization/cubicStylization/CGGTNode.h new file mode 100644 index 0000000..16be11c --- /dev/null +++ b/cubicStylization/cubicStylization/CGGTNode.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "maya/MFnNumericAttribute.h" +#include "maya/MFnTypedAttribute.h" +#include "maya/MFnUnitAttribute.h" +#include +#include +#include +#include +#include +#include "maya/MfnMeshData.h" +#include +#include "maya/MPointArray.h" +#include "maya/MFloatPointArray.h" + + + +class CGGTNode : public MPxNode +{ +public: + CGGTNode() {}; + ~CGGTNode() override {}; + MStatus compute(const MPlug& plug, MDataBlock& data) override; + static void* creator(); + static MStatus initialize(); + + static MObject cubeness; + static MObject coarse_faces; + static MObject input_geometry; + static MObject output_geometry; + static MTypeId id; + +}; \ No newline at end of file diff --git a/cubicStylization/cubicStylization/PluginMain.cpp b/cubicStylization/cubicStylization/PluginMain.cpp new file mode 100644 index 0000000..d14dde0 --- /dev/null +++ b/cubicStylization/cubicStylization/PluginMain.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CGGTCmd.h" +#include "CGGTNode.h" + +MStatus initializePlugin(MObject obj) +{ + MStatus status = MStatus::kSuccess; + MFnPlugin plugin(obj, "MyPlugin", "1.0", "Any"); + + // Register Command + status = plugin.registerCommand("CGGTCmd", CGGTCmd::creator, CGGTCmd::newSyntax); + if (!status) { + status.perror("registerCommand"); + return status; + } + + // Register node + status = plugin.registerNode("CGGTNode", CGGTNode::id, + CGGTNode::creator, CGGTNode::initialize); + if (!status) { + status.perror("registerNode"); + return status; + } + + // Auto-register Mel menu script + char buffer[2048]; + MString pluginPath = plugin.loadPath(); + MString menuPath = MString("source \"") + pluginPath + MString("/autoregister.mel\""); + sprintf_s(buffer, 2048, menuPath.asChar(), pluginPath); + MGlobal::executeCommand(buffer, true); + + return status; +} + +MStatus uninitializePlugin(MObject obj) +{ + MStatus status = MStatus::kSuccess; + MFnPlugin plugin(obj); + + // Command + status = plugin.deregisterCommand("CGGTCmd"); + if (!status) { + status.perror("deregisterCommand"); + return status; + } + + // Node + status = plugin.deregisterNode(CGGTNode::id); + if (!status) { + status.perror("deregisterNode"); + return status; + } + + return status; +} + + diff --git a/cubicStylization/cubicStylization/autoregister.mel b/cubicStylization/cubicStylization/autoregister.mel new file mode 100644 index 0000000..44fe583 --- /dev/null +++ b/cubicStylization/cubicStylization/autoregister.mel @@ -0,0 +1,4 @@ +global string $gMainWindow; +menu -p $gMainWindow -label "Cubic Stylization"; + menuItem -label "Offline Stylization" -command "if (`window -exists offlineWin`) deleteUI offlineWin; window -title \"Offline Cubic Stylization\" -widthHeight 500 500 offlineWin; columnLayout -columnAttach \"both\" 5 -rowSpacing 10 -columnWidth 500; text -l \"Tool Parameters\" -align \"left\"; string $cubenessSlider = `floatSliderGrp -field true -minValue 0 -maxValue 1 -fieldMinValue 0 -fieldMaxValue 1 -precision 3 -label \"Cubeness\" cubenessSlider`; button -label \"Deform\" -w 70 -h 30 -command \"CGGTCmd -c (`floatSliderGrp -q -value cubenessSlider`)\"; showWindow offlineWin;"; + menuItem -label "Real-time Stylization" -command "createNode transform -n CGGT1; createNode mesh -n CGGTShape1 -p CGGT1; sets -add initialShadingGroup CGGTShape1; createNode CGGTNode -n CGGTNode1; connectAttr pCubeShape1.outMesh CGGTNode1.input_geometry; connectAttr CGGTNode1.output_geometry CGGTShape1.inMesh;"; \ No newline at end of file diff --git a/cubicStylization/cubicStylization/cubicStylization.vcxproj b/cubicStylization/cubicStylization/cubicStylization.vcxproj new file mode 100644 index 0000000..03cdafd --- /dev/null +++ b/cubicStylization/cubicStylization/cubicStylization.vcxproj @@ -0,0 +1,158 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a7126fec-7db8-4616-a5ae-bee96c5ee5e4} + cubicStylization + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + .mll + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + NT_PLUGIN + true + C:\Program Files\Autodesk\Maya2022\include + + + Console + true + C:\Program Files\Autodesk\Maya2022\lib + $(OutDir)$(ProjectName).mll + Foundation.lib;OpenMaya.lib;OpenMayaUI.lib;OpenMayaAnim.lib;OpenMayaFX.lib;OpenMayaRender.lib;Image.lib;opengl32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cubicStylization/cubicStylization/cubicStylization.vcxproj.filters b/cubicStylization/cubicStylization/cubicStylization.vcxproj.filters new file mode 100644 index 0000000..24483d9 --- /dev/null +++ b/cubicStylization/cubicStylization/cubicStylization.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file