Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sjirka authored Mar 15, 2018
1 parent a6d90cd commit 781ec4b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 17 deletions.
11 changes: 9 additions & 2 deletions SeamsEasyCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <maya\MMatrix.h>
#include <maya\MItDependencyNodes.h>
#include <maya\MArgList.h>
#include <maya\MAngle.h>

SeamsEasyCmd::SeamsEasyCmd()
{
Expand Down Expand Up @@ -45,6 +46,7 @@ MSyntax SeamsEasyCmd::newSyntax()
syntax.addFlag(SORT_FLAG, SORT_FLAG_LONG, MSyntax::kString, MSyntax::kString);
syntax.addFlag(DISTANCEMULTI_FLAG, DISTANCEMULTI_FLAG_LONG, MSyntax::kDouble);
syntax.addFlag(DEPTHMULTI_FLAG, DEPTHMULTI_FLAG_LONG, MSyntax::kDouble);
syntax.addFlag(HARDEDGEANGLE_FLAG, HARDEDGEANGLE_FLAG_LONG, MSyntax::kAngle);

syntax.addArg(MSyntax::kString);

Expand Down Expand Up @@ -318,9 +320,10 @@ MStatus SeamsEasyCmd::queryAttrValue(MPlug& attrPlug) {
MDataHandle hAttr = attrPlug.asMDataHandle();
MFnNumericData::Type type = hAttr.numericType();

if (attrPlug == SeamsEasyNode::aProfileMode) {
if (attrPlug == SeamsEasyNode::aProfileMode)
appendToResult(attrPlug.asShort());
}
else if (attrPlug == SeamsEasyNode::aHardEdgeAngle)
appendToResult(attrPlug.asMAngle().as(MAngle::uiUnit()));
else {
switch (type) {
case MFnNumericData::kBoolean:
Expand Down Expand Up @@ -357,6 +360,10 @@ MStatus SeamsEasyCmd::setFlagAttr(MArgDatabase& argData, char *flag, MPlug& attr
int value = argData.flagArgumentBool(flag, 0, &status);
status = m_dagMod.newPlugValueInt(attrPlug, value);
}
else if (attrPlug == SeamsEasyNode::aHardEdgeAngle) {
MAngle value = argData.flagArgumentMAngle(flag, 0, &status);
status = m_dagMod.newPlugValueMAngle(attrPlug, value);
}
else {
switch (type) {
case MFnNumericData::kBoolean: {
Expand Down
11 changes: 8 additions & 3 deletions SeamsEasyCmd.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include "SeamsEasyNode.h"
#include "../_library/SNode.h"
#include "SNode.h"

#include <maya\MPxCommand.h>
#include <maya\MDGModifier.h>
#include <maya\MDagModifier.h>
#include <maya\MDagPath.h>
#include <maya\MDistance.h>
#include <maya\MArgDatabase.h>
#include <map>
#include <maya\MPlugArray.h>

#include <map>

#define THICKNESS_FLAG_LONG "-thickness"
#define THICKNESS_FLAG "-th"

Expand Down Expand Up @@ -48,6 +49,9 @@
#define DEPTHMULTI_FLAG_LONG "-depthMultiplier"
#define DEPTHMULTI_FLAG "-dpm"

#define HARDEDGEANGLE_FLAG_LONG "-hardEdgeAngle"
#define HARDEDGEANGLE_FLAG "-hea"

class SeamsEasyCmd : public MPxCommand
{
public:
Expand Down Expand Up @@ -89,7 +93,8 @@ class SeamsEasyCmd : public MPxCommand
{ DEPTH_FLAG, SeamsEasyNode::aProfileDepth },
{ SUBDIVS_FLAG, SeamsEasyNode::aProfileSubdivs },
{ DISTANCEMULTI_FLAG, SeamsEasyNode::aDistanceMultiplier },
{ DEPTHMULTI_FLAG, SeamsEasyNode::aDepthMultiplier }
{ DEPTHMULTI_FLAG, SeamsEasyNode::aDepthMultiplier },
{ HARDEDGEANGLE_FLAG, SeamsEasyNode::aHardEdgeAngle },
};
};

28 changes: 22 additions & 6 deletions SeamsEasyNode.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "SeamsEasyNode.h"
#include "StitchEasyNode.h"
#include "../_library/SNode.h"
#include "../_library/SPlane.h"
#include "SNode.h"
#include "SPlane.h"

#include <maya\MFnNumericAttribute.h>
#include <maya\MFnTypedAttribute.h>
Expand All @@ -22,6 +22,7 @@
#include <maya\MDGModifier.h>
#include <maya\MDagModifier.h>
#include <maya\MItDependencyGraph.h>
#include <maya\MAngle.h>

MTypeId SeamsEasyNode::id(0x00127891);

Expand Down Expand Up @@ -51,6 +52,8 @@ MObject SeamsEasyNode::aProfileDepth;
MObject SeamsEasyNode::aProfileSubdivs;
MObject SeamsEasyNode::aProfileCurve;

MObject SeamsEasyNode::aHardEdgeAngle;

OffsetParams::Compare OffsetParams::compare = OffsetParams::kDistance;

SeamsEasyNode::SeamsEasyNode(){
Expand Down Expand Up @@ -216,6 +219,12 @@ MStatus SeamsEasyNode::initialize()
attributeAffects(aDepthMultiplier, aOutMesh);
attributeAffects(aDepthMultiplier, aOutStitchLines);

aHardEdgeAngle = uAttr.create("hardEdgeAngle", "hardEdgeAngle", MFnUnitAttribute::kAngle, M_PI/2, &status);
nAttr.setMin(0);
nAttr.setMax(180);
addAttribute(aHardEdgeAngle);
attributeAffects(aHardEdgeAngle, aOutMesh);

return MS::kSuccess;
}

Expand Down Expand Up @@ -276,11 +285,13 @@ MStatus SeamsEasyNode::compute(const MPlug &plug, MDataBlock &dataBlock) {
bool extrudeAll = dataBlock.inputValue(aExtrudeAllBoundaries).asBool();
float thickness = (float)dataBlock.inputValue(aExtrudeThickness).asDistance().as(MDistance::internalUnit());
unsigned int divisions = dataBlock.inputValue(aExtrudeDivisions).asInt();
double hardEdgeAngle = dataBlock.inputValue(aHardEdgeAngle).asAngle().as(MAngle::internalUnit());

// Load profile settings //////////////////////////////////////////////////////////////////////
std::set <OffsetParams> offsetParams;
OffsetParams::compare = OffsetParams::kDistance;

dirtyProfile = true;
if (dirtyProfile) {
std::set <OffsetParams> offsetParamsTmp;

Expand Down Expand Up @@ -412,11 +423,11 @@ MStatus SeamsEasyNode::compute(const MPlug &plug, MDataBlock &dataBlock) {
MObject stitchComponent = stitchCompData.create(MFn::kMeshEdgeComponent);

// Insert new loops
std::map <unsigned int, MIntArray> loopEdges;
m_loopEdges.clear();
for (auto param = offsetParams.rbegin(); param != offsetParams.rend(); param++) {
m_profileMesh.getActiveEdges(loopEdges[param->index]);
m_profileMesh.getActiveEdges(m_loopEdges[param->index]);
if (param->stitch)
stitchCompData.addElements(loopEdges[param->index]);
stitchCompData.addElements(m_loopEdges[param->index]);
status = m_profileMesh.offsetEdgeloops(param->distance + gap / 2, (0 == param->distance && param==--offsetParams.rend()) ? false : true);
CHECK_MSTATUS_AND_RETURN_IT(status);
}
Expand All @@ -429,7 +440,7 @@ MStatus SeamsEasyNode::compute(const MPlug &plug, MDataBlock &dataBlock) {
// Pull loop vertices
for (auto param : offsetParams){
MIntArray loopVertices;
status = m_profileMesh.getEdgeVertices(loopEdges[param.index], loopVertices);
status = m_profileMesh.getEdgeVertices(m_loopEdges[param.index], loopVertices);
CHECK_MSTATUS_AND_RETURN_IT(status);
status = m_profileMesh.pullVertices(loopVertices, param.depth);
CHECK_MSTATUS_AND_RETURN_IT(status);
Expand All @@ -448,6 +459,11 @@ MStatus SeamsEasyNode::compute(const MPlug &plug, MDataBlock &dataBlock) {
CHECK_MSTATUS_AND_RETURN_IT(status);
}

for (auto &loop : m_loopEdges) {
status = extrudeMesh.setHardEdges(loop.second, hardEdgeAngle);
CHECK_MSTATUS_AND_RETURN_IT(status);
}

status = dataBlock.outputValue(aOutMesh).set(extrudeMesh.getObject());
CHECK_MSTATUS_AND_RETURN_IT(status);
dataBlock.setClean(aOutMesh);
Expand Down
7 changes: 6 additions & 1 deletion SeamsEasyNode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "SSeamMesh.h"

#include <maya\MPxNode.h>
#include <maya\MItMeshPolygon.h>
#include <maya\MItMeshEdge.h>
Expand All @@ -8,10 +10,10 @@
#include <maya\MNodeMessage.h>
#include <maya\MObjectArray.h>
#include <maya\MCallbackIdArray.h>

#include <set>
#include <map>
#include <deque>
#include <SSeamMesh.h>

class OffsetParams {
public:
Expand Down Expand Up @@ -128,13 +130,16 @@ class SeamsEasyNode : public MPxNode{
static MObject aProfileSubdivs;
static MObject aProfileCurve;

static MObject aHardEdgeAngle;

private:
MObject
m_sourceMesh,
m_component;
SSeamMesh
m_baseMesh,
m_profileMesh;
std::map <unsigned int, MIntArray> m_loopEdges;

MCallbackIdArray callbackIds;

Expand Down
4 changes: 2 additions & 2 deletions StitchEasyCmd.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "StitchEasyCmd.h"
#include "StitchEasyNode.h"
#include "SeamsEasyNode.h"
#include "../_library/SShadingGroup.h"
#include "SNode.h"

#include <maya\MSyntax.h>
#include <maya\MSelectionList.h>
Expand All @@ -13,8 +15,6 @@
#include <maya\MFnTransform.h>
#include <maya\MMatrix.h>
#include <maya\MArgList.h>
#include <SShadingGroup.h>
#include <SNode.h>
#include <maya\MItDependencyGraph.h>

StitchEasyCmd::StitchEasyCmd()
Expand Down
2 changes: 2 additions & 0 deletions StitchEasyCmd.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include "StitchEasyNode.h"

#include <maya\MPxCommand.h>
#include <maya\MDGModifier.h>
#include <maya\MDagModifier.h>
#include <maya\MDagPath.h>
#include <maya\MDistance.h>
#include <maya\MAngle.h>
#include <maya\MArgDatabase.h>

#include <map>

#define DISTANCE_FLAG_LONG "-distance"
Expand Down
2 changes: 1 addition & 1 deletion StitchEasyCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void StitchEasyCtx::deleteAction() {

void StitchEasyCtx::completeAction(){
if (m_nodeName!="") {
MSelectionList selection;
MSelectionList selection;q
MGlobal::getActiveSelectionList(selection, true);

MItSelectionList itSelected(selection, MFn::kMesh);
Expand Down
3 changes: 2 additions & 1 deletion StitchEasyCtxCmd.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <maya\MPxContextCommand.h>
#include "StitchEasyCtx.h"

#include <maya\MPxContextCommand.h>

class StitchEasyCtxCmd : public MPxContextCommand
{
public:
Expand Down
4 changes: 3 additions & 1 deletion StitchEasyNode.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include "SMesh.h"

#include <maya\MPxNode.h>
#include <maya\MFnComponentListData.h>
#include <maya\MFnSingleIndexedComponent.h>
#include <SMesh.h>
#include <maya\MMatrix.h>

class StitchEasyNode : public MPxNode
Expand Down

0 comments on commit 781ec4b

Please sign in to comment.