Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
cmake_minimum_required(VERSION 3.2.2)
project(wireframeDisplay)
cmake_minimum_required(VERSION 3.9)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
SET(MAYA_VERSION 2020 CACHE STRING "Maya version number")
SET(MODULE_NAME ${PROJECT_NAME} CACHE STRING "Name of the module")

file(GLOB SOURCE_FILES "src/*.*")
project(
"wireframeDisplay"
VERSION 1.0
DESCRIPTION "A quick smooth with border conditions"
LANGUAGES CXX
)

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Maya REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
# (defined in FindMaya.cmake, copied here for reference)
# set(MAYA_INSTALL_BASE_PATH "" CACHE STRING
# "Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/"
# )
set(MAYA_VERSION 2020 CACHE STRING "Maya version")

include_directories(${MAYA_INCLUDE_DIR} maya lib ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
link_directories(${MAYA_LIBRARY_DIR})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${MAYA_LIBRARIES} ${OPENGL_LIBRARIES})
set(MAYA_FILES
"src/PluginMain.cpp"
"src/wireframeDisplay.cpp"
"src/shapesDefinition.h"
"src/wireframeDisplay.h"
)

find_package(OpenGL REQUIRED)
find_package(Maya REQUIRED)
add_library(${PROJECT_NAME} SHARED ${MAYA_FILES})
target_link_libraries(${PROJECT_NAME} PRIVATE Maya::Maya OpenGL::GL)
target_include_directories(${PROJECT_NAME}
PRIVATE Maya::Maya
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
)
MAYA_PLUGIN(${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME} ${MAYA_TARGET_TYPE} DESTINATION ${MODULE_NAME}/plug-ins/win64/${MAYA_VERSION})
164 changes: 100 additions & 64 deletions cmake/FindMaya.cmake
Original file line number Diff line number Diff line change
@@ -1,127 +1,163 @@
# The MIT License (MIT)
#
# Copyright (c) 2015 Chad Vernon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# Copyright 2017 Chad Vernon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# - Maya finder module
#.rst:
# FindMaya
# --------
#
# Find Maya headers and libraries.
#
# Imported targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``Maya::Maya``
# The Maya libraries, if found.
#
# Variables that will be defined:
# MAYA_FOUND Defined if a Maya installation has been detected
# MAYA_EXECUTABLE Path to Maya's executable
# MAYA_<lib>_FOUND Defined if <lib> has been found
# MAYA_<lib>_LIBRARY Path to <lib> library
# MAYA_INCLUDE_DIR Path to the devkit's include directories
# MAYA_LIBRARIES All the Maya libraries
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``Maya_FOUND``
# Defined if a Maya installation has been detected
# ``MAYA_INCLUDE_DIR``
# Where to find the headers (maya/MFn.h)
# ``MAYA_LIBRARIES``
# All the Maya libraries.
#

# Set a default Maya version if not specified
if(NOT DEFINED MAYA_VERSION)
set(MAYA_VERSION 2016 CACHE STRING "Maya version")
set(MAYA_VERSION 2017 CACHE STRING "Maya version")
endif()

# OS Specific environment setup
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL")
set(MAYA_INSTALL_BASE_SUFFIX "")
set(MAYA_INC_SUFFIX "include")
set(MAYA_LIB_SUFFIX "lib")
set(MAYA_BIN_SUFFIX "bin")
set(MAYA_TARGET_TYPE LIBRARY)
if(WIN32)
# Windows
set(MAYA_INSTALL_BASE_DEFAULT "C:/Program Files/Autodesk")
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};NT_PLUGIN")
set(OPENMAYA OpenMaya.lib)
set(MAYA_PLUGIN_EXTENSION ".mll")
set(MAYA_TARGET_TYPE RUNTIME)
elseif(APPLE)
# Apple
set(MAYA_INSTALL_BASE_DEFAULT /Applications/Autodesk)
set(MAYA_INC_SUFFIX "devkit/include")
set(MAYA_LIB_SUFFIX "Maya.app/Contents/MacOS")
set(MAYA_BIN_SUFFIX "Maya.app/Contents/bin/")
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};OSMac_")
set(OPENMAYA libOpenMaya.dylib)
set(MAYA_PLUGIN_EXTENSION ".bundle")
else()
# Linux
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};LINUX")
set(MAYA_INSTALL_BASE_DEFAULT /usr/autodesk)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

if(MAYA_VERSION LESS 2016)
SET(MAYA_INSTALL_BASE_SUFFIX -x64)
# Pre Maya 2016 on Linux
set(MAYA_INSTALL_BASE_SUFFIX -x64)
endif()
set(OPENMAYA libOpenMaya.so)
set(MAYA_PLUGIN_EXTENSION ".so")
endif()

set(MAYA_INSTALL_BASE_PATH ${MAYA_INSTALL_BASE_DEFAULT} CACHE STRING
"Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/")

set(MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/Maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})
if(NOT DEFINED MAYA_DEVKIT_BASE)
set(MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})
else()
set(MAYA_LOCATION ${MAYA_DEVKIT_BASE})
endif()

# Maya library directory
find_path(MAYA_LIBRARY_DIR ${OPENMAYA}
#set(CMAKE_FIND_DEBUG_MODE TRUE)
# Maya include directory
find_path(MAYA_INCLUDE_DIR maya/MFn.h
PATHS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
PATH_SUFFIXES
"${MAYA_LIB_SUFFIX}/"
DOC "Maya library path"
"include/"
"devkit/include/"
)

# Maya include directory
find_path(MAYA_INCLUDE_DIR maya/MFn.h
find_library(MAYA_LIBRARY
NAMES
OpenMaya
PATHS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
PATH_SUFFIXES
"${MAYA_INC_SUFFIX}/"
DOC "Maya include path"
"lib/"
"Maya.app/Contents/MacOS/"
NO_DEFAULT_PATH
)
#set(CMAKE_FIND_DEBUG_MODE FALSE)

set(MAYA_LIBRARIES "${MAYA_LIBRARY}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Maya
REQUIRED_VARS MAYA_INCLUDE_DIR MAYA_LIBRARY)
mark_as_advanced(MAYA_INCLUDE_DIR MAYA_LIBRARY)

if (NOT TARGET Maya::Maya)
add_library(Maya::Maya UNKNOWN IMPORTED)
set_target_properties(Maya::Maya PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${MAYA_INCLUDE_DIR}"
IMPORTED_LOCATION "${MAYA_LIBRARY}")

# Maya libraries
set(_MAYA_LIBRARIES OpenMaya OpenMayaAnim OpenMayaFX OpenMayaRender OpenMayaUI Foundation clew)
if (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND MAYA_VERSION LESS 2017)
# Clang and Maya 2016 and older needs to use libstdc++
set_target_properties(Maya::Maya PROPERTIES
INTERFACE_COMPILE_OPTIONS "-std=c++0x;-stdlib=libstdc++")
endif ()
endif()

# Add the other Maya libraries into the main Maya::Maya library
set(_MAYA_LIBRARIES OpenMayaAnim OpenMayaFX OpenMayaRender OpenMayaUI Foundation clew)
foreach(MAYA_LIB ${_MAYA_LIBRARIES})
find_library(MAYA_${MAYA_LIB}_LIBRARY NAMES ${MAYA_LIB} PATHS ${MAYA_LIBRARY_DIR}
find_library(MAYA_${MAYA_LIB}_LIBRARY
NAMES
${MAYA_LIB}
PATHS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
PATH_SUFFIXES
"lib/"
"Maya.app/Contents/MacOS/"
NO_DEFAULT_PATH)
mark_as_advanced(MAYA_${MAYA_LIB}_LIBRARY)
if (MAYA_${MAYA_LIB}_LIBRARY)
set(MAYA_LIBRARIES ${MAYA_LIBRARIES} ${MAYA_${MAYA_LIB}_LIBRARY})
add_library(Maya::${MAYA_LIB} UNKNOWN IMPORTED)
set_target_properties(Maya::${MAYA_LIB} PROPERTIES
IMPORTED_LOCATION "${MAYA_${MAYA_LIB}_LIBRARY}")
set_property(TARGET Maya::Maya APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Maya::${MAYA_LIB})
set(MAYA_LIBRARIES ${MAYA_LIBRARIES} "${MAYA_${MAYA_LIB}_LIBRARY}")
endif()
endforeach()

if (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Clang and Maya needs to use libstdc++
set(MAYA_CXX_FLAGS "-std=c++0x -stdlib=libstdc++")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Maya DEFAULT_MSG MAYA_INCLUDE_DIR MAYA_LIBRARIES)

function(MAYA_PLUGIN _target)
if (WIN32)
set_target_properties(${_target} PROPERTIES
LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin"
)
LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin")
endif()
set_target_properties(${_target} PROPERTIES
COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS}"
PREFIX ""
SUFFIX ${MAYA_PLUGIN_EXTENSION})
endfunction()
71 changes: 36 additions & 35 deletions scripts/creating.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
from maya import cmds

cmds.loadPlugin("wireframeDisplay")

"""
prt, construct = cmds.polySphere(
radius=1.0,
subdivisionsX=20,
subdivisionsY=20,
axis=[0.0, 1.0, 0.0],
createUVs=2,
constructionHistory=True,
)
loc = cmds.createNode("wireframeDisplay", p=prt)
shp = cmds.listRelatives(prt, s=True)[0]
cmds.connectAttr(shp + ".outMesh", loc + ".inMesh", f=True)
"""

for mesh in cmds.ls(type="mesh"):
(prt,) = cmds.listRelatives(mesh, p=True, path=True)
loc = cmds.createNode("wireframeDisplay", p=prt)
cmds.setAttr(loc + ".inputColor", 1, 1, 0)
cmds.setAttr(loc + ".inputAlpha", 0.2)
cmds.connectAttr(mesh + ".outMesh", loc + ".inMesh", f=True)


from maya import cmds

cmds.loadPlugin("wireframeDisplay")
for el in cmds.ls(sl=True, tr=True):
meshes = cmds.listRelatives(el, s=True, type="mesh")
meshes = [shp for shp in meshes if not cmds.getAttr(shp + ".intermediateObject")]
for msh in meshes:
loc = cmds.createNode("wireframeDisplay", p=prt)
cmds.connectAttr(msh + ".outMesh", loc + ".inMesh", f=True)
from __future__ import absolute_import
from maya import cmds

cmds.loadPlugin("wireframeDisplay")

"""
prt, construct = cmds.polySphere(
radius=1.0,
subdivisionsX=20,
subdivisionsY=20,
axis=[0.0, 1.0, 0.0],
createUVs=2,
constructionHistory=True,
)
loc = cmds.createNode("wireframeDisplay", p=prt)
shp = cmds.listRelatives(prt, s=True)[0]
cmds.connectAttr(shp + ".outMesh", loc + ".inMesh", f=True)
"""

for mesh in cmds.ls(type="mesh"):
(prt,) = cmds.listRelatives(mesh, p=True, path=True)
loc = cmds.createNode("wireframeDisplay", p=prt)
cmds.setAttr(loc + ".inputColor", 1, 1, 0)
cmds.setAttr(loc + ".inputAlpha", 0.2)
cmds.connectAttr(mesh + ".outMesh", loc + ".inMesh", f=True)


from maya import cmds

cmds.loadPlugin("wireframeDisplay")
for el in cmds.ls(sl=True, tr=True):
meshes = cmds.listRelatives(el, s=True, type="mesh")
meshes = [shp for shp in meshes if not cmds.getAttr(shp + ".intermediateObject")]
for msh in meshes:
loc = cmds.createNode("wireframeDisplay", p=prt)
cmds.connectAttr(msh + ".outMesh", loc + ".inMesh", f=True)
8 changes: 5 additions & 3 deletions src/wireframeDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void wireframeDisplayData::getPlugs(const MObject& node, bool getCol) {
}
MFnDagNode fn(node);
if (getCol) {
MPlug inputColPlug = fn.findPlug("overrideColorRGB");
MPlug inputColPlug = fn.findPlug("overrideColorRGB", false);
// MPlug inputColPlug = MPlug(node, MPxLocatorNode::overrideColorR);
this->color[0] = inputColPlug.child(0).asFloat();
this->color[1] = inputColPlug.child(1).asFloat();
Expand Down Expand Up @@ -125,8 +125,8 @@ MBoundingBox getBB(const MObject& node) {
//MGlobal::displayInfo(meshBB.name());
*/

MPlug meshBBMI = meshObjDep.findPlug("boundingBoxMin");
MPlug meshBBMX = meshObjDep.findPlug("boundingBoxMax");
MPlug meshBBMI = meshObjDep.findPlug("boundingBoxMin", false);
MPlug meshBBMX = meshObjDep.findPlug("boundingBoxMax", false);
// MGlobal::displayInfo(meshBBMI.name());

MDGModifier dg;
Expand Down Expand Up @@ -252,6 +252,7 @@ MStatus wireframeDisplay::compute(const MPlug& plug, MDataBlock& data) {
return MS::kSuccess;
}

#ifdef MAYA_LEGACY_DISPLAY
// called by legacy default viewport
void wireframeDisplay::draw(M3dView& view, const MDagPath& path, M3dView::DisplayStyle style,
M3dView::DisplayStatus status) {
Expand Down Expand Up @@ -307,6 +308,7 @@ void wireframeDisplay::draw(M3dView& view, const MDagPath& path, M3dView::Displa
view.drawText( MString("wireframeDisplay"), MPoint( 0.0, 0.0, 0.0 ), M3dView::kCenter );
*/
}
#endif

bool wireframeDisplay::isBounded() const { return true; }

Expand Down
Loading