Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-104984 MAYA-104641 - Material export via registry #574

Merged
merged 11 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions lib/mayaUsd/commands/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ target_sources(${PROJECT_NAME}
PRIVATE
baseExportCommand.cpp
baseImportCommand.cpp
baseListShadingModesCommand.cpp
)

set(headers
baseExportCommand.h
baseImportCommand.h
baseListShadingModesCommand.h
)

# -----------------------------------------------------------------------------
Expand Down
75 changes: 75 additions & 0 deletions lib/mayaUsd/commands/baseListShadingModesCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "baseListShadingModesCommand.h"

#include <mayaUsd/fileio/registryHelper.h>
#include <mayaUsd/fileio/shading/shadingModeRegistry.h>

#include <maya/MArgList.h>
#include <maya/MArgDatabase.h>
#include <maya/MStatus.h>
#include <maya/MString.h>
#include <maya/MSyntax.h>

#include <mutex>
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

PXR_NAMESPACE_USING_DIRECTIVE

MAYAUSD_NS_DEF {

MStatus
MayaUSDListShadingModesCommand::doIt(const MArgList& args) {
MStatus status;
MArgDatabase argData(syntax(), args, &status);

if (status != MS::kSuccess) {
return status;
}

TfTokenVector v;
if (argData.isFlagSet("export")) {
v = UsdMayaShadingModeRegistry::ListExporters();
} else if (argData.isFlagSet("import")) {
v = UsdMayaShadingModeRegistry::ListImporters();
}

// Always include the "none" shading mode.
appendToResult(UsdMayaShadingModeTokens->none.GetText());

for (const auto& e : v) {
appendToResult(e.GetText());
}

return MS::kSuccess;
}

MSyntax
MayaUSDListShadingModesCommand::createSyntax() {
MSyntax syntax;
syntax.addFlag("-ex", "-export", MSyntax::kNoArg);
syntax.addFlag("-im", "-import", MSyntax::kNoArg);

syntax.enableQuery(false);
syntax.enableEdit(false);

return syntax;
}

void* MayaUSDListShadingModesCommand::creator() {
return new MayaUSDListShadingModesCommand();
}

} // MAYAUSD_NS_DEF
39 changes: 39 additions & 0 deletions lib/mayaUsd/commands/baseListShadingModesCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MAYA_LIST_SHADING_MODES_COMMAND_H
#define MAYA_LIST_SHADING_MODES_COMMAND_H

#include <mayaUsd/base/api.h>

#include <pxr/pxr.h>

#include <maya/MPxCommand.h>

MAYAUSD_NS_DEF {

class MAYAUSD_CORE_PUBLIC MayaUSDListShadingModesCommand : public MPxCommand
{
public:
MStatus doIt(const MArgList& args) override;
bool isUndoable () const override { return false; };

static MSyntax createSyntax();
static void* creator();
};

}

#endif
8 changes: 5 additions & 3 deletions lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(
HdVP2ShaderFragmentsTokens,
MAYAUSD_CORE_PUBLIC_USD_PREVIEW_SURFACE_TOKENS);

TF_DEFINE_PRIVATE_TOKENS(
_tokens,

Expand Down Expand Up @@ -64,8 +68,6 @@ TF_DEFINE_PRIVATE_TOKENS(
(UsdPrimvarReader_float3)
(UsdPrimvarReader_float4)
(UsdPrimvarReader_vector)

(UsdPreviewSurface)
);

static const TfTokenVector _LanguageSpecificFragmentNames = {
Expand Down Expand Up @@ -108,7 +110,7 @@ static const TfTokenVector _FragmentGraphNames = {
_tokens->BasisCurvesLinearFallbackShader,
_tokens->FallbackCPVShader,
_tokens->FallbackShader,
_tokens->UsdPreviewSurface
HdVP2ShaderFragmentsTokens->SurfaceFragmentGraphName
};


Expand Down
12 changes: 12 additions & 0 deletions lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@
#define HD_VP2_SHADER_FRAGMENTS

#include <pxr/pxr.h>
#include <pxr/base/tf/staticTokens.h>

#include <mayaUsd/base/api.h>

#include <maya/MStatus.h>

PXR_NAMESPACE_OPEN_SCOPE

#define MAYAUSD_CORE_PUBLIC_USD_PREVIEW_SURFACE_TOKENS \
((SurfaceFragmentGraphName, "UsdPreviewSurface"))

TF_DECLARE_PUBLIC_TOKENS(
HdVP2ShaderFragmentsTokens,
MAYAUSD_CORE_PUBLIC,
MAYAUSD_CORE_PUBLIC_USD_PREVIEW_SURFACE_TOKENS);

/*! \brief Registration/deregistration of HdVP2 shader fragments.
\class HdVP2ShaderFragments
*/
class HdVP2ShaderFragments
{
public:
//! Register all HdVP2 fragments
MAYAUSD_CORE_PUBLIC
static MStatus registerFragments();
mattyjams marked this conversation as resolved.
Show resolved Hide resolved

//! Deregister all HdVP2 fragments
Expand Down
1 change: 1 addition & 0 deletions lib/usd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ if(BUILD_HDMAYA)
add_subdirectory(hdMaya)
endif()

add_subdirectory(pxrUsdPreviewSurface)
add_subdirectory(translators)
add_subdirectory(schemas)

Expand Down
145 changes: 145 additions & 0 deletions lib/usd/pxrUsdPreviewSurface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#
# Copyright 2020 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set(TARGET_NAME mayaUsdPreviewSurface)
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

set(install_destination
${CMAKE_INSTALL_PREFIX}/lib/usd
)

set(resources_install_path
${CMAKE_INSTALL_PREFIX}/lib/usd/${TARGET_NAME}/resources
)

set(library_install_path
${CMAKE_INSTALL_PREFIX}/lib
)

add_library(${TARGET_NAME} SHARED)

# -----------------------------------------------------------------------------
# sources
# -----------------------------------------------------------------------------
target_sources(${TARGET_NAME}
PRIVATE
usdPreviewSurface.cpp
usdPreviewSurfacePlugin.cpp
usdPreviewSurfaceShadingNodeOverride.cpp
usdPreviewSurfaceWriter.cpp
)

# -----------------------------------------------------------------------------
# compiler configuration
# -----------------------------------------------------------------------------
target_compile_definitions(${TARGET_NAME}
PRIVATE
PXRUSDPREVIEWSURFACE_EXPORTS
$<$<BOOL:${IS_MACOSX}>:OSMac_>
)

mayaUsd_compile_config(${TARGET_NAME})

mayaUsd_promoteHeaderList(
HEADERS
usdPreviewSurfacePlugin.h
BASEDIR
${TARGET_NAME}
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
target_include_directories(${TARGET_NAME}
PRIVATE
${MAYA_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${TARGET_NAME}
PRIVATE
arch
gf
plug
sdf
tf
vt
usdShade
${MAYA_LIBRARIES}
mayaUsd
mayaUsd_Schemas
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
)

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib")
mayaUsd_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib")
if(DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib")
elseif(DEFINED PXR_USD_LOCATION)
mayaUsd_add_rpath(rpath "${PXR_USD_LOCATION}/lib")
endif()
if(IS_LINUX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib64")
endif()
if(IS_MACOSX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../../../Maya.app/Contents/MacOS")
endif()
mayaUsd_install_rpath(rpath ${TARGET_NAME})
endif()

#------------------------------------------------------------------------------
# install
#------------------------------------------------------------------------------
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/plugInfo.json"
"${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json"
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json
DESTINATION ${resources_install_path}
)

#install top level plugInfo.json that includes the configured plugInfo.json
install(CODE
"file(WRITE \"${CMAKE_CURRENT_BINARY_DIR}/lib/usd/plugInfo.json\" \"{\n \\\"Includes\\\": [ \\\"*/resources/\\\" ]\n}\")"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/usd/plugInfo.json
DESTINATION ${install_destination}
)
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

install(
TARGETS ${TARGET_NAME}
LIBRARY
DESTINATION ${library_install_path}
ARCHIVE
DESTINATION ${library_install_path}
RUNTIME
DESTINATION ${library_install_path}
)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}>
DESTINATION ${library_install_path} OPTIONAL
)
endif()

install(
FILES AEpxrUsdPreviewSurfaceTemplate.mel
DESTINATION plugin/adsk/scripts
)
39 changes: 39 additions & 0 deletions lib/usd/pxrUsdPreviewSurface/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright 2018 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef PXRUSDPREVIEWSURFACE_API_H
#define PXRUSDPREVIEWSURFACE_API_H

#include <pxr/base/arch/export.h>

#if defined(PXR_STATIC)
# define PXRUSDPREVIEWSURFACE_API
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...)
# define PXRUSDPREVIEWSURFACE_LOCAL
#else
# if defined(PXRUSDPREVIEWSURFACE_EXPORTS)
# define PXRUSDPREVIEWSURFACE_API ARCH_EXPORT
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
# else
# define PXRUSDPREVIEWSURFACE_API ARCH_IMPORT
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
# endif
# define PXRUSDPREVIEWSURFACE_LOCAL ARCH_HIDDEN
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <pxrUsdPreviewSurface/usdPreviewSurface.h>
#include "usdPreviewSurface.h"

#include <pxr/pxr.h>

Expand Down
Loading