0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arnold for Mayaのプラグインを作成するためのビルド設定について

0
Posted at

環境

  • Windows
  • Autodesk Maya 2026.1
  • MtoA (Arnold for Maya) 5.5.4
  • Visual Studio 2022

Arnoldのプラグイン作成について

ArnoldのプラグインはC++で作成できます。サンプルコードは公式ドキュメントのプラグイン - Arnold Developer Guide で確認できます。本記事では、公式ドキュメントには記載されていないビルド時に必要なCMakeLists.txtの設定方法に焦点を当てて説明します。

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(arnold_sample_plugin)

set(CMAKE_CXX_STANDARD 17)

set(ARNOLD_ROOT "C:/Program Files/Autodesk/Arnold/maya2026")

include_directories(
        "${ARNOLD_ROOT}/include/arnold"
        "${ARNOLD_ROOT}/include/axftoa"
        "${ARNOLD_ROOT}/include/mtoa"
        "${ARNOLD_ROOT}/include/renderview"
)

link_directories("${ARNOLD_ROOT}/lib")

add_library(arnold_sample_plugin SHARED sample.cpp)

target_link_libraries(${PROJECT_NAME}
        ai
        ai_renderview
        AxFtoA
        mtoa_api
)

set(ARNOLD_ROOT "...")

Arnold for Mayaのインストールパスを指定しています。この変数は必須ではありませんが、
include_directoriesやlink_directoriesの記述を簡潔にするために使用しています。

include_directories(...)

ビルド時に必要なヘッダファイルは、インストールパス配下の include ディレクトリ内にあります。サブディレクトリごとに分かれているため、必要なディレクトリを指定します。(例として主要なものをすべて指定していますが、実際に使用しないものについては指定不要です)

link_directories(...)

ライブラリファイルはインストールパス配下の lib ディレクトリ内にありますので、
そこを指定しています。

add_library(... SHARED xxxx.cpp)

Arnoldプラグインは共有ライブラリ(SHARED)としてビルドします。
本記事では、 sample.cpp というファイルをビルド対象としています。

target_link_libraries(...)

必要なArnold関連のライブラリをリンクします。(例として主要なものをすべて指定していますが、実際に使用しないものについては指定不要です)

サンプルコード

ビルド確認用のサンプルコードです。C++コードの詳細については、簡単なプラグインを作成する - Arnold Developer Guide をご参照ください。

#include <ai.h>

#include <cstdio>

AI_SHADER_NODE_EXPORT_METHODS(SampleMethods);

enum SampleParams { p_color };

node_parameters { AiParameterRGB("color", 0.5f, 0.5f, 0.5f); }

node_initialize {}

node_update {}

node_finish {}

shader_evaluate { sg->out.RGB() = AiShaderEvalParamRGB(p_color); }

node_loader {
  if (i > 0) return false;
  node->methods = SampleMethods;
  node->output_type = AI_TYPE_RGB;
  node->name = "sampleShader";
  node->node_type = AI_NODE_SHADER;
  snprintf(node->version, sizeof(node->version), "%s", AI_VERSION);
  return true;
}

ビルドの流れ

プロジェクトディレクトリに CMakeLists.txtsample.cpp を配置し、コマンドラインやIDEを使ってビルドします。

ここではWindowsのコマンドラインでのビルド手順を例示します。
Visual Studioのコンパイラを使用していることを前提とします。

cd /d <プロジェクトディレクトリのパス>

:: CMakeLists.txt を基にビルド用ファイルを生成
cmake -B <ビルドディレクトリのパス> -S .

:: Release構成でビルドを実行
cmake --build <ビルドディレクトリのパス> --config Release

Mayaでの確認

生成した .dll を任意のディレクトリにコピーして、環境変数 ARNOLD_PLUGIN_PATH にそのディレクトリのパスを設定してください。Maya起動後、HyperShadeで該当ノードが追加されていればビルド成功です。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?